From 4b658cc5d6f8658a633ac22d9b574dc7a030612e Mon Sep 17 00:00:00 2001 From: paolo Date: Fri, 16 Jan 2015 18:24:52 +0000 Subject: [PATCH] 2015-01-16 Paolo Carlini PR c++/62134 * g++.dg/cpp0x/alias-decl-46.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@219766 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.dg/cpp0x/alias-decl-46.C | 114 +++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-46.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fa76e0c55e6..c2e957f251f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-16 Paolo Carlini + + PR c++/62134 + * g++.dg/cpp0x/alias-decl-46.C: New. + 2015-01-16 Christophe Lyon * gcc.target/aarch64/advsimd-intrinsics/arm-neon-ref.h (CHECK): diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-46.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-46.C new file mode 100644 index 00000000000..19595ea3cf2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-46.C @@ -0,0 +1,114 @@ +// PR c++/62134 +// { dg-do compile { target c++11 } } + +template struct tuple; +template<__SIZE_TYPE__, typename U> struct tuple_element; + +template struct enable_if { }; +template struct enable_if { typedef T type; }; + +template struct int_t { static constexpr int value = V; }; +template int constexpr int_t::value; + +template +struct Index +{ + static int const value = -1; +}; + +template +struct Index, Val, i> +{ + static int const value = i; +}; + +template +struct Index, Val, i> +{ + static int const value = Index, Val, i+1>::value; +}; + +template struct PermutationSign; + +template +struct PermutationSignIfFound +{ + static int const value = 0; +}; + +template +struct PermutationSignIfFound<-1, C, R> +{ + static int const value = 0; +}; + +template <> +struct PermutationSign, tuple<>> +{ + static int const value = 1; +}; + +template +struct PermutationSign> +{ + static int const value = 0; +}; + +template +struct PermutationSign, R> +{ + static int const value = 0; +}; + +template +struct PermutationSign +{ + static int const value + = PermutationSignIfFound + ::type>::value, + C, Org>::value; +}; + +template class Pred, int i=0, class Enable=void> +struct IndexIf +{ + static int const value = -1; + using type = tuple<>; +}; + +template class Pred, int i> +struct IndexIf, Pred, i, + typename enable_if::value>::type> +{ + using type = A0; + static int const value = i; +}; + +template class Pred, int i> +struct IndexIf, Pred, i, + typename enable_if::value>::type> +{ + using next = IndexIf, Pred, i+1>; + using type = typename next::type; + static int const value = next::value; +}; + +template +struct MatchPermutationP +{ + template using type = PermutationSign; +}; + +template struct FindCombination +{ + using type = IndexIf::template type>; + static int const where = type::value; + static int const sign + = (where>=0) ? PermutationSign::value : 0; +}; + +int main() +{ + using finder = FindCombination, tuple>>; + static_assert(finder::where==0 && finder::sign==+1, "bad"); +} -- 2.11.4.GIT