There are times when classdesc simply cannot correctly parse syntactically correct C++, or won't be able to be adapted to do so. One of these situations occurs when a class definition refers to an object in the containing namespace, but the descriptor definition requires the fully qualified version of the name. An example is as follows:
namespace foo { struct bar { enum Foo {x, y, z}; }; template <bar::Foo t> class Foobar {}; }which is syntactically correct C++, but the generated descriptor looks like
template < bar :: Foo t > struct access_pack<class ::foo::Foobar<t> > { void operator()(classdesc::pack_t& targ, const classdesc::string& desc,class ::foo::Foobar<t>& arg) { using namespace foo; } };The problem is that
bar::Foo
is not visible in the
classdesc_access
namespace where the struct access_pack
type must be declared.
As a workaround, whenever this situation is encountered, use the fully qalified version of the type, ie as follows:
template <foo::bar::Foo t> class Foobar {};