namespace std {
typedef decltype(sizeof(int)) size_t;
template <class _E>
class initializer_list
{
const _E* __begin_;
size_t __size_;
initializer_list(const _E* __b, size_t __s)
: __begin_(__b),
__size_(__s)
{}
public:
typedef _E value_type;
typedef const _E& reference;
typedef const _E& const_reference;
typedef size_t size_type;
typedef const _E* iterator;
typedef const _E* const_iterator;
initializer_list() : __begin_(nullptr), __size_(0) {}
size_t size() const {return __size_;}
const _E* begin() const {return __begin_;}
const _E* end() const {return __begin_ + __size_;}
};
}
template < bool condition, typename T = void >
struct enable_if { typedef T type; };
template< typename T >
struct enable_if< false, T > {};
namespace Casts {
template< unsigned O >
void implicit(typename enable_if< O <= 4 >::type* = 0) {
}
template< unsigned O >
void cstyle(typename enable_if< O <= (unsigned)4 >::type* = 0) {
}
template< unsigned O >
void functional(typename enable_if< O <= unsigned(4) >::type* = 0) {
}
template< unsigned O >
void static_(typename enable_if< O <= static_cast<unsigned>(4) >::type* = 0) {
}
template< typename T >
void auto_(decltype(new auto(T()))) {
}
template< typename T >
void scalar_(decltype(T(), int())) {
}
template <unsigned N> struct T {};
template <int N> T<N> f() { return T<N>(); }
template void implicit<4>(void*);
template void cstyle<4>(void*);
template void functional<4>(void*);
template void static_<4>(void*);
template T<6> f<6>();
template void auto_<int>(int*);
template void scalar_<int>(int);
}
namespace test1 {
short foo(short);
int foo(int);
template <class T> auto a(T t) -> decltype(foo(T())) { return foo(t); }
template <class T> auto b(T t) -> decltype((foo)(T())) { return (foo)(t); }
void test(short s) {
a(s);
b(s);
}
}
namespace test2 {
template <class T> void a(T x, decltype(x()) y) {}
template <class T> auto b(T x) -> decltype(x()) { return x(); }
template <class T> void c(T x, void (*p)(decltype(x()))) {}
template <class T> void d(T x, auto (*p)() -> decltype(x())) {}
template <class T> void e(auto (*p)(T y) -> decltype(y())) {}
template <class T> void f(void (*p)(T x, decltype(x()) y)) {}
template <class T> void g(T x, decltype(x()) y) {
static decltype(x()) variable;
variable = 0;
}
template <class T> void h(T x, decltype((decltype(x())(*)()) 0) y) {}
template <class T> void i(decltype((auto (*)(T x) -> decltype(x())) 0) y) {}
float foo();
void bar(float);
float baz(float(*)());
void fred(float(*)(), float);
void instantiate() {
a(foo, 0.0f);
(void) b(foo);
c(foo, bar);
d(foo, foo);
e(baz);
f(fred);
g(foo, 0.0f);
h(foo, foo);
i<float(*)()>(baz);
}
}
namespace test3 {
template <class T, class U> void a(T x, U y, decltype(x.*y) z) {}
struct X {
int *member;
};
void instantiate() {
X x;
int *ip;
a(x, &X::member, ip);
}
}
namespace test4 {
struct X {
X(int);
};
template <typename T>
void tf1(decltype(new T(1)) p)
{}
template <typename T>
void tf2(decltype(new T({1})) p)
{}
template <typename T>
void tf3(decltype(new T{1}) p)
{}
template void tf1<X>(X*);
template void tf2<X>(X*);
template void tf3<X>(X*);
}
namespace test5 {
template <typename T> void a(decltype(noexcept(T()))) {}
template void a<int>(decltype(noexcept(int())));
}