c++ - Why does scope resolution fail in presence of decltype? -
it understanding decltype used query type of objects/variables , on.
from examples present on wikipedia, such following:
int i; decltype(i) x3; // type int
i assumed this:
class { public: int a, b; }; template<typename t> struct isclass { enum { yes = std::is_class<t>::value }; enum { no = !yes }; }; std::vector<a> v; auto = v.begin(); isclass<decltype(it)::value_type>::yes
because after line legal:
isclass<std::vector<a>::iterator::value_type>::yes
alas wouldn't compile, citing following: error c2039: 'value_type' : not member of '
global namespace''`
any ideas why scope resolution made behave way in presence of decltype?
p.s: if makes difference i'm using msvc2012 (without nov ctp)
this known bug in visual c++ compiler. has not yet been fixed of visual c++ 2013 preview. can work around issue using std::common_type
:
isclass<std::common_type<decltype(it)>::type::value_type>::yes ^^^^^^^^^^^^^^^^^ ^^^^^^^
(std::common_type
single template argument yields argument type; it's standardized c++11 equivalent of identity
template has long been used in metaprogramming.)
you can find public bug report on microsoft connect: cannot use decltype before scope operator. if issue important you, please consider upvoting bug report.
Comments
Post a Comment