|
Boost Users : |
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2007-03-28 17:33:46
I think the problem is in the typedef statement below:
typedef mpl::insert<Constraints,
mpl::end<Constraints>,
Base> BaseClasses;
mpl::insert is an own type but you need the new sequence type with is
accessed via:
mpl::insert<...>::type
Best Regards,
Ovanes
-----Original Message-----
From: Scott Meyers [mailto:usenet_at_[hidden]]
Sent: Donnerstag, 29. März 2007 00:28
To: boost-users_at_[hidden]
Subject: [Boost-users] [mpl] insert not inserting?
In my continuing effort to demonstrate my inability to get much of anything
working with the MPL, I'm having trouble inserting a type into an existing
set of types. The code compiles and runs, but the revised type sequence is
empty.
Here's the code:
#include <boost/mpl/set.hpp>
#include <boost/mpl/for_each.hpp>
#include <typeinfo>
#include <iostream>
namespace mpl = boost::mpl;
struct Base { virtual ~Base(){} };
struct A { virtual ~A(){} };
struct B { virtual ~B(){} };
struct Print {
template<typename T>
void operator()(const T&)
{
std::cout << typeid(T).name() << ", ";
}
};
int main()
{
typedef mpl::set<A, B> Constraints;
// print contents of Constraints (should be the equivalent
// of "[A, B,]")
std::cout << '[';
mpl::for_each<Constraints>(Print());
std::cout << "]\n";
// add Base to Constraints, call result BaseClasses
typedef mpl::insert<Constraints,
mpl::end<Constraints>,
Base> BaseClasses;
// print contents of BaseClasses (should be the equivalent
// of "[A, B, Base, ]")
std::cout << '[';
mpl::for_each<BaseClasses>(Print());
std::cout << "]\n";
}
Can anybody spot what I'm doing wrong? I know that I could use the
two-argument form of insert with a set, but I'm trying to write code that
will work with a vector, too, and at any rate, I get the same results with
the two-argument form of set.
Thanks,
Scott
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
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