decltype and the scope operator in C++
问题 I need to obtain the type which was supplied when instantiating a template. Consider the following example: template <typename T> struct Foo { typedef T TUnderlying; }; static Foo<int> FooInt; class Bar { public: auto Automatic() -> decltype(FooInt)::TUnderlying { return decltype(FooInt)::TUnderlying(); } }; int main() { Bar bar; auto v = bar.Automatic(); return 0; } Problem with this code is using the scope operator together with decltype. Visual C++ 2010 complains like this: error C2039: