From c812c92d1a1835f0bda783e709481188c8d92225 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 15 Mar 2014 19:34:59 -0700 Subject: Clean up header organization --- src/io/cxxstdio.hpp | 61 +++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) (limited to 'src/io/cxxstdio.hpp') diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp index 753a1fc..0324ebc 100644 --- a/src/io/cxxstdio.hpp +++ b/src/io/cxxstdio.hpp @@ -24,9 +24,10 @@ # include # include -// TODO get rid of these header order violations -# include "../common/const_array.hpp" -# include "../common/utils2.hpp" +# include "../compat/cast.hpp" + +# include "../generic/const_array.hpp" +# include "../generic/enum.hpp" # include "fwd.hpp" @@ -213,27 +214,25 @@ namespace cxxstdio } }; -# define XPRINTF(out, fmt, ...) \ - (/*[&]() -> int*/ \ - { \ - struct format_impl \ - { \ - constexpr static \ - const char *print_format() { return fmt; } \ - }; \ - /*return*/ cxxstdio::PrintFormatter::print(out, ## __VA_ARGS__); \ - }/*()*/) +# define XPRINTF(out, fmt, ...) \ + ({ \ + struct format_impl \ + { \ + constexpr static \ + const char *print_format() { return fmt; } \ + }; \ + cxxstdio::PrintFormatter::print(out, ## __VA_ARGS__); \ + }) -# define XSCANF(out, fmt, ...) \ - (/*[&]() -> int*/ \ - { \ - struct format_impl \ - { \ - constexpr static \ - const char *scan_format() { return fmt; } \ - }; \ - /*return*/ cxxstdio::ScanFormatter::scan(out, ## __VA_ARGS__); \ - }/*()*/) +# define XSCANF(out, fmt, ...) \ + ({ \ + struct format_impl \ + { \ + constexpr static \ + const char *scan_format() { return fmt; } \ + }; \ + cxxstdio::ScanFormatter::scan(out, ## __VA_ARGS__); \ + }) # define FPRINTF(file, fmt, ...) XPRINTF(/*no_cast*/(file), fmt, ## __VA_ARGS__) # define FSCANF(file, fmt, ...) XSCANF(no_cast(file), fmt, ## __VA_ARGS__) @@ -241,23 +240,21 @@ namespace cxxstdio # define SPRINTF(str, fmt, ...) XPRINTF(base_cast(str), fmt, ## __VA_ARGS__) # define SNPRINTF(str, n, fmt, ...) XPRINTF(base_cast&>(str), fmt, ## __VA_ARGS__) # define SCANF(fmt, ...) FSCANF(stdin, fmt, ## __VA_ARGS__) -# define SSCANF(str, fmt, ...) XSCANF(/*ZString or compatible*/str, fmt, ## __VA_ARGS__) +# define SSCANF(str, fmt, ...) XSCANF(maybe_cast(str), fmt, ## __VA_ARGS__) # define STRPRINTF(fmt, ...) \ - (/*[&]() -> AString*/ \ - { \ + ({ \ AString _out_impl; \ SPRINTF(_out_impl, fmt, ## __VA_ARGS__); \ - /*return*/ _out_impl; \ - }/*()*/) + _out_impl; \ + }) # define STRNPRINTF(n, fmt, ...) \ - (/*[&]() -> VString*/ \ - { \ + ({ \ VString _out_impl; \ SNPRINTF(_out_impl, n, fmt, ## __VA_ARGS__); \ - /*return*/ _out_impl; \ - }/*()*/) + _out_impl; \ + }) } // namespace cxxstdio -- cgit v1.2.3-60-g2f50