diff options
Diffstat (limited to 'libcxx/test/std/utilities/function.objects')
12 files changed, 210 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.fail.cpp new file mode 100644 index 00000000000..e156fa966ac --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 +// XFAIL: c++11, c++14 + +// <functional> + +#include <functional> +#include <type_traits> + +#include "test_macros.h" + +struct S : public std::function<void()> { using function::function; }; + +int main() { + S f1( [](){} ); + S f2(std::allocator_arg, std::allocator<int>{}, f1); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp index bc8ab873b0a..5bdf9e98e89 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 +// REQUIRES-ANY: c++11, c++14 // <functional> @@ -16,6 +17,8 @@ #include <functional> #include <type_traits> +#include "test_macros.h" + using Fn = std::function<void()>; struct S : public std::function<void()> { using function::function; }; diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp new file mode 100644 index 00000000000..f455f031184 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.fail.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> +// XFAIL: c++98, c++03, c++11, c++14 + +// class function<R(ArgTypes...)> + +// template<class A> function(allocator_arg_t, const A&); + +#include <functional> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + std::function<int(int)> f(std::allocator_arg, std::allocator<int>()); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp index f97e34d3f2c..392dfc1993b 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp @@ -8,10 +8,13 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // class function<R(ArgTypes...)> // template<class A> function(allocator_arg_t, const A&); +// +// This signature was removed in C++17 #include <functional> #include <cassert> diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp new file mode 100644 index 00000000000..24f7fceb877 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> +// XFAIL: c++98, c++03, c++11, c++14 + +// class function<R(ArgTypes...)> + +// template<class F, class A> function(allocator_arg_t, const A&, F); +// +// This signature was removed in C++17 + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +void foo(int) {} + +int main() +{ + std::function<void(int)> f(std::allocator_arg, std::allocator<int>(), foo); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp index e662b6c2427..8d454723320 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // class function<R(ArgTypes...)> diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp new file mode 100644 index 00000000000..9967457ff82 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> +// XFAIL: c++98, c++03, c++11, c++14 + +// class function<R(ArgTypes...)> + +// template<class A> function(allocator_arg_t, const A&, const function&); +// +// This signature was removed in C++17 + + +#include <functional> +#include <cassert> + +#include "test_macros.h" + +int main() +{ + typedef std::function<void(int)> F; + F f1; + F f2(std::allocator_arg, std::allocator<int>(), f1); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp index 371eb98de1a..718aa49341d 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // class function<R(ArgTypes...)> diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp new file mode 100644 index 00000000000..cc4ecce7513 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.fail.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> +// XFAIL: c++98, c++03, c++11, c++14 + +// class function<R(ArgTypes...)> + +// template<class A> function(allocator_arg_t, const A&, nullptr_t); +// +// This signature was removed in C++17 + +#include <functional> +#include <cassert> + +#include "min_allocator.h" + +int main() +{ + std::function<int(int)> f(std::allocator_arg, std::allocator<int>(), nullptr); +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp index 2350f92f0f8..354ad955f20 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp @@ -8,10 +8,13 @@ //===----------------------------------------------------------------------===// // <functional> +// REQUIRES-ANY: c++98, c++03, c++11, c++14 // class function<R(ArgTypes...)> // template<class A> function(allocator_arg_t, const A&, nullptr_t); +// +// This signature was removed in C++17 #include <functional> #include <cassert> diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp new file mode 100644 index 00000000000..cb9fb9afad2 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.fail.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <functional> +// XFAIL: c++98, c++03, c++11, c++14 + +// class function<R(ArgTypes...)> + +// template<class A> function(allocator_arg_t, const A&, function&&); +// +// This signature was removed in C++17 + +#include <functional> +#include <memory> +#include <cassert> + +#include "test_macros.h" + +class A +{ + int data_[10]; +public: + static int count; + + A() + { + ++count; + for (int i = 0; i < 10; ++i) + data_[i] = i; + } + + A(const A&) {++count;} + + ~A() {--count;} + + int operator()(int i) const + { + for (int j = 0; j < 10; ++j) + i += data_[j]; + return i; + } +}; + +int A::count = 0; + +int g(int) { return 0; } + +int main() +{ + { + std::function<int(int)> f = A(); + std::function<int(int)> f2(std::allocator_arg, std::allocator<A>(), std::move(f)); + } +} diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp index 403d646f421..e328481b274 100644 --- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp @@ -8,12 +8,15 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03 +// REQUIRES-ANY: c++11, c++14 // <functional> // class function<R(ArgTypes...)> // template<class A> function(allocator_arg_t, const A&, function&&); +// +// This signature was removed in C++17 #include <functional> #include <memory> |