summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-10-30 09:35:42 +0000
committer <>2015-01-09 11:51:27 +0000
commitc27a97d04853380f1e80525391b3f0d156ed4c84 (patch)
tree68ffaade7c605bc80cffa18360799c98a810976f /gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C
parent6af3fdec2262dd94954acc5e426ef71cbd4521d3 (diff)
downloadgcc-tarball-c27a97d04853380f1e80525391b3f0d156ed4c84.tar.gz
Imported from /home/lorry/working-area/delta_gcc-tarball/gcc-4.9.2.tar.bz2.gcc-4.9.2
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C55
1 files changed, 55 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C
new file mode 100644
index 0000000000..973f8a7804
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-sfinae1.C
@@ -0,0 +1,55 @@
+// PR c++/56039
+// { dg-do compile { target c++11 } }
+
+template <bool> struct BoolSink { typedef void type; };
+
+template <typename T, typename U>
+struct AddRvalueReferenceImpl { typedef T type; };
+
+template <typename T>
+struct AddRvalueReferenceImpl<T, typename BoolSink<false &&
+ [] {
+ extern T &&tref;
+ }>::type> { // { dg-error "lambda" }
+ typedef T &&type;
+};
+
+template <typename T>
+struct AddRvalueReference : AddRvalueReferenceImpl<T, void> { };
+
+namespace ImplHelpers {
+ template <typename T>
+ typename AddRvalueReference<T>::type create(void) { }
+}
+
+template <typename T, typename U, typename ...Args>
+struct IsConstructibleImpl { enum { value = 0 }; };
+
+template <typename T, typename ...Args>
+struct IsConstructibleImpl<T, typename BoolSink<false &&
+ [] {
+ T t( ::ImplHelpers::create<Args>() ...);
+ }>::type, Args ...> { // { dg-error "lambda" }
+ enum { value = 1 };
+};
+
+template <typename T, typename ...Args>
+struct IsConstructible : IsConstructibleImpl<T, void, Args ...> { };
+
+struct DestroyMe {
+ ~DestroyMe() = delete;
+};
+
+static_assert(+IsConstructible<int>::value, "error");
+static_assert(!IsConstructible<void>::value, "error");
+static_assert(+IsConstructible<int [1]>::value, "error");
+static_assert(!IsConstructible<DestroyMe>::value, "error");
+static_assert(!IsConstructible<int *, char *>::value, "error");
+
+static_assert(+IsConstructible<int &&, int>::value, "error");
+static_assert(!IsConstructible<int &&, int &>::value, "error");
+static_assert(+IsConstructible<int &&, int &&>::value, "error");
+
+// { dg-prune-output "expected" }
+// { dg-prune-output "does not name a class" }
+// { dg-prune-output "static assertion" }