|
Boost Users : |
Subject: [Boost-users] [MPL] - for_each operators with decision branching
From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2010-05-19 13:23:50
I have a project in which I use these things I call "records" to attach
data to edges and vertexes in a boost::graph. They are visitable
(acyclic visitor described by Alexandrescu) and I have metafunctions
that will take their most derived type and give me a list of "fields"
that they contain. I can then write generic processors to do things
like build editors for them or perform operations that can effect any
field of a particular type or concept. Thus I often find myself using
mpl::for_each and writing things like this:
struct operator
{
template < typename MetaField >
void operator()(MetaField const&, boost::enable_if< some_test >::type
* = 0);
template < typename MetaField >
void operator()(MetaField const&, boost::disable_if<some_test>::type *
= 0);
};
I imagine that this is common enough that there may already be a utility
to write things like this but I don't see one in the docs. Is it out
there? What about something that would make this type of thing easy:
struct operator
{
template < typename MetaField >
void operator()(MetaField const&, boost::enable_if< test_a >::type * =
0); template < typename MetaField >
void operator()(MetaField const&, boost::enable_if< and_< not_
<test_a>, test_b>>::type * = 0)
void operator()(MetaField const&, boost::enable_if<not_<or_<test_a,
test_b>>>::type * = 0);
};
That's supposed to be an if, elseif, else construct.
-- http://crazyeddiecpp.blogspot.com/
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