Subject: [Boost-bugs] [Boost C++ Libraries] #6091: Not documented requirement about I/O operators
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-11-03 21:26:18
#6091: Not documented requirement about I/O operators
------------------------------+---------------------------------------------
Reporter: mloskot | Owner:
Type: Bugs | Status: new
Milestone: To Be Determined | Component: None
Version: Boost 1.47.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
The Fusion documentation in Boost 1.47 does not mention that in order to
make Fusion-adapted types usable with input and output operators, it is
necessary to import these operators into type's namespace.
The problem is discussed in the thread [http://lists.boost.org/boost-
users/2011/11/71518.php Adapted struct I/O].
Here is sample based on the
[http://www.boost.org/doc/libs/1_47_0/libs/fusion/doc/html/fusion/adapted/adapt_tpl_struct.html
demo::employee] example that shows correct use of Fusion-adapted type:
{{{
#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>
namespace demo
{
// This does the trick, but not documented
using boost::fusion::operators::operator<<;
using boost::fusion::operators::operator>>;
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))
int main()
{
demo::employee<std::string, int> e;
std::cin >> e;
std::cout << e << std::endl;
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6091> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC