|
Boost Users : |
Subject: [Boost-users] [fusion] Adapted struct I/O
From: Mateusz Åoskot (mateusz_at_[hidden])
Date: 2011-11-02 18:56:27
Hi,
I'm still taking early steps with Boost.Fusion.
I'm trying to adapt a bunch of struct and template struct for easy I/O
operations.
I don't understand one thing from the docs. Here we go;
1) Given the example [1] of template struct adoption:
namespace demo
{
template<typename Name, typename Age>
struct employee
{
Name name;
Age age;
};
}
// Any instantiated demo::employee is now a Fusion sequence
BOOST_FUSION_ADAPT_TPL_STRUCT(
(Name)(Age),
(demo::employee) (Name)(Age),
(Name, name)
(Age, age))
[1] http://www.boost.org/doc/libs/1_47_0/libs/fusion/doc/html/fusion/adapted/adapt_tpl_struct.html
2) The included comment says "demo::employee is now a Fusion sequence".
3) Jumping to I/O and out docs, reading that [2]
"The I/O operators: << and >> work generically on all Fusion sequences. "
[2] http://www.boost.org/doc/libs/1_47_0/libs/fusion/doc/html/fusion/sequence/operator/i_o.html
4) Means, I should be able to stream Fusion-adopted demo::employee
#include <iostream>
#include <string>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/sequence/io.hpp>
#include <boost/fusion/include/io.hpp>
// code from above example goes here
int main()
{
demo::employee<std::string, int> e;
std::cout << e << std::endl;
}
5) Given what I have learned above, I expect the cout << e to work:
$ g++ -I/home/mloskot/dev/boost/_svn/trunk boost_fusion.cpp
boost_fusion.cpp: In function âint main()â:
boost_fusion.cpp:28:18: error: no match for âoperator<<â in âstd::cout << eâ
...
I assume complete error is not necessary as my question is of general nature.
Is my expectation valid?
Best regards,
-- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org Member of ACCU, http://accu.org
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net