Created
June 9, 2015 04:55
-
-
Save vitaut/d9ad0265fa4cb6d8013d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define FMT_HEADER_ONLY | |
#include "format.h" | |
struct Syschar { | |
char c; | |
Syschar(char c = 0) : c(c) {} | |
operator char() const { return c; } | |
}; | |
namespace fmt { | |
namespace internal { | |
template <> | |
class CharTraits<Syschar> : public BasicCharTraits<Syschar> { | |
public: | |
static Syschar convert(char value) { return value); } | |
static Syschar convert(Syschar value) { return value; } | |
template <typename T> | |
static int format_float(Syschar *buffer, std::size_t size, | |
const Syschar *format, unsigned width, int precision, T value) { | |
// floating point formatting goes here | |
return 0; | |
} | |
}; | |
} | |
} | |
namespace { | |
template <> | |
inline Arg::StringValue<Syschar> ignore_incompatible_str( | |
Arg::StringValue<wchar_t>) { return fmt::internal::Arg::StringValue<Syschar>(); } | |
} | |
void print(const Syschar *format_str, fmt::ArgList args) { | |
fmt::BasicMemoryWriter<Syschar> w; | |
fmt::BasicFormatter<Syschar> f(w); | |
f.format(format_str, args); | |
const Syschar *c = w.c_str(); | |
while (*c) | |
std::putc((c++)->c, stdout); | |
} | |
FMT_VARIADIC(void, print, const Syschar *) | |
int main() { | |
const Syschar str[] = {'t', 'e', 's', 't', '\0'}; | |
print(str); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment