examples/example.arguments.boolean/example.arguments.boolean.cpp
This is an example showing how to use the
bool
conversion shims that come with Pantheios, but that are not included by default.
#include <fastformat/fastformat.h>
#include <fastformat/shims/conversion/filter_type/bool.hpp>
#include <fastformat/sinks/ostream.hpp>
#include <fastformat/fastformat.hpp>
#include <exception>
#include <iostream>
#include <string>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
#include <stdlib.h>
#ifdef FASTFORMAT_NO_FILTER_TYPE_CONVERSION_SHIM_SUPPORT
# error Cannot compile this file with a compiler that does not support the filter_type mechanism
#endif
static int main_(int , char** )
{
#ifdef FASTFORMAT_USE_WIDE_STRINGS
# define stm std::wcout
#else
# define stm std::cout
#endif
const bool True = true;
const bool False = false;
fastformat::fmtln(stm, FASTFORMAT_LITERAL_STRING("True={0}"), True);
fastformat::fmtln(stm, FASTFORMAT_LITERAL_STRING("False={0}"), False);
fastformat::writeln(stm, FASTFORMAT_LITERAL_STRING("True="), True);
fastformat::writeln(stm, FASTFORMAT_LITERAL_STRING("False="), False);
return EXIT_SUCCESS;
}
int main(int argc, char** argv)
{
try
{
return main_(argc, argv);
}
catch(std::exception& x)
{
cerr << "Unhandled error: " << x.what() << endl;
}
catch(...)
{
cerr << "Unhandled unknown error" << endl;
}
return EXIT_FAILURE;
}