#include #include #include #include typedef std::complex ComplexD; template class TypeMapper { public: enum { NestLevel = T::NestLevel }; }; template<> class TypeMapper { public: enum { NestLevel = 0 }; }; template class Container { public: std::vector data; Container(int size) : data (size){}; }; template class Recursive { public: enum { NestLevel = TypeMapper::NestLevel + 1}; obj internal; }; template::type * = nullptr > auto function(const obj &arg)-> obj { std::cout<::type * = nullptr > auto function(const obj &arg)-> obj { std::cout<(arg.internal); return ret; } template auto function(const Container & arg)-> Container(arg.data[0]))> { Container(arg.data[0]))> ret(arg.data.size()); for(int ss=0;ss(arg.data[ss]); } return ret; } int main(int argc,char **argv) { Container > > array(10); Container > > ret(10); ret = function<1>(array); ret = function<2>(array); }