无法创建一个空元组的一元组(c 0x)
我正在尝试元组,并遇到一个创建元组的问题.
代码示例如下. //a.cpp #include <tuple> using namespace std; int main() { auto te = make_tuple(); //this line is ok auto tte = make_tuple(te); //this line gives an error. return 0; } 我用g 4.5(g -std = c 0x a.cpp)和MS VC 2010编译它. 我的问题是这样的: 我想这是一种边界的情况,但是如果算术是正确的,应该允许零. 来自gcc的错误消息是: $gcc -std=c++0x a.cpp In file included from a.cpp:1:0: c:mingwbin../lib/gcc/mingw32/4.5.2/include/c++/tuple: In constructor 'std::tuple<_Elements>::tuple(std::tuple<_UElements ...>&) [with _UElements = {},_Elements = {std::tuple<>}]': c:mingwbin../lib/gcc/mingw32/4.5.2/include/c++/tuple:551:62: instantiated from 'std::tuple<typename std::__decay_and_strip<_Elements>::__type ...> std::make_tuple(_Elements&& ...) [with _Elements = {std::tuple<>&},typename std::__decay_and_strip<_Elements>::__type = <type error>]' a.cpp:6:27: instantiated from here c:mingwbin../lib/gcc/mingw32/4.5.2/include/c++/tuple:259:70: error: invalid static_cast from type 'std::tuple<>' to type 'const std::_Tuple_impl<0u>&' 解决方法
这看起来像编译器已经匹配了你的std :: tuple<>反对std :: tuple< std :: tuple>的以下构造函数(见N3242中的20.4.2p15-17):
我认为这是编译器执行std :: tuple的一个bug; “注释”意味着这个构造函数不应该被考虑,因为它不会被编译. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |