草庐IT

ThingType

全部标签

c++ - 如何从模板化类方法返回依赖类型?

假设我有一个基于模板ThingType的类。在header中,我使用它来typedef依赖类型VectorThingType。我想从GetVectorOfThings()方法中返回它。如果我将VectorThingType设置为返回类型,我会得到一个Doesnotnameatype错误,因为该类型未在此范围内定义。有什么方法可以在不复制typedef中的代码的情况下做到这一点?#include#includetemplateclassThing{public:ThingTypeaThing;typedefstd::vectorVectorThingType;VectorThingTyp