re PR c++/70563 (SFINAE fails when trying invalid template instantiation)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 8 May 2018 10:03:39 +0000 (10:03 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 8 May 2018 10:03:39 +0000 (10:03 +0000)
2018-05-08  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/70563
* g++.dg/cpp0x/sfinae62.C: New.

From-SVN: r260030

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/sfinae62.C [new file with mode: 0644]

index cc61ffb938ef5d8dfc024175727e66ba99b4b27f..d5126b3eb6daf7aaeaf588af07f31ef7e0505d31 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/70563
+       * g++.dg/cpp0x/sfinae62.C: New.
+
 2018-05-08  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * gcc.target/aarch64/sve/vcond_6.c (LOOP): Unconditionally
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae62.C b/gcc/testsuite/g++.dg/cpp0x/sfinae62.C
new file mode 100644 (file)
index 0000000..7bde64c
--- /dev/null
@@ -0,0 +1,41 @@
+// PR c++/70563
+// { dg-do compile { target c++11 } }
+
+template<typename... T> using void_t = void;
+
+template<typename T> struct TemporaryBindObject
+{
+};
+
+struct MyTrueType
+{
+ static constexpr bool value = true;
+};
+
+struct MyFalseType
+{
+ static constexpr bool value = false;
+};
+
+template<template<typename...> class Dest> struct TestValidBind
+{
+ template<typename T, typename = void_t<>> struct toTypesOf : MyFalseType
+ {};
+ template<template<typename...> class Src, typename... Ts> struct toTypesOf<Src<Ts...>, void_t<Dest<Ts...,float>>> : MyTrueType
+ {};
+};
+
+template<typename T> struct OneParamStruct
+{
+};
+template<typename T1, typename T2> struct TwoParamStruct
+{
+};
+
+using tmp = TemporaryBindObject<int>;
+
+int main()
+{
+ bool value1 = TestValidBind<TwoParamStruct>::toTypesOf<TemporaryBindObject<int>>::value;
+ bool value2 = TestValidBind<OneParamStruct>::toTypesOf<TemporaryBindObject<int>>::value;
+}