Monday, November 8, 2010

Pantheios 1.0.1 beta 198 released: new i and xi inserters

The latest release of Pantheios includes two new inserters, pantheios::i and pantheios::xi. The former is a typedef for the pantheios::integer inserter class, and may be used interchangeably with it:

  #include <pantheios/inserters/i.hpp>
  #include <pantheios/pan.hpp>
  int n = 10;

  pan::log_DEBUG("i=", pan::i(n));
  pan::log_DEBUG("i=", pan::i(n, -10));
  pan::log_DEBUG("i=", pan::i(n, -10, pan::fmt::hex));

produces the same output (and effectively the same binary) as:

  #include <pantheios/inserters/integer.hpp>
  #include <pantheios/pan.hpp>

  int n = 10;

  pan::log_DEBUG("i=", pan::integer(n));
  pan::log_DEBUG("i=", pan::integer(n, -10));
  pan::log_DEBUG("i=", pan::integer(n, -10, pan::fmt::hex));

The latter is actually a new class, and is used specifically for inserting integers in hexadecimal form, optionally specifying minimum width:

  #include <pantheios/inserters/xi.hpp>
  #include <pantheios/pan.hpp>
  int n = 16;

  pan::log_DEBUG("i=", pan::xi(n));
  pan::log_DEBUG("i=", pan::xi(n, -10));


The (hopefully obvious) advantage to both these new inserter types is that they're more succinct. There are more to come ...

No comments:

Post a Comment