//
//===----------------------------------------------------------------------===//
-// UNSUPPORTED: c++03
-// XFAIL: c++11, c++14
+// UNSUPPORTED: c++03, c++11, c++14
// <functional>
+//
+// Make sure we can't initialize a std::function using an allocator (http://wg21.link/p0302r1).
+// These constructors were removed in C++17.
#include <functional>
-#include <type_traits>
-
-#include "test_macros.h"
+#include <memory>
struct S : public std::function<void()> { using function::function; };
-int main(int, char**) {
- S f1( [](){} );
- S f2(std::allocator_arg, std::allocator<int>{}, f1);
-
- return 0;
+void f() {
+ S f1( [](){} );
+ S f2(std::allocator_arg, std::allocator<int>{}, f1); // expected-error {{no matching constructor for initialization of 'S'}}
}
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++03
+
// <functional>
// class function<R(ArgTypes...)>
#include <functional>
#include <cassert>
-// member data pointer: cv qualifiers should transfer from argument to return type
-
-struct A_int_1
-{
- A_int_1() : data_(5) {}
-
- int data_;
-};
-
-void
-test_int_1()
-{
- // member data pointer
- {
- int A_int_1::*fp = &A_int_1::data_;
- A_int_1 a;
- std::function<int& (const A_int_1*)> r2(fp);
- const A_int_1* ap = &a;
- assert(r2(ap) == 6);
- r2(ap) = 7;
- assert(r2(ap) == 7);
- }
-}
+// member data pointer: cv qualifiers should transfer from argument to return type
-int main(int, char**)
-{
- test_int_1();
+struct Foo { int data; };
- return 0;
+void f() {
+ int Foo::*fp = &Foo::data;
+ std::function<int& (const Foo*)> r2(fp); // expected-error {{no matching constructor for initialization of}}
}