2
我的问题是由下面的例子示出:C++中模板内类decltype
#include <vector>
template <class T>
class TestNest{
public:
std::vector<T> m_list;
class InsideNest{
const TestNest<T>* m_test;
decltype(m_test->m_list.begin()) m_iter;
public:
InsideNest(const TestNest<T>* source)
:m_test(source)
,m_iter(source->m_list.begin())
{}
};
};
int main(int argc, char *argv[])
{
TestNest<int> outside;
TestNest<int>::InsideNest inside(&outside);
}
不编译(至少不是在MSVC2013)的部分是decltype(m_test->m_list.begin())
。任何想法如何解决这个问题?
编辑:改变代码显示main()和#包括
你得到了什么编译器错误? – NathanOliver
错误C2227:' - > m_list'的左边必须指向class/struct/union/generic类型 – IlBeldus
在VS2015中一切正常。请显示包含。 – alexeykuzmin0