此代码使用VS(/ za)编译,但不使用GCC编译。谁是对的,谁是错的?或两者都错了/对吗?
#include <iostream>
#include <type_traits>
using namespace std;
struct NullType
{
//NullType(){}
template<class T>
NullType(T value){}
enum {value};
};
template<class T>
struct IntType
{
typedef T type;
};
template<int value_>
struct Low
{
typedef int type;
enum {value = value_};
};
template< class T>
struct Low_impl
{
protected:
T value_;
Low_impl():value_(T()){/*e.b.*/}
Low_impl(T value):value_(value){/*e.b.*/}
};
template<class T>
struct isNullType
{
enum {value = false};
};
template<>
struct isNullType<NullType>
{
enum {value = true};
};
template<class T>
struct TypeTraits
{
typedef T type;
};
/*template<>
struct TypeTraits<int>
{
typedef int type;
};*/
template<class Int_>
struct Int_Type_Tag
{
static_assert(std::is_integral<Int_>::type,"Non Integral Type Is ILLEGAL As a Parameter to this class ");
typedef Int_ type;
};
template<class T>
struct TypeTraits<Int_Type_Tag<T>>
{
typedef typename Int_Type_Tag<T>::type type;
};
template<class Int_Type,class L = NullType>
struct Int : private std::conditional<isNullType<L>::value,
NullType,
Low_impl<typename TypeTraits<Int_Type>::type>>::type
{
typedef typename std::conditional<isNullType<L>::value,
NullType,
Low_impl<typename TypeTraits<Int_Type>::type>>::type BaseType;
Int():BaseType(L::value){}
};
int main()
{
Int<int> a;
cout << sizeof(a);
return 0;
}
GCC 4.5.1的错误 错误:没有匹配函数来调用'NullType :: NullType(NullType ::&amp;)'|