On Thu, Jul 28, 2011 at 11:32 AM, Chris Foster <[email protected]> wrote:
> You probably noticed that I've
> given thought to C++98 support, so that's not necessarily a deal
> breaker. However, it's rather painful to wrap tfm::format() inside
> another interface (for example, ErrorHandler::error()) if you don't have
> varadic templates. A bit of judicious code generation using python can
> avoid any manual copy & paste, but it's still not incredibly nice.
I figured out how to let the user define their own wrappers for tfm::format()
using a macro so I think I can declare complete C++98 support now! Example
usage from the README:
The C++0x function
template<typename... Args>
void error(int code, const char* fmt, const Args&... args)
{
std::cerr << "error (code " << code << ")";
tfm::format(std::cerr, fmt, args...);
}
can be simulated with the following macro call:
#define TINYFORMAT_WRAP_FORMAT_EXTRA_ARGS int code,
TINYFORMAT_WRAP_FORMAT(
void, /* return type */
error, /* function name */
std::cerr << "error (code " << code << ")";, /* stuff before format()*/
std::cerr, /* stream name */
/*empty*/ /* stuff after format() */
)
#undef TINYFORMAT_WRAP_FORMAT_EXTRA_ARGS
This should let us use tinyformat in ErrorHandler without much fuss. I admit
this was one of my goals, especially since aqsis has a very similar
ErrorHandler class with a slightly different - but still ugly - approach to
formatting.
Apologies for the spam to everyone on the OIIO list who doesn't care about
this little library, I'm rather excessively enthusiastic about it right now.
~Chris
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org