Suppose I have a template function (e.g. foo ) that returns a dependent type of const . Parameters for getting the return type as const - either put const to the left of the typename keyword:
template<typename T> const typename T::bar ^^^^^ foo(T const& baz) { ... }
or to the right of the dependent type:
template<typename T> typename T::bar const ^^^^^ foo(T const& baz) { ... }
But what if I put a const qualifier between the typename keyword and the dependent type?
template<typename T> typename const T::bar ^^^^^ foo(T const& baz) { ... }
The above, as expected, does not compile for GCC and CLANG, but, to my surprise, VC ++ compiles it in order.
Q
- Is it a VC ++ extension?
- Does the C ++ standard mean anything about where is the right place to place
const in this context?
c ++ language-lawyer c ++ 11 templates dependent-name
101010
source share