I believe using
keyword was added in order to allow template typdefs. However I came across to one compilation error, here is simplified code:
template <bool EnableFirst, class T1, class T2>
struct OneOfTwo {};
template <class T1, class T2>
struct OneOfTwo<true, T1, T2>
{
using type = T1;
};
template <class T1, class T2>
struct OneOfTwo<false, T1, T2>
{
using type = T2;
};
struct A
{
static constexpr int X = 1;
};
struct B
{
static constexpr int X = 12;
};
struct C {};
struct D {};
template <class T1, class T2>
using ClassX = OneOfTwo<T1::X == T2::X, C, D>::type; //C4346: 'T2::X': dependent name is not a type; C2061: syntax error: identifier 'type'
template <class T1, class T2>
struct ClassY : public OneOfTwo<T1::X == T2::X, C, D>::type {}; //OK
And I use these classes like this:
ClassY<A, B> y;
ClassX<A, B> x;
I believe ClassX
and ClassY
should be exactly same thing, however ClassX
causes compilation error. So my question is: which part of C++ standard did I break?
BTW, I'm using MSVC 2015 toolset with XP support (v140_xp).