As usual while waiting for the next release - don't forget to check the nightly builds in the forum.
#include <iostream>#include <typeinfo>#include "Demangle.h"using namespace std;template<class... Types>struct X{};template<class A,class B,class... Types>struct X<A,B,Types...>{ typedef A type; typedef X<B,Types...> next; A head;};//template<class A,class... Types>//struct X<A,Types...>//{// typedef A type;// typedef X<Types...> next;// A head;////};template<class B>struct X<B>{ B head; typedef B type; typedef B next;};template<int index, class Sequence>struct get{ typedef typename get<index - 1,typename Sequence::next>::type type;};template<class Sequence>struct get<0,Sequence>{ typedef typename Sequence::type type;};int main(){ typedef X<int,double,char> x; //cout << demangle(x.get_head()); cout << demangle(typename get<3,x>::type()); return 0;}
d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp|40| recursively instantiated from 'get<2, X<double, char> >'|d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp:40|71|instantiated from 'get<3, X<int, double, char> >'|d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp:54|40|instantiated from here|d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp|46|error: 'char' is not a class, struct, or union type|||=== Build finished: 2 errors, 0 warnings (0 minutes, 0 seconds) ===|
Build started on: 26-10-2011 at 10:24.35 Build ended on: 26-10-2011 at 10:24.36-------------- Build: Debug in Meta_Sequence --------------- g++ -Wall -fexceptions -g -Wshadow -Winit-self -Wredundant-decls -Wcast-align -Wundef -Wfloat-equal -Winline -Wunreachable-code -Wmissing-declarations -Wmissing-include-dirs -Wswitch-enum -Wswitch-default -Weffc++ -Wmain -pedantic-errors -pedantic -std=c++0x -Wfatal-errors -Wextra -Wall -g -ID:\Libraries\boost_1_47_0\boost_1_47_0 -ID:\Libraries\Art_lib -Id:\Excersizes\metaprogramming_excersizes\Meta_Sequence -Id:\Excersizes\metaprogramming_excersizes\Meta_Sequence -c d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp -o obj\Debug\main.o d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp: In instantiation of 'get<0, char>':d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp:40:71: recursively instantiated from 'get<2, X >' d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp:40:71: instantiated from 'get<3, X >' d:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp:54:40: instantiated from hered:\Excersizes\metaprogramming_excersizes\Meta_Sequence\main.cpp:46:37: error: 'char' is not a class, struct, or union type compilation terminated due to -Wfatal-errors.Process terminated with status 1 (0 minutes, 0 seconds)2 errors, 0 warnings (0 minutes, 0 seconds)
Hi Neil, my problem is that in build log specializations of 'get' meta function are not listed with their correct types. I think that log should be as detailed as possible, and this isn't.
Quote from: smallB on October 26, 2011, 12:00:30 pmHi Neil, my problem is that in build log specializations of 'get' meta function are not listed with their correct types. I think that log should be as detailed as possible, and this isn't.The build log shows everything the compiler tells you. If that is not enough, complain to the GCC guys.