diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-03 16:17:20 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-03 16:17:20 +0000 |
commit | 81063a237722ae010bca325021b92436f8c56e05 (patch) | |
tree | ef3c72fe220f4b022444d08f8bd000ba5f273f30 | |
parent | 7f886434372264d13648dab5e4048de1fe671246 (diff) |
Consolidate template metafunction tests for variadic templates into a single file
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@122748 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp (renamed from test/CXX/temp/temp.decls/temp.variadic/count.cpp) | 34 | ||||
-rw-r--r-- | test/CXX/temp/temp.decls/temp.variadic/replace.cpp | 26 |
2 files changed, 32 insertions, 28 deletions
diff --git a/test/CXX/temp/temp.decls/temp.variadic/count.cpp b/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp index 1f6778adc3..6a5e989d1a 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/count.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/metafunctions.cpp @@ -1,6 +1,21 @@ // RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s -namespace Basic { +// This is a collection of various template metafunctions involving +// variadic templates, which are meant to exercise common use cases. +template<typename T, typename U> +struct is_same { + static const bool value = false; +}; + +template<typename T> +struct is_same<T, T> { + static const bool value = true; +}; + +template<typename...> struct tuple { }; +template<int ...> struct int_tuple { }; + +namespace Count { template<typename Head, typename ...Tail> struct count { static const unsigned value = 1 + count<Tail...>::value; @@ -16,7 +31,7 @@ namespace Basic { int check3[count<char, signed char, unsigned char>::value == 3? 1 : -1]; } -namespace WithPackExpansion { +namespace CountWithPackExpansion { template<typename ...> struct count; template<typename Head, typename ...Tail> @@ -34,3 +49,18 @@ namespace WithPackExpansion { int check2[count<float, double>::value == 2? 1 : -1]; int check3[count<char, signed char, unsigned char>::value == 3? 1 : -1]; } + +namespace Replace { + // Simple metafunction that replaces the template arguments of + // template template parameters with 'int'. + template<typename T> + struct EverythingToInt; + + template<template<typename ...> class TT, typename T1, typename T2> + struct EverythingToInt<TT<T1, T2> > { + typedef TT<int, int> type; + }; + + int check0[is_same<EverythingToInt<tuple<double, float>>::type, + tuple<int, int>>::value? 1 : -1]; +} diff --git a/test/CXX/temp/temp.decls/temp.variadic/replace.cpp b/test/CXX/temp/temp.decls/temp.variadic/replace.cpp deleted file mode 100644 index eb49cd1317..0000000000 --- a/test/CXX/temp/temp.decls/temp.variadic/replace.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s - -template<typename T, typename U> -struct is_same { - static const bool value = false; -}; - -template<typename T> -struct is_same<T, T> { - static const bool value = true; -}; - -// Simple metafunction that replaces the template arguments of -// template template parameters with 'int'. -template<typename T> -struct EverythingToInt; - -template<template<typename ...> class TT, typename T1, typename T2> -struct EverythingToInt<TT<T1, T2> > { - typedef TT<int, int> type; -}; - -template<typename...> struct tuple { }; - -int check0[is_same<EverythingToInt<tuple<double, float>>::type, - tuple<int, int>>::value? 1 : -1]; |