Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

fastformat::iterators Namespace Reference

Detailed Description

Namespace within which FastFormat iterators are defined.


class  format_output_iterator
 This class template defines an output iterator that writes to a given sink using fastformat::fmt(). More...


template<typename S, typename F, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
format_output_iterator< S, F,
A1, A2, A3, A4, A5, A6, A7, A8 > 
format_iterator (S &sink, F const &format,...)
 Creator function for the fastformat::iterators::format_output_iterator output iterator class template.

Function Documentation

format_output_iterator<S, F, A1, A2, A3, A4, A5, A6, A7, A8> fastformat::iterators::format_iterator ( S &  sink,
F const &  format,
) [inline]

Creator function for the fastformat::iterators::format_output_iterator output iterator class template.

Used as follows

  std::vector<std::string>  strings;


  std::cout << "with std::ostream_iterator:\n";
  std::copy(strings.begin(), strings.end()
          , std::ostream_iterator<string_t>(std::cout, "\n"));
  std::cout << "\n";

  std::cout << "with fastformat::format_iterator:\n";
  std::copy(strings.begin(), strings.end()
          , fastformat::format_iterator(std::cout, "\t{0}\n"));
  std::cout << "\n";

  FILE* stm = stdout;
  std::cout << "with fastformat::format_iterator (with stdout):\n";
  std::copy(strings.begin(), strings.end()
          , fastformat::format_iterator(stm, "\t{0}\n"));
  std::cout << "\n";

Unlike std::ostream_iterator, there is no requirement to specify the value type, as that will be inferred by the FastFormat application layer in the usual manner.
sink The sink to which to write, e.g. std::cout
format An instance of any string type, to be used as the format for the underlying fastformat::fmt() call, e.g. "\t{0}\n". It must contain at least one instance of the replacement parameter {0}, and no instances of any replacement parameters with higher indexes (except those specified by additional parameters).
... up to 8 additional parameters, to be matched by format replacement parameters {1} to {8}

FastFormat Library documentation Matthew Wilson, 2006-2009 Logo