|
Boost Users : |
From: Joel de Guzman (joel_at_[hidden])
Date: 2007-07-26 03:14:35
Graham Reitz wrote:
> Yes, thanks Joel.
>
> I should have used more elements in my example and not called it some_pair.
Oh and BTW, in case you don't know yet, in Fusion, structs and tuples
are interchangeable. IOTW, structs *are* tuples. Sample:
namespace ns
{
struct point
{
int x;
int y;
};
}
BOOST_FUSION_ADAPT_STRUCT(
ns::point,
(int, x)
(int, y)
)
/*...*/
ns::point p = {123, 456};
std::cout << at_c<0>(p) << std::endl;
std::cout << at_c<1>(p) << std::endl;
(those at_c<N> thingies are Fusion's get<N> counterparts. Ala MPL!)
It's the same interface as say, for vector<int, int>:
fusion::vector<int, int> v(123, 456);
std::cout << at_c<0>(v) << std::endl;
std::cout << at_c<1>(v) << std::endl;
Or even a boost::array:
boost::array<int, 2> a(123, 456);
std::cout << at_c<0>(a) << std::endl;
std::cout << at_c<1>(a) << std::endl;
Or, of course, a std::pair:
std::pair<int, int> pr(123, 456);
std::cout << at_c<0>(pr) << std::endl;
std::cout << at_c<1>(pr) << std::endl;
Regards,
-- Joel de Guzman http://www.boost-consulting.com http://spirit.sf.net
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