c++ - Get type of outer class in template -
struct outer { struct inner { }; }; template <typename t> void test() { ??outer?? foo; // how type of t's outer class ? } test<outer::inner>(); inside test() have template argument of type t , want declare variable of whatever type outer class of t.
i think should trivial compiler info, far couldn't find how it.
it can't done. there indeed information available compiler cannot used in metaprogramming context. ongoing work on adding compile-time reflection language might improve situation, don't hold breath.
in meantime, you'll have old-fashioned way.
struct outer { struct inner { typedef outer outer_class; }; }
Comments
Post a Comment