summaryrefslogtreecommitdiff
path: root/test/SemaCXX/cxx0x-defaulted-functions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/cxx0x-defaulted-functions.cpp')
-rw-r--r--test/SemaCXX/cxx0x-defaulted-functions.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/SemaCXX/cxx0x-defaulted-functions.cpp b/test/SemaCXX/cxx0x-defaulted-functions.cpp
index 16e20ff4964d..7ec9726095cb 100644
--- a/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ b/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -208,3 +208,38 @@ int fn() {
t = true;
}
}
+
+namespace dependent_classes {
+template <bool B, typename X, typename Y>
+struct conditional;
+
+template <typename X, typename Y>
+struct conditional<true, X, Y> { typedef X type; };
+
+template <typename X, typename Y>
+struct conditional<false, X, Y> { typedef Y type; };
+
+template<bool B> struct X {
+ X();
+
+ // B == false triggers error for = default.
+ using T = typename conditional<B, const X &, int>::type;
+ X(T) = default; // expected-error {{only special member functions}}
+
+ // Either value of B creates a constructor that can be default
+ using U = typename conditional<B, X&&, const X&>::type;
+ X(U) = default;
+};
+
+X<true> x1;
+X<false> x2; // expected-note {{in instantiation}}
+
+template <typename Type>
+class E {
+ explicit E(const int &) = default;
+};
+
+template <typename Type>
+E<Type>::E(const int&) {} // expected-error {{definition of explicitly defaulted function}}
+
+}