I have this class:
template <typename T>
class Hybrid
{
public:
Hybrid() : m_activeStackSize(0) {}
private:
std::list<T> data;
size_t m_activeStackSize;
auto internal_peek() -> decltype(data)::iterator
{
if (m_activeStackSize)
{
decltype(data)::iterator itr = data.end();
std::advance(itr, -1);
return itr;
}
else
{
decltype(data)::iterator itr = data.begin();
return itr;
}
}
};
When I try to compile this in Microsoft Visual Studio 2015, I get:
main.cpp (12): error C3646: 'iterator': unknown override specifier
I do not understand why it will not allow me to return the iteratortype std::list<T>while the body code is:
decltype(data)::iterator itr = data.end();
and
decltype(data)::iterator itr = data.begin();
Compile successfully.
How can I successfully return std::list iteratorusing decltypeexplicitly?
Uninstall -> decltype(data)::iteratorsuccessfully compiled.
Edit:
Compiling with GCC and adding typenamefor each decltype compiles fine , MSVC still doesn't work.
source
share