examples/example.arguments.void_pointers/example.arguments.void_pointers.cpp
This is an example showing how to use the void pointer conversion shims that come with Pantheios, but that are not included by default.
#define FASTFORMAT_USE_VOID_POINTERS_CONVERSION_SHIMS
#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>
static int main_(int , char** )
{
void* p = &p;
void const* pc = &pc;
void volatile* pv = &pv;
void const volatile* pcv = &pcv;
#ifdef FASTFORMAT_USE_WIDE_STRINGS
fastformat::fmtln(std::wcout, L"a void* pointer: {0}", p);
fastformat::fmtln(std::wcout, L"a void const* pointer: {0}", pc);
fastformat::fmtln(std::wcout, L"a void volatile* pointer: {0}", pv);
fastformat::fmtln(std::wcout, L"a void const volatile* pointer: {0}", pcv);
fastformat::writeln(std::wcout, L"a void* pointer: ", p);
fastformat::writeln(std::wcout, L"a void const* pointer: ", pc);
fastformat::writeln(std::wcout, L"a void volatile* pointer: ", pv);
fastformat::writeln(std::wcout, L"a void const volatile* pointer: ", pcv);
#else
fastformat::fmtln(std::cout, "a void* pointer: {0}", p);
fastformat::fmtln(std::cout, "a void const* pointer: {0}", pc);
fastformat::fmtln(std::cout, "a void volatile* pointer: {0}", pv);
fastformat::fmtln(std::cout, "a void const volatile* pointer: {0}", pcv);
fastformat::writeln(std::cout, "a void* pointer: ", p);
fastformat::writeln(std::cout, "a void const* pointer: ", pc);
fastformat::writeln(std::cout, "a void volatile* pointer: ", pv);
fastformat::writeln(std::cout, "a void const volatile* pointer: ", pcv);
#endif
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;
}