-
0 votesanswersviews
C Boost :: MPL折叠示例 - 参数数量错误
我想通过使用boost :: mpl :: fold来处理一些模板参数 . 目前,我仍然坚持Boost提供的样本,即使这对我不起作用 . 我收到以下错误: ..\src\main.cpp:18:32: error: template argument 2 is invalid ..\src\main.cpp:18:37: error: wrong number of template argume... -
1 votesanswersviews
通过将模板参数与字符串连接来生成C类型名称
我试图找出一种方法来使用Boost :: MPL生成一个typename,它是模板参数和字符串的串联 . 我有一对名为 X 和 XProvider 的类 . 后者是一个工厂类,它实例化从前一类继承的对象 . 模板类用于在运行时管理类型的实例化:除其他外,它包含unordered_map和其他一些misc . 成员 . 我最终想要实现的是一个看起来像这样的元函数: 鉴于上课 template <... -
1 votesanswersviews
如何在Boost.MPL中使用嵌套元函数?
我有一个简单的元函数: template <typename T> using is_const_lvalue_reference = mpl::and_< std::is_lvalue_reference<T>, std::is_const<typename std::remove_reference<T>::type> &g... -
3 votesanswersviews
boost :: mpl :: bind的用法
当我尝试使用以下测试代码的mpl :: bind函数时,我无法在gcc中传递编译器,有人可以帮助我找出问题,非常感谢 . #include <iostream> #include <typeinfo> #include <string> #include <boost/mpl/apply.hpp> #include <boost/mpl/cha... -
0 votesanswersviews
在boost :: mpl :: tag <T> :: type上编译错误
我最近尝试过boost :: mpl,它看起来既棒又可怕 . 有时编译错误信息相当混乱 . 这次我在以下代码上遇到问题: #include <iostream> #include <boost/type_traits/is_same.hpp> #include <boost/mpl/integral_c_tag.hpp> #include <boost/m... -
3 votesanswersviews
模糊元函数或未定义类型
我是metafunctions的新手 . 我想编写一个函数,用一些其他类型替换复合类型中某种类型的所有匹配项 . 例如: replace<void *, void, int>::type 应为 int * , replace<void, void, int>::type 应为 int 等 . 到目前为止我基本上失败了两种不同的方法: template < ... -
2 votesanswersviews
Boost.MPL的复杂性
boost::mpl::push_back文件说明: push_back在序列结束时执行插入,保证O(1)复杂度 . 编译时间复杂吗? -
2 votesanswersviews
提升MPL递归元函数定义
我是MPL的初学者,所以我可能完全误解了如何使用它,但我已经尝试了所有我能想到的让这个工作 . 首先,我正在努力实现的目标 . 我有一堆形式的类: class X { typedef mpl::vector< D1,...,Dn > dependencies; ... } 其中n可以是0(无依赖性),Di也是相同形式的类 . 我的目标是定义一个元函数 template <... -
2 votesanswersviews
boost :: mpl :: for_each的类型包装器错误(Abrahams&Gurtovoy书中的第9.1.1节)
以下代码几乎逐字逐句地复制自David Abrahams和Aleksey Gurtovoy撰写的C Template Metaprogramming:概念,工具和技术来自Boost and Beyond的第9.1.1节 . 唯一的变化是我希望能够使用常规的Boost模板mpl :: identity从书中更改类型包装器模板 . 但是,在Microsoft Visual C Express 2010...