Alright so as this is really bugging me, despite having found a 'solution' (i.e. throw the impl in the header), I figured I'd give this a try.
In some occassions, I implement a begin and end method in order to be able to use for-each style for loops. Now on previous occassions, these happened to be template classes, in which I preferred to keep the method implementations in the header files, so I never ran into the following issue.
Using a trailing return type, the following spits out an error once attempting to compile:
Header:
auto end()->decltype(m_Messages.end());
Cpp:
auto Foo::end()->decltype(m_Messages.end())
{
return m_Messages.end();
}
With the following errors:
... 'left of '.end' must have class/struct/union'
'int Foo::end(void)' overloaded function differs only be return type from 'std::vector[....]' Foo::end'
'Foo::end: redefinition, different basic types'
Which, quite obviously, leads to me believe that m_Messages.end() is not being recognized. The same happens for begin.
It should be noted that simply throwing the implementation in the header file does allow it to compile.
I'm wondering what I'm missing here, especially since I also tried to just return m_Messages (as a test), which did compile. What puzzles me even more is that the body in the cpp file was generated by Visual Studio itself (i.e. the quick action menu in VS2015).
I'm no fan of 'help me understand this error' threads, but again, I'm pretty puzzled and I haven't been able to find information about this particular case. Feel free to point out my google skills as being atrocious though, a lmgfty won't hurt me.
It's also just possible that this simply isn't possible, but that seems odd to me, since using decltype on a regular member as trailing return type does work (be that an instance of a template class or not).