Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 将模板化constexpr传递给推断自动对象类型的函数_C++_Templates_Lambda_Template Meta Programming_Boost Hana - Fatal编程技术网

C++ 将模板化constexpr传递给推断自动对象类型的函数

C++ 将模板化constexpr传递给推断自动对象类型的函数,c++,templates,lambda,template-meta-programming,boost-hana,C++,Templates,Lambda,Template Meta Programming,Boost Hana,我正在制作一个实体组件系统库,利用模板元编程在编译时评估签名位集数据,并允许精确的位集大小,而无需使用\define MAX\u COMPONENTS some number。 我使用的是Boost Hana,其功能如下所示: 模板 静态constexpr位集signatureBitset=位集( hana::fold(签名列表[hana::integral_c],0, [](自动左、自动右){ 返回l | 1简单的解决方案,如Jack C所说。在注释中,使用lambda中的decltype(r

我正在制作一个实体组件系统库,利用模板元编程在编译时评估签名位集数据,并允许精确的位集大小,而无需使用
\define MAX\u COMPONENTS some number
。 我使用的是Boost Hana,其功能如下所示:

模板
静态constexpr位集signatureBitset=位集(
hana::fold(签名列表[hana::integral_c],0,
[](自动左、自动右){

返回l | 1简单的解决方案,如Jack C所说。在注释中,使用lambda中的
decltype(r)
从对象获取类型,而不是通过模板函数推断类型


这意味着
propertyCheck
可以工作。

是否有某种原因
decltype(r)
在lambda中不起作用?@JackC.Type被包装在hana::basic_Type中,因此decltype(r)是hana::basic_Type。在对它进行一点解释之后,
typename decltype(r)::Type
是实际的解决方案。