相关疑难解决方法(0)

在编译期间构建类型列表 - 没有C++ 11

我想要做的确切获得类型/类的列表.但我不能使用C++ 11.有关如何将类型附加到模板列表的任何建议吗?

编辑:我想做的一些代码:

#include <iostream>
#include <typeinfo>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/for_each.hpp>

using namespace std;

class A {};
class B {};
class C {};

typedef boost::mpl::vector<> type1;
// supposed I'd like to have this as a #define macro so someone can call
// REGISTER_CLASS(A) and push the type into a list
typedef boost::mpl::push_back<type1, A> type2;
typedef boost::mpl::push_back<type2, B> type3;
typedef boost::mpl::push_back<type3, C> type4;

template <typename T> struct wrap {};

struct Print
{
      template <typename T> void operator()( …
Run Code Online (Sandbox Code Playgroud)

c++ metaprogramming template-meta-programming

2
推荐指数
1
解决办法
1638
查看次数