有关使用MPL :: range_c与mpl :: fold使用的问题
我有以下简单功能来转换MPL :: vector< ...>打包< ...> namespace mpl = boost::mpl; template struct pack{}; struct A{}; struct B…
使用强类型枚举的值作为 boost::mpl::map 中的索引
我使用类似于 std::map 定义的 C++ 映射结构来存储编译器符号表的属性。 Foo 是一个强类型枚举,例如enum class Foo {ENUM}。将一些其他类型转换为 st…
应如何将二元谓词传递给用户定义的 Boost.MPL 算法?
考虑以下对 std::any_of 的 Boost.MPL 风格元编程版本的尝试, #include // cout #include // is_base_of, is_pod #include // apply #include // fol…
使用 mpl::if_ 和整数模板参数选择类型
以下代码适用于 Visual Studio 2005,但在使用 g++ 4.4.5 编译时出现编译器错误: #include #include template struct A { void f() { typedef boost:…
收集稍后应在宏中调用的函数列表
我正在编写一个小型库,使用它 C++ 中的枚举应该会变得更容易。语法类似于: ENUM_START(MyEnum) ENUM_VAL(Val1) ENUM_VAL(Val2) ... ENUM_END 该宏创…
使用 boost::mpl,我如何获得有多少模板类不是“空”,并用这个数字调用一些宏?
我想根据 boost::mpl::eval_if (或类似函数)的结果来调用带有一些参数的宏,这些参数可以给出有多少个模板参数不为空。假设我们有一些如下所示的伪…
Boost::MPL Vector 和 For_Each:如何将 avector 打印为元组?
想象一下,我们有一个 mpl::vector,我们希望将其打印(例如,cout)为字符串:int, string, char。如何使用 boost::mpl 来做这样的事情?…
每个函数和自由函数的 Boost mpl
为什么这段代码无法编译: #include #include #include using namespace std; using namespace boost; template // specific visitor for type printi…
Boost.Variant、Boost.MPL:如何追加类型?
我看着这个基于 boost.Any 的代码,不禁想知道我们是否可以使用Boost.Variant 代替。我想知道这样的 API 是否可行: void voidFunc() { std::cout << …
使用 mpl::if_、boost::function 和 typedef 为 void 时出现问题
我是 Boost.MPL 库的新手,并且有一些“初学者问题” 看看这个示例: template struct A { typedef boost::function_types::parameter_types P; typed…
从 MPL 元函数类创建函子
我一直在 MPL 中寻找一个类,它将从行为良好的 MPL 元函数类创建函数对象。我手工完成了这个实现: template struct functor { typedef Result result…
获取 mpl 向量的前 M 个元素
我有一个带有 N 个元素的 boost::mpl::vector ,比如说: typedef boost::mpl::vector my_vector; 我希望获得一个包含 M 元素的序列代码>我的向量。因…
使用 boost mpl pop_front
有: #include #include #include int main() { typedef boost::mpl::vector v; typedef typename pop_front::type poped; } 问题是 poped 不等于 boo…