GCC and Clang allow this syntax, your compiler is failing at properly implementing C++11.
You can do this, though:
std::map<int, std::string> foo;
std::map<int, std::string>::value_type;
using some_type = decltype(foo);
some_type::value_type;
Вопрос
Consider these three statements:
std::map<int, std::string> foo;
std::map<int, std::string>::value_type;
decltype(foo)::value_type;
Why isn't the last one legal? I thought that decltype(foo)
would be an operator yielding the map type std::map<int, std::string>
from which I could extract the value_type
.
I'm using MSVC2012.
Решение
GCC and Clang allow this syntax, your compiler is failing at properly implementing C++11.
You can do this, though:
std::map<int, std::string> foo;
std::map<int, std::string>::value_type;
using some_type = decltype(foo);
some_type::value_type;
Другие советы
Its valid, you have other errors, you must give a name to your variable:
std::map<int, std::string> foo;
std::map<int, std::string>::value_type nn_var;
decltype(foo)::value_type nn2_var;
typedef decltype(foo)::value_type value_type;
use:
std::remove_reference<decltype(foo)>::type::value_type