boost-hana相关内容
Boost Hana是否提供将谓词与逻辑运算符组合的方法? 我指的是这样的东西 constexpr auto both = [](auto& f,auto& g){return [& f,& g](auto&& x){return f(x)&&g(x);};}; 可以这样使用: int main(){std :: vectorv {1,2,3,4,5,6,7,8,9,
..
前言 我问了类似的问题:说我有一个谓词 auto p1 = [](int x){return x>2;} 和谓词 auto p2 = [](int x){return x
..
我的目标是定义一个 Recursive 类,该类以 int N 和一种或多种类型的 T,... Ts ,它的行为应类似于 std :: pair 与 类型为 T 的 N 个项目的 std :: array 作为 first 的 ,以及作为 second 的 可选 std :: vector 递归在相同的 N 上以及其余模板参数 Ts ... 上模板化的实例. 在尝试根据上述要求写下该
..
我希望以下代码能够编译和工作: #include#include#includeint main(){std :: vectorx = {1,1,3,4};自动分组= boost :: hana :: group(x,std :: equal_to {});} 尝试编译如下错误:
..
我找不到通过元组迭代的 hana :: for_each 访问真实对象的方法. 结构A {std :: string名称;}结构B {std :: string名称;}使用type_t = decltype(boost :: hana :: tuple_t);type_t名称;boost :: hana :: for_each(names,[&](const auto& a){std
..
我想确定类型是否定义了带有模板参数的成员函数,但模板参数受SFINAE约束. 示例我有一个类型为A的单个函数foo struct A{ template std::enable_if,ReturnType> foo(T t){ ... } }; Condition是某种情况,例如std::is_pos_v 现在我正
..
考虑以下问题,该问题使用 -std = c ++ 14 在Clang 3.8上成功编译。 #include 命名空间hana = boost :: hana; int main(){ constexpr auto index = hana :: range(); hana :: for_each(ind
..
使用C ++ 14以及好奇重复模板模式(CRTP)和 Boost.Hana (或者如果您愿意的话, boost :: mpl ),我可以建立类型列表吗?在编译时(或静态初始化时)没有显式声明? 例如,我有类似的内容(请参见 Coliru ): #include #include #include
..
我有一个可以容纳不同类型的属性向量: class base_attribute_vector; //没有模板参数 template class raw_attribute_vector:public base_attribute_vector; raw_attribute_vector foo; raw_attribute_vec
..
是否存在一种Boost Hana方法,用于在编译时将 Struct 概念的成员类型转换为类型名称为std :: string的STL容器? 例如, MyType t(); std::array ls = boost::hana::typesToString(t); for(std::string x : ls){ std::cout
..
我有以下代码: auto myMap = hana::make_map( hana::make_pair(hana::type_c, 2), hana::make_pair(hana::type_c, "hi"), hana::make_pair(hana::type_c, 3.0) ); 是否可以预先知道"my
..
我正在使用带有Boost.hana的c ++ 17来编写一些元编程程序.让我困扰的一个问题是,在像static_assert这样的constexpr上下文中可以使用哪种表达式.这是一个示例: #include using namespace boost::hana::literals; template class X { pu
..
我有一个模板函数,默认情况下没有定义,但是它由某些类型专用: template auto foo(bar &, const T &) -> void; template auto foo(bar &, const std::string &) -> void {} 我该如何编写constexpr函数来告诉我T类型是否具有上述函数
..
所以我正在尝试使用boost::hana创建一个库,该库需要具有基于值来获取元素索引的功能: constexpr auto tup = boost::hana::make_tuple(3_c, boost::hana::type_c); auto index = get_index_of_first_matching(tup, boost::hana::type_c
..
我有此代码: auto myTuple = hana::tuple_t; std::cout ().pretty_name() ::_ 我想访
..
我正在尝试出于学习目的在C ++中实现通用ECS库.我在想很多方法来实现事情,但是我总是遇到问题.因此,如果您可以帮助我解决这个问题: 假设我有constexpr hana::tuple个hana::type_c组件,例如: struct C1 {}; struct C2 {}; struct C3 {}; constexpr auto components = hana::to_t
..
我正在尝试根据发送给函数的类型创建一个位集.但是让我们稍微减少一下测试用例. 警告:在此示例中,我使用的是自动gcc扩展程序,不需要使用模板参数. namespace hana = boost::hana; constexpr decltype(auto) rec(auto i, auto max, auto f, auto returnValue) { return retu
..
我正在尝试使用嵌套的constexpr lambdas创建一个咖喱接口,但是编译器并不认为它是一个常量表达式. namespace hana = boost::hana; using namespace hana::literals; struct C1 {}; template struct Arr
..
我正在尝试使用hana::second ... 从一对访问hana::type namespace hana = boost::hana; using namespace hana::literals; struct Key {}; struct Foo {}; int main() { auto test = hana::make_tuple( hana::make_p
..
我有一个Boos.Hana序列,我想打印它到屏幕,用逗号分隔。但是逗号只分开元素,所以我必须检查我是否在最后一个元素。 目前我的黑客是非常糟糕的(看着指针,并转换到 void * 。 template decltype(auto)operator
..