David Greene wrote:
Well, my mpl adventure continues.
I'm trying to place pair members of a sequence with their keys:
#include
#include #include #include #include #include #include #include <iostream> #include <typeinfo>
using namespace boost; using namespace boost::mpl;
struct pair_base {};
template
struct pair_type : public pair , private pair_base {}; template<typename Sequence> struct replaceit { typedef typename replace_if< Sequence, is_base_and_derived
, key_type int main(void) { replaceit< vector< charm
You should be seeing a syntax error right here.
pair_type
>, pair_type > double > ::type toprint;
std::cout << typeid(toprint).name() << std::endl;
return(0); };
I know this is incorrect because the pairs will be replaced by the key_type metafunction itself.
If I add ::type to the end of key_type
What's the right way to do this?
Use an algorithm like transform that _computes_ the new values rather
than simply replacing them with a constant value:
template <class Seq>
struct replaceit
: transform<
Seq
, if_<
is_base_and_derived
Furthermore, is there a better way to identify pairs in replace_if than deriving from a special class? All I can think of is writing a predicate class and specializing it for mpl::pair. Seems like there should be an easier way.
Why? That seems like a pretty darned good approach to me. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com