boost-mpl

    1热度

    1回答

    我有一个简单元函数: template <typename T> using is_const_lvalue_reference = mpl::and_< std::is_lvalue_reference<T>, std::is_const<typename std::remove_reference<T>::type> >; 显然,如果T是一个占位符MPL因为remo

    1热度

    1回答

    是像下面 typedef boost::mpl::map< pair<int,"int"> , pair<long,"long"> , pair<bool,"bool"> > m; 可能吗?如果不是,有什么选择?

    0热度

    1回答

    考虑: template<typename T> struct MakeVectorOfType { typedef std::vector<T> type; }; typedef boost::mpl::vector<int, double> TScalarTypes; typedef boost::mpl::transform<TScalarTypes, MakeVect

    1热度

    1回答

    在我的一个项目中,我过度使用boost-variant。在某个点,我超过了boost-variant的模板参数(20)的最大数量。因此,我通过将几个boost-variant类型链接在一起(如链接列表)来推导出以下解决方案。 #include <boost/variant.hpp> #include <iostream> template<int T> struct A { con

    1热度

    1回答

    我试图从Abrahams和Gurtovoy的书“C++ Template Metaprogramming”中重新生成一个例子“3.1 Dimensional Analysis”。在某个时刻,他们比较了值(类型mpl::vector_c)的“维度”与变换值的“维度”相同(mpl::transform应用于两个mpl::vector_c)。 对我来说,比较始终是false,我无法理解我出错的地方。简化

    3热度

    1回答

    我想将mpl::vector中的每个元素乘以int。 首先,将int_与int相乘的元函数。 template <int i> struct multiply_scalar { template<typename T> struct apply { typedef int_<(T::value * i)> type; }; }; 这里是我想要打的

    2热度

    1回答

    我想学习boost mpl,试过一个非常简单的例子来计算一个类型出现在mpl map中的次数。可能有人解释为什么这个程序的输出为0 typedef map< pair<int, unsigned> , pair<char, unsigned char> , pair<long_<5>, char[17]> , pair<int[42], bo

    3热度

    1回答

    我在整个项目中都使用boost-variant。在一种情况下,我需要将包含在我的boost-variant中的类型分为几类。由于我的变体中有很多类型,我想到了在访问者中定义几个变体的想法。这些变体基本上是type-> class映射。 下面的代码说明了我想达到的目的。 #include <iostream> #include <boost/variant.hpp> #inclu

    1热度

    2回答

    我试图将一个模板化方法限制为允许的类型及其“重复”风格的给定列表。 typedef boost::mpl::set<bool, int, double> allowedTypes; class Foo { typedef boost::mpl::set<bool, int, double> allowedTypes; template<class T> void

    2热度

    1回答

    我很难理解为什么下面的简单程序不能编译。我有一个variadic模板类(下面的my_type),我想用它来转换一个mpl向量。下面的代码片段导致编译错误“/ boost/mpl /aux_/preprocessed/gcc/apply_wrap.hpp:38:19:'apply'在'template'关键字之后没有引用模板。 #include <boost/mpl/vector.hpp> #in