115 lines
3.1 KiB
C++
115 lines
3.1 KiB
C++
// !! tr1 hacks!!
|
|
#pragma once
|
|
|
|
template<class T>
|
|
struct type_identity
|
|
{
|
|
// Used to work around Visual C++ 2008's spurious error: "a function-style conversion to a built-in type can only take one argument"
|
|
typedef T type;
|
|
};
|
|
|
|
namespace __audetail
|
|
{
|
|
|
|
template<typename T, typename U>
|
|
struct is_more_const : AuBoolType<false>
|
|
{ };
|
|
|
|
template<typename T, typename U>
|
|
struct is_more_const<const T, U> : AuBoolType<true>
|
|
{ };
|
|
|
|
template<typename T, typename U>
|
|
struct is_more_const<const T, const U> : AuBoolType<false>
|
|
{ };
|
|
|
|
template<typename T, typename U>
|
|
struct is_more_volatile : AuBoolType<false>
|
|
{ };
|
|
|
|
template<typename T, typename U>
|
|
struct is_more_volatile<volatile T, U> : AuBoolType<true>
|
|
{ };
|
|
|
|
template<typename T, typename U>
|
|
struct is_more_volatile<volatile T, volatile U> : AuBoolType<false>
|
|
{ };
|
|
|
|
template<typename T, typename U>
|
|
struct is_more_cv : AuBoolType<is_more_const<T, U>::value &&is_more_volatile<T, U>::value>
|
|
{ };
|
|
|
|
|
|
template<typename T>
|
|
struct is_default_constructible
|
|
{
|
|
template<typename U>
|
|
static yes &test(int(*)[sizeof(new U)]);
|
|
template<typename U>
|
|
static no &test(...);
|
|
enum
|
|
{
|
|
value = sizeof(test<T>(0)) == sizeof(yes)
|
|
};
|
|
};
|
|
|
|
template<typename T, typename Arg>
|
|
struct is_constructible_1
|
|
{
|
|
template<typename U, typename Arg_>
|
|
static yes &test(int(*)[sizeof(typename type_identity<U>::type(static_cast<Arg_>(*((typename AuRemoveReference<Arg_>::type *)0))))]);
|
|
template<typename U, typename Arg_>
|
|
static no &test(...);
|
|
enum
|
|
{
|
|
value = sizeof(test<T, Arg>(0)) == sizeof(yes)
|
|
};
|
|
};
|
|
|
|
// Base pointer construct from Derived Pointer
|
|
template<typename T, typename U>
|
|
struct is_constructible_1<T *, U *>
|
|
: AuConditional<
|
|
AuIsVoid<typename AuRemoveCV<T>::type>::value,
|
|
AuBoolType<true>,
|
|
typename AuConditional<
|
|
AuIsVoid<typename AuRemoveCV<U>::type>::value,
|
|
AuBoolType<false>,
|
|
typename AuConditional<
|
|
is_more_cv<T, U>::value,
|
|
AuBoolType<false>,
|
|
AuIsBaseOf<T, U>
|
|
>::type
|
|
>::type
|
|
>::type
|
|
{ };
|
|
|
|
// Base pointer construct from Derived Pointer
|
|
template<typename T, typename U>
|
|
struct is_constructible_1<T &, U &>
|
|
: AuConditional<
|
|
is_more_cv<T, U>::value,
|
|
AuBoolType<false>,
|
|
AuIsBaseOf<T, U>
|
|
>::type
|
|
{ };
|
|
|
|
|
|
template<typename T, typename Arg1, typename Arg2>
|
|
struct is_constructible_2
|
|
{
|
|
template<typename U, typename Arg1_, typename Arg2_>
|
|
static yes &test(int(*)[
|
|
sizeof(typename type_identity<U>::type(
|
|
static_cast<Arg1_>(*((typename AuRemoveReference<Arg1_>::type *)0)),
|
|
static_cast<Arg2_>(*((typename AuRemoveReference<Arg2_>::type *)0))
|
|
))
|
|
]);
|
|
template<typename U, typename Arg1_, typename Arg2_>
|
|
static no &test(...);
|
|
enum
|
|
{
|
|
value = sizeof(test<T, Arg1, Arg2>(0)) == sizeof(yes)
|
|
};
|
|
};
|
|
} |