alias-template.cpp [plain text]
namespace RedeclAliasTypedef {
template<typename U> using T = int;
template<typename U> using T = int;
template<typename U> using T = T<U>;
}
namespace IllegalTypeIds {
template<typename U> using A = void(int n = 0); template<typename U> using B = inline void(int n); template<typename U> using C = virtual void(int n); template<typename U> using D = explicit void(int n); template<typename U> using E = void(int n) throw(); template<typename U> using F = void(*)(int n) &&; template<typename U> using G = __thread void(int n); template<typename U> using H = constexpr int;
template<typename U> using Y = void(int n); template<typename U> using Z = void(int n) &&; }
namespace IllegalSyntax {
template<typename Z> using ::T = void(int n); template<typename Z> using operator int = void(int n); template<typename Z> using typename U = void; template<typename Z> using typename ::V = void(int n); template<typename Z> using typename ::operator bool = void(int n); }
namespace VariableLengthArrays {
template<typename Z> using T = int[42];
int n = 32;
template<typename Z> using T = int[n];
const int m = 42;
template<typename Z> using U = int[m]; template<typename Z> using U = int[42]; template<typename Z> using U = int; }
namespace RedeclFunc {
int f(int, char**);
template<typename Z> using T = int;
T<char> f(int, char **); }
namespace LookupFilter {
namespace N { template<typename U> using S = int; }
using namespace N;
template<typename U> using S = S<U>*; }
namespace InFunctions {
template<typename...T> struct S0 {
template<typename Z> using U = T*; U<char> u;
};
template<typename Z> using T1 = int;
template<typename Z> using T2 = int[-1]; template<typename...T> struct S3 { template<typename Z> using T = int; };
template<typename Z> using Z = Z;
}
namespace ClassNameRedecl {
class C0 {
template<typename U> using C0 = int; };
class C1 {
template<typename U> using C1 = C1; };
class C2 {
template<typename U> using C0 = C1; };
template<typename...T> class C3 {
template<typename U> using f = T; };
template<typename T> class C4 { template<typename U> using T = int; };
class C5 {
class c; template<typename U> using c = int; class d; template<typename U> using d = d; };
class C6 {
class c { template<typename U> using C6 = int; }; };
}
class CtorDtorName {
template<typename T> using X = CtorDtorName;
X<int>(); ~X<int>(); };
namespace TagName {
template<typename Z> using S = struct { int n; }; template<typename Z> using T = class { int n; }; template<typename Z> using U = enum { a, b, c }; template<typename Z> using V = struct V { int n; }; expected-error {{'TagName::V' can not be defined in a type alias template}} \
expected-note {{previous definition is here}}
}
namespace StdExample {
template<typename T, typename U> struct pair;
template<typename T> using handler_t = void (*)(T);
extern handler_t<int> ignore;
extern void (*ignore)(int);
template<typename T> using cell = pair<T*, cell<T>*>; expected-error {{'T' does not refer to a value}} \
expected-note {{declared here}} \
expected-error {{expected ';' after alias declaration}}
}
namespace Access {
class C0 {
template<typename Z> using U = int; };
C0::U<int> v; class C1 {
public:
template<typename Z> using U = int;
};
C1::U<int> w; }
namespace VoidArg {
template<typename Z> using V = void;
V<int> f(int); V<char> g(V<double>); }
namespace Curried {
template<typename T, typename U> struct S;
template<typename T> template<typename U> using SS = S<T, U>; }
namespace SFINAE {
template<bool> struct enable_if; template<> struct enable_if<true> { using type = void; };
template<typename T> struct is_enum { static constexpr bool value = __is_enum(T); };
template<typename T> using EnableIf = typename enable_if<T::value>::type; template<typename T> using DisableIf = typename enable_if<!T::value>::type;
template<typename T> EnableIf<is_enum<T>> f();
template<typename T> DisableIf<is_enum<T>> f();
enum E { e };
int main() {
f<int>();
f<E>();
}
template<typename T, typename U = EnableIf<is_enum<T>>> struct fail1 {}; template<typename T> struct fail2 : DisableIf<is_enum<T>> {};
fail1<int> f1; fail2<E> f2; }