KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was experimenting with tuples and encountered a problem with creating tuples. The code example is as follows. //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; } I compiled it with both g++ 4.5 (g++ -std=c++0x a.cpp) and MS VC++2010. Both compilers are giving me an error on the second line in main(). My question is this: Since 'te' is a well-defined variable, why can't another tuple be created with te being the content. Is this semantic correct? I guess this is kind of a boundary case, but if the arithmetic is correct, zero should be allowed, IMHO. FYI, the error message from gcc is: $ gcc -std=c++0x a.cpp In file included from a.cpp:1:0: c:\mingw\bin\../lib/gcc/mingw32/4.5.2/include/c++/tuple: In constructor 'std::tuple<_Elements>::tuple(std::tuple<_UElements ...>&) [with _UElements = {}, _Elements = {std::tuple<>}]': c:\mingw\bin\../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:\mingw\bin\../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>&'
Tags (comma-separated)
Save Edits
Cancel