namespace dr1512 { void f(char *p) {
if (p > 0) {} #if __cplusplus >= 201103L
if (p > nullptr) {} #endif
}
bool g(int **x, const int **y) {
return x < y;
}
template<typename T> T val();
template<typename A, typename B, typename C> void composite_pointer_type_is_base() {
typedef __typeof(true ? val<A>() : val<B>()) type;
typedef C type;
typedef __typeof(val<A>() == val<B>()) cmp;
typedef __typeof(val<A>() != val<B>()) cmp;
typedef bool cmp;
}
template<typename A, typename B, typename C> void composite_pointer_type_is_ord() {
composite_pointer_type_is_base<A, B, C>();
typedef __typeof(val<A>() < val<B>()) cmp; typedef __typeof(val<A>() <= val<B>()) cmp; typedef __typeof(val<A>() > val<B>()) cmp; typedef __typeof(val<A>() >= val<B>()) cmp; typedef bool cmp;
}
template <typename A, typename B, typename C>
void composite_pointer_type_is_unord(int = 0) {
composite_pointer_type_is_base<A, B, C>();
}
template <typename A, typename B, typename C>
void composite_pointer_type_is_unord(__typeof(val<A>() < val<B>()) * = 0);
template <typename A, typename B, typename C>
void composite_pointer_type_is_unord(__typeof(val<A>() <= val<B>()) * = 0);
template <typename A, typename B, typename C>
void composite_pointer_type_is_unord(__typeof(val<A>() > val<B>()) * = 0);
template <typename A, typename B, typename C>
void composite_pointer_type_is_unord(__typeof(val<A>() >= val<B>()) * = 0);
template<typename A, typename B>
void no_composite_pointer_type(__typeof((true ? val<A>() : val<B>()), void()) * = 0);
template<typename A, typename B> void no_composite_pointer_type(int = 0);
struct A {};
struct B : A {};
struct C {};
void test() {
#if __cplusplus >= 201103L
using nullptr_t = decltype(nullptr);
composite_pointer_type_is_unord<nullptr_t, nullptr_t, nullptr_t>();
no_composite_pointer_type<nullptr_t, int>();
composite_pointer_type_is_unord<nullptr_t, const char**, const char**>();
composite_pointer_type_is_unord<const char**, nullptr_t, const char**>();
#endif
composite_pointer_type_is_ord<const int *, volatile void *, const volatile void*>();
composite_pointer_type_is_ord<const void *, volatile int *, const volatile void*>();
composite_pointer_type_is_ord<const A*, volatile B*, const volatile A*>();
composite_pointer_type_is_ord<const B*, volatile A*, const volatile A*>();
composite_pointer_type_is_unord<const int *A::*, volatile int *B::*, const volatile int *const B::*>();
composite_pointer_type_is_unord<const int *B::*, volatile int *A::*, const volatile int *const B::*>();
no_composite_pointer_type<int (A::*)(), int (C::*)()>();
no_composite_pointer_type<const int (A::*)(), volatile int (C::*)()>();
#if __cplusplus > 201402
composite_pointer_type_is_ord<int (*)() noexcept, int (*)(), int (*)()>(); composite_pointer_type_is_ord<int (*)(), int (*)() noexcept, int (*)()>(); composite_pointer_type_is_unord<int (A::*)() noexcept, int (A::*)(), int (A::*)()>();
composite_pointer_type_is_unord<int (A::*)(), int (A::*)() noexcept, int (A::*)()>();
composite_pointer_type_is_unord<int (B::*)(), int (A::*)() noexcept, int (B::*)()>();
composite_pointer_type_is_unord<int (A::*)() noexcept, int (B::*)(), int (B::*)()>();
composite_pointer_type_is_unord<int (B::*)() noexcept, int (A::*)(), int (B::*)()>();
composite_pointer_type_is_unord<int (A::*)(), int (B::*)() noexcept, int (B::*)()>();
no_composite_pointer_type<int (**)() noexcept, int (**)()>();
no_composite_pointer_type<int (**)(), int (**)() noexcept>();
no_composite_pointer_type<int (A::*)() const, int (A::*)()>();
no_composite_pointer_type<int (A::*)(), int (A::*)() const>();
no_composite_pointer_type<int (A::*)() &, int (A::*)()>();
no_composite_pointer_type<int (A::*)(), int (A::*)() &>();
no_composite_pointer_type<int (A::*)() &&, int (A::*)()>();
no_composite_pointer_type<int (A::*)(), int (A::*)() &&>();
no_composite_pointer_type<int (A::*)() &&, int (A::*)() &>();
no_composite_pointer_type<int (A::*)() &, int (A::*)() &&>();
no_composite_pointer_type<int (C::*)(), int (A::*)() noexcept>();
no_composite_pointer_type<int (A::*)() noexcept, int (C::*)()>();
#endif
}
#if __cplusplus >= 201103L
template<typename T> struct Wrap { operator T(); }; void test_overload() {
using nullptr_t = decltype(nullptr);
void(Wrap<nullptr_t>() == Wrap<nullptr_t>());
void(Wrap<nullptr_t>() != Wrap<nullptr_t>());
void(Wrap<nullptr_t>() < Wrap<nullptr_t>()); void(Wrap<nullptr_t>() > Wrap<nullptr_t>()); void(Wrap<nullptr_t>() <= Wrap<nullptr_t>()); void(Wrap<nullptr_t>() >= Wrap<nullptr_t>());
void(Wrap<nullptr_t>() == Wrap<int*>());
void(Wrap<nullptr_t>() != Wrap<int*>());
void(Wrap<nullptr_t>() < Wrap<int*>()); void(Wrap<nullptr_t>() > Wrap<int*>()); void(Wrap<nullptr_t>() <= Wrap<int*>()); void(Wrap<nullptr_t>() >= Wrap<int*>()); }
#endif
}
namespace dr1514 { #if __cplusplus >= 201103L
struct S {
enum E : int {}; enum E : int {}; };
S::E se;
#endif
}
namespace dr1518 { #if __cplusplus >= 201103L
struct Z0 { explicit Z0() = default; };
struct Z { explicit Z(); explicit Z(int); explicit Z(int, int); };
template <class T> int Eat(T); Z0 a;
Z0 b{};
Z0 c = {}; int i = Eat<Z0>({});
Z c2 = {}; int i2 = Eat<Z>({}); Z a1 = 1; Z a3 = Z(1);
Z a2(1);
Z *p = new Z(1);
Z a4 = (Z)1;
Z a5 = static_cast<Z>(1);
Z a6 = {4, 3};
struct UserProvidedBaseCtor { UserProvidedBaseCtor() {}
};
struct DoesntInheritCtor : UserProvidedBaseCtor { int x;
};
DoesntInheritCtor I{{}, 42};
#if __cplusplus <= 201402L
#endif
struct BaseCtor { BaseCtor() = default; }; struct InheritsCtor : BaseCtor { using BaseCtor::BaseCtor; int x;
};
InheritsCtor II = {{}, 42};
namespace std_example {
struct A {
explicit A() = default; };
struct B : A {
explicit B() = default; };
struct C {
explicit C(); };
struct D : A {
C c;
explicit D() = default; };
template <typename T> void f() {
T t; T u{}; T v = {}; }
template <typename T> void g() {
void x(T t); x({}); }
void test() {
f<A>(); f<B>(); f<C>(); f<D>(); g<A>(); g<B>(); g<C>(); g<D>(); }
}
#endif }
namespace dr1550 { int f(bool b, int n) {
return (b ? (throw 0) : n) + (b ? n : (throw 0));
}
}
namespace dr1558 { #if __cplusplus >= 201103L
template<class T, class...> using first_of = T;
template<class T> first_of<void, typename T::type> f(int); template<class T> void f(...) = delete;
struct X { typedef void type; };
void test() {
f<X>(0);
f<int>(0); }
#endif
}
namespace dr1560 { void f(bool b, int n) {
(b ? throw 0 : n) = (b ? n : throw 0) = 0;
}
class X { X(const X&); };
const X &get();
const X &x = true ? get() : throw 0;
}
namespace dr1563 { #if __cplusplus >= 201103L
double bar(double) { return 0.0; }
float bar(float) { return 0.0f; }
using fun = double(double);
fun &foo{bar}; #endif
}
namespace dr1573 { #if __cplusplus >= 201103L
struct A { A(); A(int, char, ...); };
struct B : A { using A::A; };
B b(1, 'x', 4.0, "hello");
struct C { C(); constexpr C(int) {} };
struct D : C { using C::C; };
constexpr D d = D(0); struct E : C { using C::C; A a; }; constexpr E e = E(0); struct F : C { using C::C; C c; }; constexpr F f = F(0);
struct G { G(int); };
struct H : G { using G::G; G g; }; H h(0); #endif
}
#if __cplusplus >= 201103L
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 < class _T1, class _T2 > struct pair { _T2 second; };
template<typename T> struct basic_string {
basic_string(const T* x) {}
~basic_string() {};
};
typedef basic_string<char> string;
}
namespace dr1579 { template<class T>
struct GenericMoveOnly {
GenericMoveOnly();
template<class U> GenericMoveOnly(const GenericMoveOnly<U> &) = delete; GenericMoveOnly(const int &) = delete; template<class U> GenericMoveOnly(GenericMoveOnly<U> &&);
GenericMoveOnly(int &&);
};
GenericMoveOnly<float> DR1579_Eligible(GenericMoveOnly<char> CharMO) {
int i;
GenericMoveOnly<char> GMO;
if (0)
return i;
else if (0)
return GMO;
else if (0)
return ((GMO));
else
return CharMO;
}
GenericMoveOnly<char> GlobalMO;
GenericMoveOnly<float> DR1579_Ineligible(int &AnInt,
GenericMoveOnly<char> &CharMO) {
static GenericMoveOnly<char> StaticMove;
extern GenericMoveOnly<char> ExternMove;
if (0)
return AnInt; else if (0)
return GlobalMO; else if (0)
return StaticMove; else if (0)
return ExternMove; else if (0)
return AnInt; else
return CharMO; }
auto DR1579_lambda_valid = [](GenericMoveOnly<float> mo) ->
GenericMoveOnly<char> {
return mo;
};
auto DR1579_lambda_invalid = []() -> GenericMoveOnly<char> {
static GenericMoveOnly<float> mo;
return mo; };
}
namespace dr1584 {
template<typename T> void f(const T *); template<typename T> void g(T *, const T * = 0);
template<typename T> void h(T *) { T::error; } template<typename T> void h(const T *);
void i() {
f(&i); g(&i);
h(&i); }
}
namespace dr1589 {
void f0(long, int=0); void f0(long); void f0(std::initializer_list<int>); void g0() { f0({1L}); }
void f1(int, int=0); void f1(int); void f1(std::initializer_list<long>); void g1() { f1({42}); }
void f2(std::pair<const char*, const char*>, int = 0); void f2(std::pair<const char*, const char*>); void f2(std::initializer_list<std::string>); void g2() { f2({"foo","bar"}); }
namespace with_error {
void f0(long); void f0(std::initializer_list<int>); void f0(std::initializer_list<int>, int = 0); void g0() { f0({1L}); }
void f1(int); void f1(std::initializer_list<long>); void f1(std::initializer_list<long>, int = 0); void g1() { f1({42}); }
void f2(std::pair<const char*, const char*>); void f2(std::initializer_list<std::string>); void f2(std::initializer_list<std::string>, int = 0); void g2() { f2({"foo","bar"}); } }
}
namespace dr1591 { template<class T, int N> int h(T const(&)[N]);
int X = h({1,2,3});
template<class T> int j(T const(&)[3]);
int Y = j({42});
struct Aggr { int i; int j; };
template<int N> int k(Aggr const(&)[N]); int Y0 = k({1,2,3}); int Z = k({{1},{2},{3}});
template<int M, int N> int m(int const(&)[M][N]);
int X0 = m({{1,2},{3,4}});
template<class T, int N> int n(T const(&)[N], T);
int X1 = n({{1},{2},{3}},Aggr());
namespace check_multi_dim_arrays {
template<class T, int N, int M, int O> int ***f(const T (&a)[N][M][O]); template<class T, int N, int M> int **f(const T (&a)[N][M]);
template<class T, int N> int *f(const T (&a)[N]); int ***p3 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12} } });
int ***p33 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12, 13} } }); int **p2 = f({ {1,2,3}, {3, 4, 5} });
int **p22 = f({ {1,2}, {3, 4} });
int *p1 = f({1, 2, 3});
}
namespace check_multi_dim_arrays_rref {
template<class T, int N, int M, int O> int ***f(T (&&a)[N][M][O]); template<class T, int N, int M> int **f(T (&&a)[N][M]);
template<class T, int N> int *f(T (&&a)[N]); int ***p3 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12} } });
int ***p33 = f({ { {1,2}, {3, 4} }, { {5,6}, {7, 8} }, { {9,10}, {11, 12, 13} } }); int **p2 = f({ {1,2,3}, {3, 4, 5} });
int **p22 = f({ {1,2}, {3, 4} });
int *p1 = f({1, 2, 3});
}
namespace check_arrays_of_init_list {
template<class T, int N> float *f(const std::initializer_list<T> (&)[N]);
template<class T, int N> double *f(const T(&)[N]);
double *p = f({1, 2, 3});
float *fp = f({{1}, {1, 2}, {1, 2, 3}});
}
namespace core_reflector_28543 {
template<class T, int N> int *f(T (&&)[N]); template<class T> char *f(std::initializer_list<T> &&); template<class T, int N, int M> int **f(T (&&)[N][M]); template<class T, int N> char **f(std::initializer_list<T> (&&)[N]);
template<class T> short *f(T (&&)[2]);
template<class T> using Arr = T[];
char *pc = f({1, 2, 3}); char *pc2 = f({1, 2}); int *pi = f(Arr<int>{1, 2, 3});
void *pv1 = f({ {1, 2, 3}, {4, 5, 6} }); char **pcc = f({ {1}, {2, 3} });
short *ps = f(Arr<int>{1, 2}); }
}
#endif