The I/O operators:
>> work generically
on all Fusion sequences. The global
operator<< has been overloaded for generic
output streams such that Sequence(s)
are output by recursively calling
operator<< for each element. Analogously,
has been overloaded to extract Sequence(s)
from generic input streams by recursively calling
operator>> for each element.
The default delimiter between the elements is space, and the Sequence is enclosed in parenthesis. For Example:
vector<float, int, std::string> a(1.0f, 2, std::string("Howdy folks!"); cout << a;
as: (1.0 2 Howdy folks!)
The library defines three manipulators for changing the default behavior:
Defines the character that is output before the first element.
Defines the character that is output after the last element.
Defines the delimiter character between elements.
The argument to
tuple_delimiter may be a
a C-string, or a wide C-string.
std::cout << tuple_open('[') << tuple_close(']') << tuple_delimiter(", ") << a;
outputs the same
as: [1.0, 2, Howdy folks!]
The same manipulators work with
as well. Suppose the
stream contains the following data:
(1 2 3) [4:5]
vector<int, int, int> i;
vector<int, int> j; std::cin >> i; std::cin >> set_open('[') >> set_close(']') >> set_delimiter(':'); std::cin >> j;
reads the data into the
#include <boost/fusion/sequence/io.hpp> #include <boost/fusion/include/io.hpp>