Say I have an object of some of stl container classes obj. I can define other object of same type this way:
decltype(obj) obj2;
<
It's because of the way that the language is parsed.
decltype(obj)::iterator it = obj.begin();
You want it to become
(decltype(obj)::iterator) it;
But in actual fact, it becomes
decltype(obj) (::iterator) it;
I have to admit, I was also surprised to see that this was the case, as I'm certain that I've done this before. However, in this case, you could just use auto, or even decltype(obj.begin()), but in addition, you can do
typedef decltype(obj) objtype;
objtype::iterator it;