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++ boost multi_索引获取依赖类型_C++_Templates_Boost - Fatal编程技术网

C++ boost multi_索引获取依赖类型

C++ boost multi_索引获取依赖类型,c++,templates,boost,C++,Templates,Boost,我遇到了一个问题,对于依赖类型,boost::multi_index::multi_index_container::get()在C是依赖类型时会中断。如果不依赖,则不会发生相同的情况。MCVE,g++7.1.0(如果您声明是相同的,也可以是6.3.0): #包括 #包括 #包括 #包括 #包括 #包括 #包括 #定义成员(T,M)boost::multi_index::MEMBER #定义标记成员(T,M)boost::multi_index::标记成员(T,M) 名称空间ns1{ 结构元素{

我遇到了一个问题,对于依赖类型,
boost::multi_index::multi_index_container::get()
C
是依赖类型时会中断。如果不依赖,则不会发生相同的情况。MCVE,g++7.1.0(如果您声明是相同的,也可以是6.3.0):

#包括
#包括
#包括
#包括
#包括
#包括
#包括
#定义成员(T,M)boost::multi_index::MEMBER
#定义标记成员(T,M)boost::multi_index::标记成员(T,M)
名称空间ns1{
结构元素{
大小\u t id\u;
布尔运算符
>;                                                                                                             
}                                                                                                                  
名称空间ns2{
//void f(ns1::Cont&Cont)//始终有效
模板
空f(C&cont)
{                                                                                                              
ns1::Cont&c=Cont;
静态断言(std::is_same_v);
cont.get();//v1-依赖类型时出错
//c、 get();//v2-始终有效
}                                                                                                              
}                                                                                                                  
int main()
{                                                                                                                  
ns1::Cont Cont;
cont.insert({0});
ns2::f(续);
}

请告知?

指出
get
是一个模板:

cont.template get<MEMBER(ns1::Elem, id_)>(); // now works
cont.template get();//现在可以工作了

它与
c
一起工作,因为您明确声明了它的类型(
ns1::Cont
),因此,get不再依赖于它。

表示
get
是一个模板:

cont.template get<MEMBER(ns1::Elem, id_)>(); // now works
cont.template get();//现在可以工作了
它与
c
一起工作,因为您显式声明了它的类型(
ns1::Cont
),因此get不再依赖