diff options
| author | Bill Wendling <isanbard@gmail.com> | 2012-04-18 21:39:23 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2012-04-18 21:39:23 +0000 |
| commit | 392e4fbdd9b152efff4c051286f6b2c21270c902 (patch) | |
| tree | 4ac339be2c4c7c596f068b59d5e512b157c7b433 /libcxx/test/utilities/function.objects | |
| parent | eb1c2bdc1f55fbc5d1e7bb86e9f0e038b0f5adb7 (diff) | |
Creating release_31 branchllvmorg-3.1.0-rc1
llvm-svn: 155059
llvm-svn: 155053
llvm-svn: 155051
Diffstat (limited to 'libcxx/test/utilities/function.objects')
90 files changed, 0 insertions, 5258 deletions
diff --git a/libcxx/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp b/libcxx/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp deleted file mode 100644 index 13e5b68a30a2..000000000000 --- a/libcxx/test/utilities/function.objects/arithmetic.operations/divides.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// divides - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::divides<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); - assert(f(36, 4) == 9); -} diff --git a/libcxx/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp b/libcxx/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp deleted file mode 100644 index f777b2397eae..000000000000 --- a/libcxx/test/utilities/function.objects/arithmetic.operations/minus.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// minus - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::minus<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); - assert(f(3, 2) == 1); -} diff --git a/libcxx/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp b/libcxx/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp deleted file mode 100644 index 542711fb2ee6..000000000000 --- a/libcxx/test/utilities/function.objects/arithmetic.operations/modulus.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// modulus - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::modulus<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); - assert(f(36, 8) == 4); -} diff --git a/libcxx/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp b/libcxx/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp deleted file mode 100644 index c96938f8c5ec..000000000000 --- a/libcxx/test/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// multiplies - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::multiplies<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); - assert(f(3, 2) == 6); -} diff --git a/libcxx/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp b/libcxx/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp deleted file mode 100644 index 6c6957ab1e73..000000000000 --- a/libcxx/test/utilities/function.objects/arithmetic.operations/negate.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// negate - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::negate<int> F; - const F f = F(); - static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), ""); - assert(f(36) == -36); -} diff --git a/libcxx/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp b/libcxx/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp deleted file mode 100644 index bc72195d91a8..000000000000 --- a/libcxx/test/utilities/function.objects/arithmetic.operations/plus.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// plus - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::plus<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); - assert(f(3, 2) == 5); -} diff --git a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp deleted file mode 100644 index ab4dd59534d5..000000000000 --- a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<CopyConstructible Fn, CopyConstructible... Types> -// unspecified bind(Fn, Types...); -// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> -// unspecified bind(Fn, Types...); - -#include <functional> -#include <cassert> - -template <class R, class F> -void -test(F f, R expected) -{ - assert(f() == expected); -} - -template <class R, class F> -void -test_const(const F& f, R expected) -{ - assert(f() == expected); -} - -int f() {return 1;} - -struct A_int_0 -{ - int operator()() {return 4;} - int operator()() const {return 5;} -}; - -int main() -{ - test(std::bind(f), 1); - test(std::bind(&f), 1); - test(std::bind(A_int_0()), 4); - test_const(std::bind(A_int_0()), 5); - - test(std::bind<int>(f), 1); - test(std::bind<int>(&f), 1); - test(std::bind<int>(A_int_0()), 4); - test_const(std::bind<int>(A_int_0()), 5); -} diff --git a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp deleted file mode 100644 index 6b18fa295bca..000000000000 --- a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp +++ /dev/null @@ -1,268 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<CopyConstructible Fn, CopyConstructible... Types> -// unspecified bind(Fn, Types...); -// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> -// unspecified bind(Fn, Types...); - -#include <stdio.h> - -#include <functional> -#include <cassert> - -int count = 0; - -// 1 arg, return void - -void f_void_1(int i) -{ - count += i; -} - -struct A_void_1 -{ - void operator()(int i) - { - count += i; - } - - void mem1() {++count;} - void mem2() const {count += 2;} -}; - -void -test_void_1() -{ - using namespace std::placeholders; - int save_count = count; - // function - { - int i = 2; - std::bind(f_void_1, _1)(i); - assert(count == save_count + 2); - save_count = count; - } - { - int i = 2; - std::bind(f_void_1, i)(); - assert(count == save_count + 2); - save_count = count; - } - // function pointer - { - void (*fp)(int) = f_void_1; - int i = 3; - std::bind(fp, _1)(i); - assert(count == save_count+3); - save_count = count; - } - { - void (*fp)(int) = f_void_1; - int i = 3; - std::bind(fp, i)(); - assert(count == save_count+3); - save_count = count; - } - // functor - { - A_void_1 a0; - int i = 4; - std::bind(a0, _1)(i); - assert(count == save_count+4); - save_count = count; - } - { - A_void_1 a0; - int i = 4; - std::bind(a0, i)(); - assert(count == save_count+4); - save_count = count; - } - // member function pointer - { - void (A_void_1::*fp)() = &A_void_1::mem1; - A_void_1 a; - std::bind(fp, _1)(a); - assert(count == save_count+1); - save_count = count; - A_void_1* ap = &a; - std::bind(fp, _1)(ap); - assert(count == save_count+1); - save_count = count; - } - { - void (A_void_1::*fp)() = &A_void_1::mem1; - A_void_1 a; - std::bind(fp, a)(); - assert(count == save_count+1); - save_count = count; - A_void_1* ap = &a; - std::bind(fp, ap)(); - assert(count == save_count+1); - save_count = count; - } - // const member function pointer - { - void (A_void_1::*fp)() const = &A_void_1::mem2; - A_void_1 a; - std::bind(fp, _1)(a); - assert(count == save_count+2); - save_count = count; - A_void_1* ap = &a; - std::bind(fp, _1)(ap); - assert(count == save_count+2); - save_count = count; - } - { - void (A_void_1::*fp)() const = &A_void_1::mem2; - A_void_1 a; - std::bind(fp, a)(); - assert(count == save_count+2); - save_count = count; - A_void_1* ap = &a; - std::bind(fp, ap)(); - assert(count == save_count+2); - save_count = count; - } -} - -// 1 arg, return int - -int f_int_1(int i) -{ - return i + 1; -} - -struct A_int_1 -{ - A_int_1() : data_(5) {} - int operator()(int i) - { - return i - 1; - } - - int mem1() {return 3;} - int mem2() const {return 4;} - int data_; -}; - -void -test_int_1() -{ - using namespace std::placeholders; - // function - { - int i = 2; - assert(std::bind(f_int_1, _1)(i) == 3); - assert(std::bind(f_int_1, i)() == 3); - } - // function pointer - { - int (*fp)(int) = f_int_1; - int i = 3; - assert(std::bind(fp, _1)(i) == 4); - assert(std::bind(fp, i)() == 4); - } - // functor - { - int i = 4; - assert(std::bind(A_int_1(), _1)(i) == 3); - assert(std::bind(A_int_1(), i)() == 3); - } - // member function pointer - { - A_int_1 a; - assert(std::bind(&A_int_1::mem1, _1)(a) == 3); - assert(std::bind(&A_int_1::mem1, a)() == 3); - A_int_1* ap = &a; - assert(std::bind(&A_int_1::mem1, _1)(ap) == 3); - assert(std::bind(&A_int_1::mem1, ap)() == 3); - } - // const member function pointer - { - A_int_1 a; - assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4); - assert(std::bind(&A_int_1::mem2, A_int_1())() == 4); - A_int_1* ap = &a; - assert(std::bind(&A_int_1::mem2, _1)(ap) == 4); - assert(std::bind(&A_int_1::mem2, ap)() == 4); - } - // member data pointer - { - A_int_1 a; - assert(std::bind(&A_int_1::data_, _1)(a) == 5); - assert(std::bind(&A_int_1::data_, a)() == 5); - A_int_1* ap = &a; - assert(std::bind(&A_int_1::data_, _1)(a) == 5); - std::bind(&A_int_1::data_, _1)(a) = 6; - assert(std::bind(&A_int_1::data_, _1)(a) == 6); - assert(std::bind(&A_int_1::data_, _1)(ap) == 6); - std::bind(&A_int_1::data_, _1)(ap) = 7; - assert(std::bind(&A_int_1::data_, _1)(ap) == 7); - } -} - -// 2 arg, return void - -void f_void_2(int i, int j) -{ - count += i+j; -} - -struct A_void_2 -{ - void operator()(int i, int j) - { - count += i+j; - } - - void mem1(int i) {count += i;} - void mem2(int i) const {count += i;} -}; - -void -test_void_2() -{ - using namespace std::placeholders; - int save_count = count; - // function - { - int i = 2; - int j = 3; - std::bind(f_void_2, _1, _2)(i, j); - assert(count == save_count+5); - save_count = count; - std::bind(f_void_2, i, _1)(j); - assert(count == save_count+5); - save_count = count; - std::bind(f_void_2, i, j)(); - assert(count == save_count+5); - save_count = count; - } - // member function pointer - { - int j = 3; - std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), j); - assert(count == save_count+3); - save_count = count; - std::bind(&A_void_2::mem1, _2, _1)(j, A_void_2()); - assert(count == save_count+3); - save_count = count; - } -} - -int main() -{ - test_void_1(); - test_int_1(); - test_void_2(); -} diff --git a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp deleted file mode 100644 index 4913a510c36e..000000000000 --- a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp +++ /dev/null @@ -1,266 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<CopyConstructible Fn, CopyConstructible... Types> -// unspecified bind(Fn, Types...); -// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> -// unspecified bind(Fn, Types...); - -#include <stdio.h> - -#include <functional> -#include <cassert> - -int count = 0; - -// 1 arg, return void - -void f_void_1(int i) -{ - count += i; -} - -struct A_void_1 -{ - void operator()(int i) - { - count += i; - } - - void mem1() {++count;} - void mem2() const {count += 2;} -}; - -void -test_void_1() -{ - using namespace std::placeholders; - int save_count = count; - // function - { - std::bind(f_void_1, _1)(2); - assert(count == save_count + 2); - save_count = count; - } - { - std::bind(f_void_1, 2)(); - assert(count == save_count + 2); - save_count = count; - } - // function pointer - { - void (*fp)(int) = f_void_1; - std::bind(fp, _1)(3); - assert(count == save_count+3); - save_count = count; - } - { - void (*fp)(int) = f_void_1; - std::bind(fp, 3)(); - assert(count == save_count+3); - save_count = count; - } - // functor - { - A_void_1 a0; - std::bind(a0, _1)(4); - assert(count == save_count+4); - save_count = count; - } - { - A_void_1 a0; - std::bind(a0, 4)(); - assert(count == save_count+4); - save_count = count; - } - // member function pointer - { - void (A_void_1::*fp)() = &A_void_1::mem1; - std::bind(fp, _1)(A_void_1()); - assert(count == save_count+1); - save_count = count; - A_void_1 a; - std::bind(fp, _1)(&a); - assert(count == save_count+1); - save_count = count; - } - { - void (A_void_1::*fp)() = &A_void_1::mem1; - std::bind(fp, A_void_1())(); - assert(count == save_count+1); - save_count = count; - A_void_1 a; - std::bind(fp, &a)(); - assert(count == save_count+1); - save_count = count; - } - // const member function pointer - { - void (A_void_1::*fp)() const = &A_void_1::mem2; - std::bind(fp, _1)(A_void_1()); - assert(count == save_count+2); - save_count = count; - A_void_1 a; - std::bind(fp, _1)(&a); - assert(count == save_count+2); - save_count = count; - } - { - void (A_void_1::*fp)() const = &A_void_1::mem2; - std::bind(fp, A_void_1())(); - assert(count == save_count+2); - save_count = count; - A_void_1 a; - std::bind(fp, &a)(); - assert(count == save_count+2); - save_count = count; - } -} - -// 1 arg, return int - -int f_int_1(int i) -{ - return i + 1; -} - -struct A_int_1 -{ - A_int_1() : data_(5) {} - int operator()(int i) - { - return i - 1; - } - - int mem1() {return 3;} - int mem2() const {return 4;} - int data_; -}; - -void -test_int_1() -{ - using namespace std::placeholders; - // function - { - assert(std::bind(f_int_1, _1)(2) == 3); - assert(std::bind(f_int_1, 2)() == 3); - } - // function pointer - { - int (*fp)(int) = f_int_1; - assert(std::bind(fp, _1)(3) == 4); - assert(std::bind(fp, 3)() == 4); - } - // functor - { - assert(std::bind(A_int_1(), _1)(4) == 3); - assert(std::bind(A_int_1(), 4)() == 3); - } - // member function pointer - { - assert(std::bind(&A_int_1::mem1, _1)(A_int_1()) == 3); - assert(std::bind(&A_int_1::mem1, A_int_1())() == 3); - A_int_1 a; - assert(std::bind(&A_int_1::mem1, _1)(&a) == 3); - assert(std::bind(&A_int_1::mem1, &a)() == 3); - } - // const member function pointer - { - assert(std::bind(&A_int_1::mem2, _1)(A_int_1()) == 4); - assert(std::bind(&A_int_1::mem2, A_int_1())() == 4); - A_int_1 a; - assert(std::bind(&A_int_1::mem2, _1)(&a) == 4); - assert(std::bind(&A_int_1::mem2, &a)() == 4); - } - // member data pointer - { - assert(std::bind(&A_int_1::data_, _1)(A_int_1()) == 5); - assert(std::bind(&A_int_1::data_, A_int_1())() == 5); - A_int_1 a; - assert(std::bind(&A_int_1::data_, _1)(a) == 5); - std::bind(&A_int_1::data_, _1)(a) = 6; - assert(std::bind(&A_int_1::data_, _1)(a) == 6); - assert(std::bind(&A_int_1::data_, _1)(&a) == 6); - std::bind(&A_int_1::data_, _1)(&a) = 7; - assert(std::bind(&A_int_1::data_, _1)(&a) == 7); - } -} - -// 2 arg, return void - -void f_void_2(int i, int j) -{ - count += i+j; -} - -struct A_void_2 -{ - void operator()(int i, int j) - { - count += i+j; - } - - void mem1(int i) {count += i;} - void mem2(int i) const {count += i;} -}; - -void -test_void_2() -{ - using namespace std::placeholders; - int save_count = count; - // function - { - std::bind(f_void_2, _1, _2)(2, 3); - assert(count == save_count+5); - save_count = count; - std::bind(f_void_2, 2, _1)(3); - assert(count == save_count+5); - save_count = count; - std::bind(f_void_2, 2, 3)(); - assert(count == save_count+5); - save_count = count; - } - // member function pointer - { - std::bind(&A_void_2::mem1, _1, _2)(A_void_2(), 3); - assert(count == save_count+3); - save_count = count; - std::bind(&A_void_2::mem1, _2, _1)(3, A_void_2()); - assert(count == save_count+3); - save_count = count; - } -} - -int f_nested(int i) -{ - return i+1; -} - -int g_nested(int i) -{ - return i*10; -} - -void test_nested() -{ - using namespace std::placeholders; - assert(std::bind(f_nested, std::bind(g_nested, _1))(3) == 31); -} - -int main() -{ - test_void_1(); - test_int_1(); - test_void_2(); - test_nested(); -} diff --git a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp deleted file mode 100644 index 03447db33dec..000000000000 --- a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp +++ /dev/null @@ -1,59 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<CopyConstructible Fn, CopyConstructible... Types> -// unspecified bind(Fn, Types...); -// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types> -// unspecified bind(Fn, Types...); - -#include <functional> -#include <cassert> - -int count = 0; - -template <class F> -void -test(F f) -{ - int save_count = count; - f(); - assert(count == save_count + 1); -} - -template <class F> -void -test_const(const F& f) -{ - int save_count = count; - f(); - assert(count == save_count + 2); -} - -void f() {++count;} - -struct A_int_0 -{ - void operator()() {++count;} - void operator()() const {count += 2;} -}; - -int main() -{ - test(std::bind(f)); - test(std::bind(&f)); - test(std::bind(A_int_0())); - test_const(std::bind(A_int_0())); - - test(std::bind<void>(f)); - test(std::bind<void>(&f)); - test(std::bind<void>(A_int_0())); - test_const(std::bind<void>(A_int_0())); -} diff --git a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp b/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp deleted file mode 100644 index 7f8dd4a98d2b..000000000000 --- a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<class T> struct is_bind_expression - -#include <functional> - -template <bool Expected, class T> -void -test(const T&) -{ - static_assert(std::is_bind_expression<T>::value == Expected, ""); -} - -struct C {}; - -int main() -{ - test<true>(std::bind(C())); - test<true>(std::bind(C(), std::placeholders::_2)); - test<true>(std::bind<int>(C())); - test<false>(1); - test<false>(std::placeholders::_2); -} diff --git a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp b/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp deleted file mode 100644 index 6a52bd1848e9..000000000000 --- a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.isbind/is_placeholder.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// struct is_placeholder - -#include <functional> - -template <int Expected, class T> -void -test(const T&) -{ - static_assert(std::is_placeholder<T>::value == Expected, ""); -} - -struct C {}; - -int main() -{ - test<1>(std::placeholders::_1); - test<2>(std::placeholders::_2); - test<3>(std::placeholders::_3); - test<4>(std::placeholders::_4); - test<5>(std::placeholders::_5); - test<6>(std::placeholders::_6); - test<7>(std::placeholders::_7); - test<8>(std::placeholders::_8); - test<9>(std::placeholders::_9); - test<10>(std::placeholders::_10); - test<0>(4); - test<0>(5.5); - test<0>('a'); - test<0>(C()); -} diff --git a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp b/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp deleted file mode 100644 index fa791d46ff50..000000000000 --- a/libcxx/test/utilities/function.objects/bind/func.bind/func.bind.place/placeholders.pass.cpp +++ /dev/null @@ -1,36 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// placeholders - -#include <functional> - -template <class T> -void -test(const T& t) -{ - T t2; - T t3 = t; -} - -int main() -{ - test(std::placeholders::_1); - test(std::placeholders::_2); - test(std::placeholders::_3); - test(std::placeholders::_4); - test(std::placeholders::_5); - test(std::placeholders::_6); - test(std::placeholders::_7); - test(std::placeholders::_8); - test(std::placeholders::_9); - test(std::placeholders::_10); -} diff --git a/libcxx/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp b/libcxx/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b643..000000000000 --- a/libcxx/test/utilities/function.objects/bind/func.bind/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/function.objects/bind/nothing_to_do.pass.cpp b/libcxx/test/utilities/function.objects/bind/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b643..000000000000 --- a/libcxx/test/utilities/function.objects/bind/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp b/libcxx/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp deleted file mode 100644 index ac10acdbd096..000000000000 --- a/libcxx/test/utilities/function.objects/bitwise.operations/bit_and.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// bit_and - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::bit_and<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); - assert(f(0xEA95, 0xEA95) == 0xEA95); - assert(f(0xEA95, 0x58D3) == 0x4891); - assert(f(0x58D3, 0xEA95) == 0x4891); - assert(f(0x58D3, 0) == 0); - assert(f(0xFFFF, 0x58D3) == 0x58D3); -} diff --git a/libcxx/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp b/libcxx/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp deleted file mode 100644 index 6dc3911df503..000000000000 --- a/libcxx/test/utilities/function.objects/bitwise.operations/bit_or.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// bit_or - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::bit_or<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); - assert(f(0xEA95, 0xEA95) == 0xEA95); - assert(f(0xEA95, 0x58D3) == 0xFAD7); - assert(f(0x58D3, 0xEA95) == 0xFAD7); - assert(f(0x58D3, 0) == 0x58D3); - assert(f(0xFFFF, 0x58D3) == 0xFFFF); -} diff --git a/libcxx/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp b/libcxx/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp deleted file mode 100644 index c3af462bbf22..000000000000 --- a/libcxx/test/utilities/function.objects/bitwise.operations/bit_xor.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// bit_xor - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::bit_xor<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, int>, F>::value), ""); - assert(f(0xEA95, 0xEA95) == 0); - assert(f(0xEA95, 0x58D3) == 0xB246); - assert(f(0x58D3, 0xEA95) == 0xB246); - assert(f(0x58D3, 0) == 0x58D3); - assert(f(0xFFFF, 0x58D3) == 0xA72C); -} diff --git a/libcxx/test/utilities/function.objects/comparisons/equal_to.pass.cpp b/libcxx/test/utilities/function.objects/comparisons/equal_to.pass.cpp deleted file mode 100644 index 988e957e9823..000000000000 --- a/libcxx/test/utilities/function.objects/comparisons/equal_to.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// equal_to - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::equal_to<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(f(36, 36)); - assert(!f(36, 6)); -} diff --git a/libcxx/test/utilities/function.objects/comparisons/greater.pass.cpp b/libcxx/test/utilities/function.objects/comparisons/greater.pass.cpp deleted file mode 100644 index 2cadd6def367..000000000000 --- a/libcxx/test/utilities/function.objects/comparisons/greater.pass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// greater - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::greater<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(!f(36, 36)); - assert(f(36, 6)); - assert(!f(6, 36)); -} diff --git a/libcxx/test/utilities/function.objects/comparisons/greater_equal.pass.cpp b/libcxx/test/utilities/function.objects/comparisons/greater_equal.pass.cpp deleted file mode 100644 index 3ecadd416e0d..000000000000 --- a/libcxx/test/utilities/function.objects/comparisons/greater_equal.pass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// greater_equal - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::greater_equal<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(f(36, 36)); - assert(f(36, 6)); - assert(!f(6, 36)); -} diff --git a/libcxx/test/utilities/function.objects/comparisons/less.pass.cpp b/libcxx/test/utilities/function.objects/comparisons/less.pass.cpp deleted file mode 100644 index 0946bbfa6f7c..000000000000 --- a/libcxx/test/utilities/function.objects/comparisons/less.pass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// less - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::less<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(!f(36, 36)); - assert(!f(36, 6)); - assert(f(6, 36)); -} diff --git a/libcxx/test/utilities/function.objects/comparisons/less_equal.pass.cpp b/libcxx/test/utilities/function.objects/comparisons/less_equal.pass.cpp deleted file mode 100644 index 818af4a8f6de..000000000000 --- a/libcxx/test/utilities/function.objects/comparisons/less_equal.pass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// less_equal - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::less_equal<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(f(36, 36)); - assert(!f(36, 6)); - assert(f(6, 36)); -} diff --git a/libcxx/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/libcxx/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp deleted file mode 100644 index 0b8f8dda87a7..000000000000 --- a/libcxx/test/utilities/function.objects/comparisons/not_equal_to.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// not_equal_to - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::not_equal_to<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(!f(36, 36)); - assert(f(36, 6)); -} diff --git a/libcxx/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp b/libcxx/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b643..000000000000 --- a/libcxx/test/utilities/function.objects/func.def/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/function.objects/func.memfn/member_data.fail.cpp b/libcxx/test/utilities/function.objects/func.memfn/member_data.fail.cpp deleted file mode 100644 index 5e748c93b9e4..000000000000 --- a/libcxx/test/utilities/function.objects/func.memfn/member_data.fail.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<Returnable R, class T> unspecified mem_fn(R T::* pm); - -#include <functional> -#include <cassert> - -struct A -{ - double data_; -}; - -template <class F> -void -test(F f) -{ - { - A a; - f(a) = 5; - assert(a.data_ == 5); - A* ap = &a; - f(ap) = 6; - assert(a.data_ == 6); - const A* cap = ap; - assert(f(cap) == f(ap)); - f(cap) = 7; - } -} - -int main() -{ - test(std::mem_fn(&A::data_)); -} diff --git a/libcxx/test/utilities/function.objects/func.memfn/member_data.pass.cpp b/libcxx/test/utilities/function.objects/func.memfn/member_data.pass.cpp deleted file mode 100644 index 048fca4d96e5..000000000000 --- a/libcxx/test/utilities/function.objects/func.memfn/member_data.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<Returnable R, class T> unspecified mem_fn(R T::* pm); - -#include <functional> -#include <cassert> - -struct A -{ - double data_; -}; - -template <class F> -void -test(F f) -{ - { - A a; - f(a) = 5; - assert(a.data_ == 5); - A* ap = &a; - f(ap) = 6; - assert(a.data_ == 6); - const A* cap = ap; - assert(f(cap) == f(ap)); - } -} - -int main() -{ - test(std::mem_fn(&A::data_)); -} diff --git a/libcxx/test/utilities/function.objects/func.memfn/member_function.pass.cpp b/libcxx/test/utilities/function.objects/func.memfn/member_function.pass.cpp deleted file mode 100644 index 01a5f8e551ab..000000000000 --- a/libcxx/test/utilities/function.objects/func.memfn/member_function.pass.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<Returnable R, class T, CopyConstructible... Args> -// unspecified mem_fn(R (T::* pm)(Args...)); - -#include <functional> -#include <cassert> - -struct A -{ - char test0() {return 'a';} - char test1(int) {return 'b';} - char test2(int, double) {return 'c';} -}; - -template <class F> -void -test0(F f) -{ - { - A a; - assert(f(a) == 'a'); - A* ap = &a; - assert(f(ap) == 'a'); - } -} - -template <class F> -void -test1(F f) -{ - { - A a; - assert(f(a, 1) == 'b'); - A* ap = &a; - assert(f(ap, 2) == 'b'); - } -} - -template <class F> -void -test2(F f) -{ - { - A a; - assert(f(a, 1, 2) == 'c'); - A* ap = &a; - assert(f(ap, 2, 3.5) == 'c'); - } -} - -int main() -{ - test0(std::mem_fn(&A::test0)); - test1(std::mem_fn(&A::test1)); - test2(std::mem_fn(&A::test2)); -} diff --git a/libcxx/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp b/libcxx/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp deleted file mode 100644 index 978f9f094fb8..000000000000 --- a/libcxx/test/utilities/function.objects/func.memfn/member_function_const.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<Returnable R, class T, CopyConstructible... Args> -// unspecified mem_fn(R (T::* pm)(Args...) const); - -#include <functional> -#include <cassert> - -struct A -{ - char test0() const {return 'a';} - char test1(int) const {return 'b';} - char test2(int, double) const {return 'c';} -}; - -template <class F> -void -test0(F f) -{ - { - A a; - assert(f(a) == 'a'); - A* ap = &a; - assert(f(ap) == 'a'); - const A* cap = &a; - assert(f(cap) == 'a'); - } -} - -template <class F> -void -test1(F f) -{ - { - A a; - assert(f(a, 1) == 'b'); - A* ap = &a; - assert(f(ap, 2) == 'b'); - const A* cap = &a; - assert(f(cap, 2) == 'b'); - } -} - -template <class F> -void -test2(F f) -{ - { - A a; - assert(f(a, 1, 2) == 'c'); - A* ap = &a; - assert(f(ap, 2, 3.5) == 'c'); - const A* cap = &a; - assert(f(cap, 2, 3.5) == 'c'); - } -} - -int main() -{ - test0(std::mem_fn(&A::test0)); - test1(std::mem_fn(&A::test1)); - test2(std::mem_fn(&A::test2)); -} diff --git a/libcxx/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp b/libcxx/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp deleted file mode 100644 index 1e00b4d6b845..000000000000 --- a/libcxx/test/utilities/function.objects/func.memfn/member_function_const_volatile.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<Returnable R, class T, CopyConstructible... Args> -// unspecified mem_fn(R (T::* pm)(Args...) const volatile); - -#include <functional> -#include <cassert> - -struct A -{ - char test0() const volatile {return 'a';} - char test1(int) const volatile {return 'b';} - char test2(int, double) const volatile {return 'c';} -}; - -template <class F> -void -test0(F f) -{ - { - A a; - assert(f(a) == 'a'); - A* ap = &a; - assert(f(ap) == 'a'); - const volatile A* cap = &a; - assert(f(cap) == 'a'); - } -} - -template <class F> -void -test1(F f) -{ - { - A a; - assert(f(a, 1) == 'b'); - A* ap = &a; - assert(f(ap, 2) == 'b'); - const volatile A* cap = &a; - assert(f(cap, 2) == 'b'); - } -} - -template <class F> -void -test2(F f) -{ - { - A a; - assert(f(a, 1, 2) == 'c'); - A* ap = &a; - assert(f(ap, 2, 3.5) == 'c'); - const volatile A* cap = &a; - assert(f(cap, 2, 3.5) == 'c'); - } -} - -int main() -{ - test0(std::mem_fn(&A::test0)); - test1(std::mem_fn(&A::test1)); - test2(std::mem_fn(&A::test2)); -} diff --git a/libcxx/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp b/libcxx/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp deleted file mode 100644 index 4d0654a9f757..000000000000 --- a/libcxx/test/utilities/function.objects/func.memfn/member_function_volatile.pass.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<Returnable R, class T, CopyConstructible... Args> -// unspecified mem_fn(R (T::* pm)(Args...) volatile); - -#include <functional> -#include <cassert> - -struct A -{ - char test0() volatile {return 'a';} - char test1(int) volatile {return 'b';} - char test2(int, double) volatile {return 'c';} -}; - -template <class F> -void -test0(F f) -{ - { - A a; - assert(f(a) == 'a'); - A* ap = &a; - assert(f(ap) == 'a'); - volatile A* cap = &a; - assert(f(cap) == 'a'); - } -} - -template <class F> -void -test1(F f) -{ - { - A a; - assert(f(a, 1) == 'b'); - A* ap = &a; - assert(f(ap, 2) == 'b'); - volatile A* cap = &a; - assert(f(cap, 2) == 'b'); - } -} - -template <class F> -void -test2(F f) -{ - { - A a; - assert(f(a, 1, 2) == 'c'); - A* ap = &a; - assert(f(ap, 2, 3.5) == 'c'); - volatile A* cap = &a; - assert(f(cap, 2, 3.5) == 'c'); - } -} - -int main() -{ - test0(std::mem_fn(&A::test0)); - test1(std::mem_fn(&A::test1)); - test2(std::mem_fn(&A::test2)); -} diff --git a/libcxx/test/utilities/function.objects/func.require/binary_function.pass.cpp b/libcxx/test/utilities/function.objects/func.require/binary_function.pass.cpp deleted file mode 100644 index fa7afb2e7b9c..000000000000 --- a/libcxx/test/utilities/function.objects/func.require/binary_function.pass.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// binary_function - -#include <functional> -#include <type_traits> - -int main() -{ - typedef std::binary_function<int, short, bool> bf; - static_assert((std::is_same<bf::first_argument_type, int>::value), ""); - static_assert((std::is_same<bf::second_argument_type, short>::value), ""); - static_assert((std::is_same<bf::result_type, bool>::value), ""); -} diff --git a/libcxx/test/utilities/function.objects/func.require/unary_function.pass.cpp b/libcxx/test/utilities/function.objects/func.require/unary_function.pass.cpp deleted file mode 100644 index f14b2d3a2ce5..000000000000 --- a/libcxx/test/utilities/function.objects/func.require/unary_function.pass.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// unary_function - -#include <functional> -#include <type_traits> - -int main() -{ - typedef std::unary_function<int, bool> uf; - static_assert((std::is_same<uf::argument_type, int>::value), ""); - static_assert((std::is_same<uf::result_type, bool>::value), ""); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp deleted file mode 100644 index 357a3b48eae2..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp +++ /dev/null @@ -1,26 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// Class bad_function_call - -// class bad_function_call -// : public exception -// { -// public: -// // 20.7.16.1.1, constructor: -// bad_function_call(); -// }; - -#include <functional> -#include <type_traits> - -int main() -{ - static_assert((std::is_base_of<std::exception, std::bad_function_call>::value), ""); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp deleted file mode 100644 index f5ab9487532f..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.badcall/func.wrap.badcall.const/bad_function_call_ctor.pass.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -// Class bad_function_call - -// bad_function_call(); - -#include <functional> -#include <type_traits> - -int main() -{ - std::bad_function_call ex; -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp deleted file mode 100644 index 44252b4b94b1..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.alg/swap.pass.cpp +++ /dev/null @@ -1,135 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template <MoveConstructible R, MoveConstructible ... ArgTypes> -// void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&); - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -class A -{ - int data_[10]; -public: - static int count; - - explicit A(int j) - { - ++count; - data_[0] = j; - } - - A(const A& a) - { - ++count; - for (int i = 0; i < 10; ++i) - data_[i] = a.data_[i]; - } - - ~A() {--count;} - - int operator()(int i) const - { - for (int j = 0; j < 10; ++j) - i += data_[j]; - return i; - } - - int id() const {return data_[0];} -}; - -int A::count = 0; - -int g(int) {return 0;} -int h(int) {return 1;} - -int main() -{ - assert(new_called == 0); - { - std::function<int(int)> f1 = A(1); - std::function<int(int)> f2 = A(2); - assert(A::count == 2); - assert(new_called == 2); - assert(f1.target<A>()->id() == 1); - assert(f2.target<A>()->id() == 2); - swap(f1, f2); - assert(A::count == 2); - assert(new_called == 2); - assert(f1.target<A>()->id() == 2); - assert(f2.target<A>()->id() == 1); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f1 = A(1); - std::function<int(int)> f2 = g; - assert(A::count == 1); - assert(new_called == 1); - assert(f1.target<A>()->id() == 1); - assert(*f2.target<int(*)(int)>() == g); - swap(f1, f2); - assert(A::count == 1); - assert(new_called == 1); - assert(*f1.target<int(*)(int)>() == g); - assert(f2.target<A>()->id() == 1); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f1 = g; - std::function<int(int)> f2 = A(1); - assert(A::count == 1); - assert(new_called == 1); - assert(*f1.target<int(*)(int)>() == g); - assert(f2.target<A>()->id() == 1); - swap(f1, f2); - assert(A::count == 1); - assert(new_called == 1); - assert(f1.target<A>()->id() == 1); - assert(*f2.target<int(*)(int)>() == g); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f1 = g; - std::function<int(int)> f2 = h; - assert(A::count == 0); - assert(new_called == 0); - assert(*f1.target<int(*)(int)>() == g); - assert(*f2.target<int(*)(int)>() == h); - swap(f1, f2); - assert(A::count == 0); - assert(new_called == 0); - assert(*f1.target<int(*)(int)>() == h); - assert(*f2.target<int(*)(int)>() == g); - } - assert(A::count == 0); - assert(new_called == 0); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp deleted file mode 100644 index 829763f79d82..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.cap/operator_bool.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// explicit operator bool() const - -#include <functional> -#include <cassert> - -int g(int) {return 0;} - -int main() -{ - { - std::function<int(int)> f; - assert(!f); - f = g; - assert(f); - } -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp deleted file mode 100644 index 92f99cd6cd26..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// function(nullptr_t); - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -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 foo(int) const {return 1;} -}; - -int A::count = 0; - -int g(int) {return 0;} - -int main() -{ - assert(new_called == 0); - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f = g; - assert(new_called == 0); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - } - assert(new_called == 0); - { - std::function<int(int)> f = (int (*)(int))0; - assert(!f); - assert(new_called == 0); - assert(f.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - } - { - std::function<int(const A*, int)> f = &A::foo; - assert(f); - assert(new_called == 0); - assert(f.target<int (A::*)(int) const>() != 0); - } -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp deleted file mode 100644 index de16998481cf..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_assign.pass.cpp +++ /dev/null @@ -1,105 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template<class F> -// requires CopyConstructible<F> && Callable<F, ArgTypes..> -// && Convertible<Callable<F, ArgTypes...>::result_type -// operator=(F f); - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -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 foo(int) const {return 1;} -}; - -int A::count = 0; - -int g(int) {return 0;} - -int main() -{ - assert(new_called == 0); - { - std::function<int(int)> f; - f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f; - f = g; - assert(new_called == 0); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - } - assert(new_called == 0); - { - std::function<int(int)> f; - f = (int (*)(int))0; - assert(!f); - assert(new_called == 0); - assert(f.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - } - { - std::function<int(const A*, int)> f; - f = &A::foo; - assert(f); - assert(new_called == 0); - assert(f.target<int (A::*)(int) const>() != 0); - } -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp deleted file mode 100644 index ea8830b7581e..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template<class A> function(allocator_arg_t, const A&); - -#include <functional> -#include <cassert> - -#include "../test_allocator.h" - -int main() -{ - std::function<int(int)> f(std::allocator_arg, test_allocator<int>()); - assert(!f); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp deleted file mode 100644 index c027ebdb363a..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template<class F, class A> function(allocator_arg_t, const A&, F); - -#include <functional> -#include <cassert> - -#include "../test_allocator.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 foo(int) const {return 1;} -}; - -int A::count = 0; - -int g(int) {return 0;} - -int main() -{ - { - std::function<int(int)> f(std::allocator_arg, test_allocator<A>(), A()); - assert(A::count == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - } - assert(A::count == 0); - { - std::function<int(int)> f(std::allocator_arg, test_allocator<int(*)(int)>(), g); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - } - { - std::function<int(int)> f(std::allocator_arg, test_allocator<int(*)(int)>(), - (int (*)(int))0); - assert(!f); - assert(f.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - } - { - std::function<int(const A*, int)> f(std::allocator_arg, - test_allocator<int(A::*)(int)const>(), - &A::foo); - assert(f); - assert(f.target<int (A::*)(int) const>() != 0); - } -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp deleted file mode 100644 index d5364bf42837..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp +++ /dev/null @@ -1,104 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template<class A> function(allocator_arg_t, const A&, const function&); - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -#include "../test_allocator.h" - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -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() -{ - assert(new_called == 0); - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - std::function<int(int)> f2(std::allocator_arg, test_allocator<A>(), f); - assert(A::count == 2); - assert(new_called == 2); - assert(f2.target<A>()); - assert(f2.target<int(*)(int)>() == 0); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f = g; - assert(new_called == 0); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - std::function<int(int)> f2(std::allocator_arg, test_allocator<int(*)(int)>(), f); - assert(new_called == 0); - assert(f2.target<int(*)(int)>()); - assert(f2.target<A>() == 0); - } - assert(new_called == 0); - { - std::function<int(int)> f; - assert(new_called == 0); - assert(f.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - std::function<int(int)> f2(std::allocator_arg, test_allocator<int>(), f); - assert(new_called == 0); - assert(f2.target<int(*)(int)>() == 0); - assert(f2.target<A>() == 0); - } -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp deleted file mode 100644 index 89efeabe18b9..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template<class A> function(allocator_arg_t, const A&, nullptr_t); - -#include <functional> -#include <cassert> - -#include "../test_allocator.h" - -int main() -{ - std::function<int(int)> f(std::allocator_arg, test_allocator<int>(), nullptr); - assert(!f); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp deleted file mode 100644 index cafc6e449462..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp +++ /dev/null @@ -1,81 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template<class A> function(allocator_arg_t, const A&, function&&); - -#include <functional> -#include <cassert> - -#include "../test_allocator.h" - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -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 main() -{ -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(new_called == 0); - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - std::function<int(int)> f2(std::allocator_arg, test_allocator<A>(), std::move(f)); - assert(A::count == 1); - assert(new_called == 1); - assert(f2.target<A>()); - assert(f2.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - assert(f.target<int(*)(int)>() == 0); - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp deleted file mode 100644 index 0efb4d9ac257..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy.pass.cpp +++ /dev/null @@ -1,119 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// function(const function& f); - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -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() -{ - assert(new_called == 0); - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - std::function<int(int)> f2 = f; - assert(A::count == 2); - assert(new_called == 2); - assert(f2.target<A>()); - assert(f2.target<int(*)(int)>() == 0); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f = g; - assert(new_called == 0); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - std::function<int(int)> f2 = f; - assert(new_called == 0); - assert(f2.target<int(*)(int)>()); - assert(f2.target<A>() == 0); - } - assert(new_called == 0); - { - std::function<int(int)> f; - assert(new_called == 0); - assert(f.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - std::function<int(int)> f2 = f; - assert(new_called == 0); - assert(f2.target<int(*)(int)>() == 0); - assert(f2.target<A>() == 0); - } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(new_called == 0); - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - std::function<int(int)> f2 = std::move(f); - assert(A::count == 1); - assert(new_called == 1); - assert(f2.target<A>()); - assert(f2.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - assert(f.target<int(*)(int)>() == 0); - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp deleted file mode 100644 index 544ec439ba95..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/copy_assign.pass.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// function& operator=(const function& f); - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -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() -{ - assert(new_called == 0); - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - std::function<int(int)> f2; - f2 = f; - assert(A::count == 2); - assert(new_called == 2); - assert(f2.target<A>()); - assert(f2.target<int(*)(int)>() == 0); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f = g; - assert(new_called == 0); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - std::function<int(int)> f2; - f2 = f; - assert(new_called == 0); - assert(f2.target<int(*)(int)>()); - assert(f2.target<A>() == 0); - } - assert(new_called == 0); - { - std::function<int(int)> f; - assert(new_called == 0); - assert(f.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - std::function<int(int)> f2; - f2 = f; - assert(new_called == 0); - assert(f2.target<int(*)(int)>() == 0); - assert(f2.target<A>() == 0); - } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(new_called == 0); - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - std::function<int(int)> f2; - f2 = std::move(f); - assert(A::count == 1); - assert(new_called == 1); - assert(f2.target<A>()); - assert(f2.target<int(*)(int)>() == 0); - assert(f.target<A>() == 0); - assert(f.target<int(*)(int)>() == 0); - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp deleted file mode 100644 index 83d61b6b2d89..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/default.pass.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// explicit function(); - -#include <functional> -#include <cassert> - -int main() -{ - std::function<int(int)> f; - assert(!f); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp deleted file mode 100644 index f0d6402d185e..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t.pass.cpp +++ /dev/null @@ -1,23 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// function(nullptr_t); - -#include <functional> -#include <cassert> - -int main() -{ - std::function<int(int)> f(nullptr); - assert(!f); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp deleted file mode 100644 index 12a2b6e2d347..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/nullptr_t_assign.pass.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// function& operator=(nullptr_t); - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -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() -{ - assert(new_called == 0); - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(new_called == 1); - assert(f.target<A>()); - f = nullptr; - assert(A::count == 0); - assert(new_called == 0); - assert(f.target<A>() == 0); - } - { - std::function<int(int)> f = g; - assert(new_called == 0); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - f = nullptr; - assert(new_called == 0); - assert(f.target<int(*)(int)>() == 0); - } -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp deleted file mode 100644 index 6dcd2857452c..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// R operator()(ArgTypes... args) const - -#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); - } -} - -int main() -{ - test_int_1(); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp deleted file mode 100644 index 31b80c3323c1..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp +++ /dev/null @@ -1,335 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// R operator()(ArgTypes... args) const - -#include <functional> -#include <cassert> - -int count = 0; - -// 1 arg, return void - -void f_void_1(int i) -{ - count += i; -} - -struct A_void_1 -{ - void operator()(int i) - { - count += i; - } - - void mem1() {++count;} - void mem2() const {++count;} -}; - -void -test_void_1() -{ - int save_count = count; - // function - { - std::function<void (int)> r1(f_void_1); - int i = 2; - r1(i); - assert(count == save_count+2); - save_count = count; - } - // function pointer - { - void (*fp)(int) = f_void_1; - std::function<void (int)> r1(fp); - int i = 3; - r1(i); - assert(count == save_count+3); - save_count = count; - } - // functor - { - A_void_1 a0; - std::function<void (int)> r1(a0); - int i = 4; - r1(i); - assert(count == save_count+4); - save_count = count; - } - // member function pointer - { - void (A_void_1::*fp)() = &A_void_1::mem1; - std::function<void (A_void_1)> r1(fp); - A_void_1 a; - r1(a); - assert(count == save_count+1); - save_count = count; - A_void_1* ap = &a; - std::function<void (A_void_1*)> r2 = fp; - r2(ap); - assert(count == save_count+1); - save_count = count; - } - // const member function pointer - { - void (A_void_1::*fp)() const = &A_void_1::mem2; - std::function<void (A_void_1)> r1(fp); - A_void_1 a; - r1(a); - assert(count == save_count+1); - save_count = count; - std::function<void (A_void_1*)> r2(fp); - A_void_1* ap = &a; - r2(ap); - assert(count == save_count+1); - save_count = count; - } -} - -// 1 arg, return int - -int f_int_1(int i) -{ - return i + 1; -} - -struct A_int_1 -{ - A_int_1() : data_(5) {} - int operator()(int i) - { - return i - 1; - } - - int mem1() {return 3;} - int mem2() const {return 4;} - int data_; -}; - -void -test_int_1() -{ - // function - { - std::function<int (int)> r1(f_int_1); - int i = 2; - assert(r1(i) == 3); - } - // function pointer - { - int (*fp)(int) = f_int_1; - std::function<int (int)> r1(fp); - int i = 3; - assert(r1(i) == 4); - } - // functor - { - A_int_1 a0; - std::function<int (int)> r1(a0); - int i = 4; - assert(r1(i) == 3); - } - // member function pointer - { - int (A_int_1::*fp)() = &A_int_1::mem1; - std::function<int (A_int_1)> r1(fp); - A_int_1 a; - assert(r1(a) == 3); - std::function<int (A_int_1*)> r2(fp); - A_int_1* ap = &a; - assert(r2(ap) == 3); - } - // const member function pointer - { - int (A_int_1::*fp)() const = &A_int_1::mem2; - std::function<int (A_int_1)> r1(fp); - A_int_1 a; - assert(r1(a) == 4); - std::function<int (A_int_1*)> r2(fp); - A_int_1* ap = &a; - assert(r2(ap) == 4); - } - // member data pointer - { - int A_int_1::*fp = &A_int_1::data_; - std::function<int& (A_int_1&)> r1(fp); - A_int_1 a; - assert(r1(a) == 5); - r1(a) = 6; - assert(r1(a) == 6); - std::function<int& (A_int_1*)> r2(fp); - A_int_1* ap = &a; - assert(r2(ap) == 6); - r2(ap) = 7; - assert(r2(ap) == 7); - } -} - -// 2 arg, return void - -void f_void_2(int i, int j) -{ - count += i+j; -} - -struct A_void_2 -{ - void operator()(int i, int j) - { - count += i+j; - } - - void mem1(int i) {count += i;} - void mem2(int i) const {count += i;} -}; - -void -test_void_2() -{ - int save_count = count; - // function - { - std::function<void (int, int)> r1(f_void_2); - int i = 2; - int j = 3; - r1(i, j); - assert(count == save_count+5); - save_count = count; - } - // function pointer - { - void (*fp)(int, int) = f_void_2; - std::function<void (int, int)> r1(fp); - int i = 3; - int j = 4; - r1(i, j); - assert(count == save_count+7); - save_count = count; - } - // functor - { - A_void_2 a0; - std::function<void (int, int)> r1(a0); - int i = 4; - int j = 5; - r1(i, j); - assert(count == save_count+9); - save_count = count; - } - // member function pointer - { - void (A_void_2::*fp)(int) = &A_void_2::mem1; - std::function<void (A_void_2, int)> r1(fp); - A_void_2 a; - int i = 3; - r1(a, i); - assert(count == save_count+3); - save_count = count; - std::function<void (A_void_2*, int)> r2(fp); - A_void_2* ap = &a; - r2(ap, i); - assert(count == save_count+3); - save_count = count; - } - // const member function pointer - { - void (A_void_2::*fp)(int) const = &A_void_2::mem2; - std::function<void (A_void_2, int)> r1(fp); - A_void_2 a; - int i = 4; - r1(a, i); - assert(count == save_count+4); - save_count = count; - std::function<void (A_void_2*, int)> r2(fp); - A_void_2* ap = &a; - r2(ap, i); - assert(count == save_count+4); - save_count = count; - } -} - -// 2 arg, return int - -int f_int_2(int i, int j) -{ - return i+j; -} - -struct A_int_2 -{ - int operator()(int i, int j) - { - return i+j; - } - - int mem1(int i) {return i+1;} - int mem2(int i) const {return i+2;} -}; - -void -testint_2() -{ - // function - { - std::function<int (int, int)> r1(f_int_2); - int i = 2; - int j = 3; - assert(r1(i, j) == i+j); - } - // function pointer - { - int (*fp)(int, int) = f_int_2; - std::function<int (int, int)> r1(fp); - int i = 3; - int j = 4; - assert(r1(i, j) == i+j); - } - // functor - { - A_int_2 a0; - std::function<int (int, int)> r1(a0); - int i = 4; - int j = 5; - assert(r1(i, j) == i+j); - } - // member function pointer - { - int(A_int_2::*fp)(int) = &A_int_2::mem1; - std::function<int (A_int_2, int)> r1(fp); - A_int_2 a; - int i = 3; - assert(r1(a, i) == i+1); - std::function<int (A_int_2*, int)> r2(fp); - A_int_2* ap = &a; - assert(r2(ap, i) == i+1); - } - // const member function pointer - { - int (A_int_2::*fp)(int) const = &A_int_2::mem2; - std::function<int (A_int_2, int)> r1(fp); - A_int_2 a; - int i = 4; - assert(r1(a, i) == i+2); - std::function<int (A_int_2*, int)> r2(fp); - A_int_2* ap = &a; - assert(r2(ap, i) == i+2); - } -} - -int main() -{ - test_void_1(); - test_int_1(); - test_void_2(); - testint_2(); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp deleted file mode 100644 index 67b4ec22da8c..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// R operator()(ArgTypes... args) const - -#include <functional> -#include <cassert> - -// 0 args, return int - -int count = 0; - -int f_int_0() -{ - return 3; -} - -struct A_int_0 -{ - int operator()() {return 4;} -}; - -void -test_int_0() -{ - // function - { - std::function<int ()> r1(f_int_0); - assert(r1() == 3); - } - // function pointer - { - int (*fp)() = f_int_0; - std::function<int ()> r1(fp); - assert(r1() == 3); - } - // functor - { - A_int_0 a0; - std::function<int ()> r1(a0); - assert(r1() == 4); - } -} - -int main() -{ - test_int_0(); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp deleted file mode 100644 index a820cb1b8f38..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// R operator()(ArgTypes... args) const - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -// 0 args, return void - -int count = 0; - -void f_void_0() -{ - ++count; -} - -struct A_void_0 -{ - void operator()() {++count;} -}; - -void -test_void_0() -{ - int save_count = count; - // function - { - std::function<void ()> r1(f_void_0); - r1(); - assert(count == save_count+1); - save_count = count; - } - // function pointer - { - void (*fp)() = f_void_0; - std::function<void ()> r1(fp); - r1(); - assert(count == save_count+1); - save_count = count; - } - // functor - { - A_void_0 a0; - std::function<void ()> r1(a0); - r1(); - assert(count == save_count+1); - save_count = count; - } -} - -int main() -{ - test_void_0(); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp deleted file mode 100644 index ae6498b9e36c..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/assign_F_alloc.pass.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template<class F, class A> void assign(F&&, const A&); - -#include <functional> -#include <cassert> - -#include "../test_allocator.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 foo(int) const {return 1;} -}; - -int A::count = 0; - -int main() -{ - { - std::function<int(int)> f; - f.assign(A(), test_allocator<A>()); - assert(A::count == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp deleted file mode 100644 index dc56574a2888..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.mod/swap.pass.cpp +++ /dev/null @@ -1,134 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// void swap(function& other); - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -class A -{ - int data_[10]; -public: - static int count; - - explicit A(int j) - { - ++count; - data_[0] = j; - } - - A(const A& a) - { - ++count; - for (int i = 0; i < 10; ++i) - data_[i] = a.data_[i]; - } - - ~A() {--count;} - - int operator()(int i) const - { - for (int j = 0; j < 10; ++j) - i += data_[j]; - return i; - } - - int id() const {return data_[0];} -}; - -int A::count = 0; - -int g(int) {return 0;} -int h(int) {return 1;} - -int main() -{ - assert(new_called == 0); - { - std::function<int(int)> f1 = A(1); - std::function<int(int)> f2 = A(2); - assert(A::count == 2); - assert(new_called == 2); - assert(f1.target<A>()->id() == 1); - assert(f2.target<A>()->id() == 2); - f1.swap(f2); - assert(A::count == 2); - assert(new_called == 2); - assert(f1.target<A>()->id() == 2); - assert(f2.target<A>()->id() == 1); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f1 = A(1); - std::function<int(int)> f2 = g; - assert(A::count == 1); - assert(new_called == 1); - assert(f1.target<A>()->id() == 1); - assert(*f2.target<int(*)(int)>() == g); - f1.swap(f2); - assert(A::count == 1); - assert(new_called == 1); - assert(*f1.target<int(*)(int)>() == g); - assert(f2.target<A>()->id() == 1); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f1 = g; - std::function<int(int)> f2 = A(1); - assert(A::count == 1); - assert(new_called == 1); - assert(*f1.target<int(*)(int)>() == g); - assert(f2.target<A>()->id() == 1); - f1.swap(f2); - assert(A::count == 1); - assert(new_called == 1); - assert(f1.target<A>()->id() == 1); - assert(*f2.target<int(*)(int)>() == g); - } - assert(A::count == 0); - assert(new_called == 0); - { - std::function<int(int)> f1 = g; - std::function<int(int)> f2 = h; - assert(A::count == 0); - assert(new_called == 0); - assert(*f1.target<int(*)(int)>() == g); - assert(*f2.target<int(*)(int)>() == h); - f1.swap(f2); - assert(A::count == 0); - assert(new_called == 0); - assert(*f1.target<int(*)(int)>() == h); - assert(*f2.target<int(*)(int)>() == g); - } - assert(A::count == 0); - assert(new_called == 0); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp deleted file mode 100644 index 5bca0968702c..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.nullptr/operator_==.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template <MoveConstructible R, MoveConstructible ... ArgTypes> -// bool operator==(const function<R(ArgTypes...)>&, nullptr_t); -// -// template <MoveConstructible R, MoveConstructible ... ArgTypes> -// bool operator==(nullptr_t, const function<R(ArgTypes...)>&); -// -// template <MoveConstructible R, MoveConstructible ... ArgTypes> -// bool operator!=(const function<R(ArgTypes...)>&, nullptr_t); -// -// template <MoveConstructible R, MoveConstructible ... ArgTypes> -// bool operator!=(nullptr_t, const function<R(ArgTypes...)>&); - -#include <functional> -#include <cassert> - -int g(int) {return 0;} - -int main() -{ - { - std::function<int(int)> f; - assert(f == nullptr); - assert(nullptr == f); - f = g; - assert(f != nullptr); - assert(nullptr != f); - } -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp deleted file mode 100644 index 53476a274735..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target.pass.cpp +++ /dev/null @@ -1,89 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// template<typename T> -// requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R> -// T* -// target(); -// template<typename T> -// requires Callable<T, ArgTypes...> && Convertible<Callable<T, ArgTypes...>::result_type, R> -// const T* -// target() const; - -#include <functional> -#include <new> -#include <cstdlib> -#include <cassert> - -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 foo(int) const {return 1;} -}; - -int A::count = 0; - -int g(int) {return 0;} - -int main() -{ - { - std::function<int(int)> f = A(); - assert(A::count == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - } - assert(A::count == 0); - { - std::function<int(int)> f = g; - assert(A::count == 0); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - } - assert(A::count == 0); - { - const std::function<int(int)> f = A(); - assert(A::count == 1); - assert(f.target<A>()); - assert(f.target<int(*)(int)>() == 0); - } - assert(A::count == 0); - { - const std::function<int(int)> f = g; - assert(A::count == 0); - assert(f.target<int(*)(int)>()); - assert(f.target<A>() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp deleted file mode 100644 index 7605e3bf666e..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.targ/target_type.pass.cpp +++ /dev/null @@ -1,61 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// class function<R(ArgTypes...)> - -// const std::type_info& target_type() const; - -#include <functional> -#include <typeinfo> -#include <cassert> - -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 foo(int) const {return 1;} -}; - -int A::count = 0; - -int g(int) {return 0;} - -int main() -{ - { - std::function<int(int)> f = A(); - assert(f.target_type() == typeid(A)); - } - { - std::function<int(int)> f; - assert(f.target_type() == typeid(void)); - } -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h deleted file mode 100644 index c5da7e6390d7..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/test_allocator.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef TEST_ALLOCATOR_H -#define TEST_ALLOCATOR_H - -#include <cstddef> -#include <type_traits> -#include <cstdlib> -#include <new> -#include <climits> - -class test_alloc_base -{ -protected: - static int count; -public: - static int throw_after; -}; - -int test_alloc_base::count = 0; -int test_alloc_base::throw_after = INT_MAX; - -template <class T> -class test_allocator - : public test_alloc_base -{ - int data_; - - template <class U> friend class test_allocator; -public: - - typedef unsigned size_type; - typedef int difference_type; - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef typename std::add_lvalue_reference<value_type>::type reference; - typedef typename std::add_lvalue_reference<const value_type>::type const_reference; - - template <class U> struct rebind {typedef test_allocator<U> other;}; - - test_allocator() throw() : data_(-1) {} - explicit test_allocator(int i) throw() : data_(i) {} - test_allocator(const test_allocator& a) throw() - : data_(a.data_) {} - template <class U> test_allocator(const test_allocator<U>& a) throw() - : data_(a.data_) {} - ~test_allocator() throw() {data_ = 0;} - pointer address(reference x) const {return &x;} - const_pointer address(const_reference x) const {return &x;} - pointer allocate(size_type n, const void* = 0) - { - if (count >= throw_after) - throw std::bad_alloc(); - ++count; - return (pointer)std::malloc(n * sizeof(T)); - } - void deallocate(pointer p, size_type n) - {std::free(p);} - size_type max_size() const throw() - {return UINT_MAX / sizeof(T);} - void construct(pointer p, const T& val) - {::new(p) T(val);} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - void construct(pointer p, T&& val) - {::new(p) T(std::move(val));} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - void destroy(pointer p) {p->~T();} - - friend bool operator==(const test_allocator& x, const test_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const test_allocator& x, const test_allocator& y) - {return !(x == y);} -}; - -template <class T> -class other_allocator -{ - int data_; - - template <class U> friend class other_allocator; - -public: - typedef T value_type; - - other_allocator() : data_(-1) {} - explicit other_allocator(int i) : data_(i) {} - template <class U> other_allocator(const other_allocator<U>& a) - : data_(a.data_) {} - T* allocate(std::size_t n) - {return (T*)std::malloc(n * sizeof(T));} - void deallocate(T* p, std::size_t n) - {std::free(p);} - - other_allocator select_on_container_copy_construction() const - {return other_allocator(-2);} - - friend bool operator==(const other_allocator& x, const other_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const other_allocator& x, const other_allocator& y) - {return !(x == y);} - - typedef std::true_type propagate_on_container_copy_assignment; - typedef std::true_type propagate_on_container_move_assignment; - typedef std::true_type propagate_on_container_swap; - -#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE - std::size_t max_size() const - {return UINT_MAX / sizeof(T);} -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE - -}; - -#endif // TEST_ALLOCATOR_H diff --git a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp deleted file mode 100644 index 6c70db408103..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/func.wrap.func/types.pass.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template<Returnable R, CopyConstructible... ArgTypes> -// class function<R(ArgTypes...)> -// : public unary_function<T1, R> // iff sizeof...(ArgTypes) == 1 and -// // ArgTypes contains T1 -// : public binary_function<T1, T2, R> // iff sizeof...(ArgTypes) == 2 and -// // ArgTypes contains T1 and T2 -// { -// public: -// typedef R result_type; -// ... -// }; - -#include <functional> -#include <type_traits> - -int main() -{ - static_assert((!std::is_base_of<std::unary_function <int, int>, - std::function<int()> >::value), ""); - static_assert((!std::is_base_of<std::binary_function<int, int, int>, - std::function<int()> >::value), ""); - static_assert(( std::is_same< std::function<int()>::result_type, - int>::value), ""); - - static_assert(( std::is_base_of<std::unary_function <int, double>, - std::function<double(int)> >::value), ""); - static_assert((!std::is_base_of<std::binary_function<int, int, double>, - std::function<double(int)> >::value), ""); - static_assert(( std::is_same< std::function<double(int)>::result_type, - double>::value), ""); - - static_assert((!std::is_base_of<std::unary_function <int, double>, - std::function<double(int, char)> >::value), ""); - static_assert(( std::is_base_of<std::binary_function<int, char, double>, - std::function<double(int, char)> >::value), ""); - static_assert(( std::is_same< std::function<double(int, char)>::result_type, - double>::value), ""); -} diff --git a/libcxx/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp b/libcxx/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b643..000000000000 --- a/libcxx/test/utilities/function.objects/func.wrap/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/function.objects/logical.operations/logical_and.pass.cpp b/libcxx/test/utilities/function.objects/logical.operations/logical_and.pass.cpp deleted file mode 100644 index 914eb4c67a11..000000000000 --- a/libcxx/test/utilities/function.objects/logical.operations/logical_and.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// logical_and - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::logical_and<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(f(36, 36)); - assert(!f(36, 0)); - assert(!f(0, 36)); - assert(!f(0, 0)); -} diff --git a/libcxx/test/utilities/function.objects/logical.operations/logical_not.pass.cpp b/libcxx/test/utilities/function.objects/logical.operations/logical_not.pass.cpp deleted file mode 100644 index 289c9241bd36..000000000000 --- a/libcxx/test/utilities/function.objects/logical.operations/logical_not.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// logical_not - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::logical_not<int> F; - const F f = F(); - static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), ""); - assert(!f(36)); - assert(f(0)); -} diff --git a/libcxx/test/utilities/function.objects/logical.operations/logical_or.pass.cpp b/libcxx/test/utilities/function.objects/logical.operations/logical_or.pass.cpp deleted file mode 100644 index 0cf217fc6493..000000000000 --- a/libcxx/test/utilities/function.objects/logical.operations/logical_or.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// logical_or - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::logical_or<int> F; - const F f = F(); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(f(36, 36)); - assert(f(36, 0)); - assert(f(0, 36)); - assert(!f(0, 0)); -} diff --git a/libcxx/test/utilities/function.objects/negators/binary_negate.pass.cpp b/libcxx/test/utilities/function.objects/negators/binary_negate.pass.cpp deleted file mode 100644 index e30670836c5a..000000000000 --- a/libcxx/test/utilities/function.objects/negators/binary_negate.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// binary_negate - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::binary_negate<std::logical_and<int> > F; - const F f = F(std::logical_and<int>()); - static_assert((std::is_base_of<std::binary_function<int, int, bool>, F>::value), ""); - assert(!f(36, 36)); - assert( f(36, 0)); - assert( f(0, 36)); - assert( f(0, 0)); -} diff --git a/libcxx/test/utilities/function.objects/negators/not1.pass.cpp b/libcxx/test/utilities/function.objects/negators/not1.pass.cpp deleted file mode 100644 index f6ac7a49dc00..000000000000 --- a/libcxx/test/utilities/function.objects/negators/not1.pass.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// not1 - -#include <functional> -#include <cassert> - -int main() -{ - typedef std::logical_not<int> F; - assert(std::not1(F())(36)); - assert(!std::not1(F())(0)); -} diff --git a/libcxx/test/utilities/function.objects/negators/not2.pass.cpp b/libcxx/test/utilities/function.objects/negators/not2.pass.cpp deleted file mode 100644 index 7541753d568e..000000000000 --- a/libcxx/test/utilities/function.objects/negators/not2.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// not2 - -#include <functional> -#include <cassert> - -int main() -{ - typedef std::logical_and<int> F; - assert(!std::not2(F())(36, 36)); - assert( std::not2(F())(36, 0)); - assert( std::not2(F())(0, 36)); - assert( std::not2(F())(0, 0)); -} diff --git a/libcxx/test/utilities/function.objects/negators/unary_negate.pass.cpp b/libcxx/test/utilities/function.objects/negators/unary_negate.pass.cpp deleted file mode 100644 index 2aa4f0ab4480..000000000000 --- a/libcxx/test/utilities/function.objects/negators/unary_negate.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// unary_negate - -#include <functional> -#include <type_traits> -#include <cassert> - -int main() -{ - typedef std::unary_negate<std::logical_not<int> > F; - const F f = F(std::logical_not<int>()); - static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), ""); - assert(f(36)); - assert(!f(0)); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/binary.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/binary.pass.cpp deleted file mode 100644 index 579e81fe69e6..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/binary.pass.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// check for deriving from binary_function - -#include <functional> -#include <type_traits> - -class functor1 - : public std::unary_function<int, char> -{ -}; - -class functor2 - : public std::binary_function<char, int, double> -{ -}; - -class functor3 - : public std::unary_function<int, int>, - public std::binary_function<char, int, double> -{ -public: - typedef float result_type; -}; - -class functor4 - : public std::unary_function<int, int>, - public std::binary_function<char, int, double> -{ -public: -}; - -struct C -{ - typedef int argument_type; - typedef int result_type; -}; - -int main() -{ - static_assert((!std::is_base_of<std::binary_function<int, char, int>, - std::reference_wrapper<functor1> >::value), ""); - static_assert((std::is_base_of<std::binary_function<char, int, double>, - std::reference_wrapper<functor2> >::value), ""); - static_assert((std::is_base_of<std::binary_function<char, int, double>, - std::reference_wrapper<functor3> >::value), ""); - static_assert((std::is_base_of<std::binary_function<char, int, double>, - std::reference_wrapper<functor4> >::value), ""); - static_assert((!std::is_base_of<std::binary_function<int, int, int>, - std::reference_wrapper<C> >::value), ""); - static_assert((!std::is_base_of<std::binary_function<int, int, float>, - std::reference_wrapper<float ()> >::value), ""); - static_assert((!std::is_base_of<std::binary_function<int, int, float>, - std::reference_wrapper<float (int)> >::value), ""); - static_assert((std::is_base_of<std::binary_function<int, int, float>, - std::reference_wrapper<float (int, int)> >::value), ""); - static_assert((!std::is_base_of<std::binary_function<int, int, float>, - std::reference_wrapper<float(*)()> >::value), ""); - static_assert((!std::is_base_of<std::binary_function<int, int, float>, - std::reference_wrapper<float(*)(int)> >::value), ""); - static_assert((std::is_base_of<std::binary_function<int, int, float>, - std::reference_wrapper<float(*)(int, int)> >::value), ""); - static_assert((!std::is_base_of<std::binary_function<C*, int, float>, - std::reference_wrapper<float(C::*)()> >::value), ""); - static_assert((std::is_base_of<std::binary_function<C*, int, float>, - std::reference_wrapper<float(C::*)(int)> >::value), ""); - static_assert((std::is_base_of<std::binary_function<const volatile C*, int, float>, - std::reference_wrapper<float(C::*)(int) const volatile> >::value), ""); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp deleted file mode 100644 index df0b55a5d060..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// operator T& () const; - -#include <functional> -#include <cassert> - -class functor1 - : public std::unary_function<int, char> -{ -}; - -template <class T> -void -test(T& t) -{ - std::reference_wrapper<T> r(t); - T& r2 = r; - assert(&r2 == &t); -} - -void f() {} - -int main() -{ - void (*fp)() = f; - test(fp); - test(f); - functor1 f1; - test(f1); - int i = 0; - test(i); - const int j = 0; - test(j); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp deleted file mode 100644 index 122716a23a8b..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// reference_wrapper& operator=(const reference_wrapper<T>& x); - -#include <functional> -#include <cassert> - -class functor1 - : public std::unary_function<int, char> -{ -}; - -template <class T> -void -test(T& t) -{ - std::reference_wrapper<T> r(t); - T t2 = t; - std::reference_wrapper<T> r2(t2); - r2 = r; - assert(&r2.get() == &t); -} - -void f() {} -void g() {} - -void -test_function() -{ - std::reference_wrapper<void ()> r(f); - std::reference_wrapper<void ()> r2(g); - r2 = r; - assert(&r2.get() == &f); -} - -int main() -{ - void (*fp)() = f; - test(fp); - test_function(); - functor1 f1; - test(f1); - int i = 0; - test(i); - const int j = 0; - test(j); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp deleted file mode 100644 index 721a442d4431..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// reference_wrapper(const reference_wrapper<T>& x); - -#include <functional> -#include <cassert> - -class functor1 - : public std::unary_function<int, char> -{ -}; - -template <class T> -void -test(T& t) -{ - std::reference_wrapper<T> r(t); - std::reference_wrapper<T> r2 = r; - assert(&r2.get() == &t); -} - -void f() {} - -int main() -{ - void (*fp)() = f; - test(fp); - test(f); - functor1 f1; - test(f1); - int i = 0; - test(i); - const int j = 0; - test(j); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp deleted file mode 100644 index ba46946aae1b..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// reference_wrapper(T&&) = delete; - -#include <functional> -#include <cassert> - -int main() -{ - std::reference_wrapper<const int> r(3); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp deleted file mode 100644 index 564a3f77433c..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp +++ /dev/null @@ -1,45 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// reference_wrapper(T& t); - -#include <functional> -#include <cassert> - -class functor1 - : public std::unary_function<int, char> -{ -}; - -template <class T> -void -test(T& t) -{ - std::reference_wrapper<T> r(t); - assert(&r.get() == &t); -} - -void f() {} - -int main() -{ - void (*fp)() = f; - test(fp); - test(f); - functor1 f1; - test(f1); - int i = 0; - test(i); - const int j = 0; - test(j); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp deleted file mode 100644 index f2ffd44e26b7..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/cref_1.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <ObjectType T> reference_wrapper<const T> cref(const T& t); - -#include <functional> -#include <cassert> - -int main() -{ - int i = 0; - std::reference_wrapper<const int> r = std::cref(i); - assert(&r.get() == &i); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp deleted file mode 100644 index 75875264479a..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/cref_2.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <ObjectType T> reference_wrapper<const T> cref(reference_wrapper<T> t); - -#include <functional> -#include <cassert> - -int main() -{ - const int i = 0; - std::reference_wrapper<const int> r1 = std::cref(i); - std::reference_wrapper<const int> r2 = std::cref(r1); - assert(&r2.get() == &i); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp deleted file mode 100644 index 86a5696f48ca..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <ObjectType T> reference_wrapper<T> ref(T& t); - -// Don't allow binding to a temp - -#include <functional> - -struct A {}; - -const A source() {return A();} - -int main() -{ - std::reference_wrapper<const A> r = std::ref(source()); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp deleted file mode 100644 index 39aa4843a710..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_1.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <ObjectType T> reference_wrapper<T> ref(T& t); - -#include <functional> -#include <cassert> - -int main() -{ - int i = 0; - std::reference_wrapper<int> r = std::ref(i); - assert(&r.get() == &i); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp deleted file mode 100644 index 1eb92aa42c21..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.helpers/ref_2.pass.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <ObjectType T> reference_wrapper<T> ref(reference_wrapper<T>t); - -#include <functional> -#include <cassert> - -int main() -{ - int i = 0; - std::reference_wrapper<int> r1 = std::ref(i); - std::reference_wrapper<int> r2 = std::ref(r1); - assert(&r2.get() == &i); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp deleted file mode 100644 index 551562721e3e..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.fail.cpp +++ /dev/null @@ -1,52 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <class... ArgTypes> -// requires Callable<T, ArgTypes&&...> -// Callable<T, ArgTypes&&...>::result_type -// operator()(ArgTypes&&... args) const; - -#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_; - std::reference_wrapper<int A_int_1::*> r1(fp); - A_int_1 a; - assert(r1(a) == 5); - r1(a) = 6; - assert(r1(a) == 6); - const A_int_1* ap = &a; - assert(r1(ap) == 6); - r1(ap) = 7; - assert(r1(ap) == 7); - } -} - -int main() -{ - test_int_1(); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp deleted file mode 100644 index a9edf00ee592..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke.pass.cpp +++ /dev/null @@ -1,329 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <class... ArgTypes> -// requires Callable<T, ArgTypes&&...> -// Callable<T, ArgTypes&&...>::result_type -// operator()(ArgTypes&&... args) const; - -#include <functional> -#include <cassert> - -int count = 0; - -// 1 arg, return void - -void f_void_1(int i) -{ - count += i; -} - -struct A_void_1 -{ - void operator()(int i) - { - count += i; - } - - void mem1() {++count;} - void mem2() const {++count;} -}; - -void -test_void_1() -{ - int save_count = count; - // function - { - std::reference_wrapper<void (int)> r1(f_void_1); - int i = 2; - r1(i); - assert(count == save_count+2); - save_count = count; - } - // function pointer - { - void (*fp)(int) = f_void_1; - std::reference_wrapper<void (*)(int)> r1(fp); - int i = 3; - r1(i); - assert(count == save_count+3); - save_count = count; - } - // functor - { - A_void_1 a0; - std::reference_wrapper<A_void_1> r1(a0); - int i = 4; - r1(i); - assert(count == save_count+4); - save_count = count; - } - // member function pointer - { - void (A_void_1::*fp)() = &A_void_1::mem1; - std::reference_wrapper<void (A_void_1::*)()> r1(fp); - A_void_1 a; - r1(a); - assert(count == save_count+1); - save_count = count; - A_void_1* ap = &a; - r1(ap); - assert(count == save_count+1); - save_count = count; - } - // const member function pointer - { - void (A_void_1::*fp)() const = &A_void_1::mem2; - std::reference_wrapper<void (A_void_1::*)() const> r1(fp); - A_void_1 a; - r1(a); - assert(count == save_count+1); - save_count = count; - A_void_1* ap = &a; - r1(ap); - assert(count == save_count+1); - save_count = count; - } -} - -// 1 arg, return int - -int f_int_1(int i) -{ - return i + 1; -} - -struct A_int_1 -{ - A_int_1() : data_(5) {} - int operator()(int i) - { - return i - 1; - } - - int mem1() {return 3;} - int mem2() const {return 4;} - int data_; -}; - -void -test_int_1() -{ - // function - { - std::reference_wrapper<int (int)> r1(f_int_1); - int i = 2; - assert(r1(i) == 3); - } - // function pointer - { - int (*fp)(int) = f_int_1; - std::reference_wrapper<int (*)(int)> r1(fp); - int i = 3; - assert(r1(i) == 4); - } - // functor - { - A_int_1 a0; - std::reference_wrapper<A_int_1> r1(a0); - int i = 4; - assert(r1(i) == 3); - } - // member function pointer - { - int (A_int_1::*fp)() = &A_int_1::mem1; - std::reference_wrapper<int (A_int_1::*)()> r1(fp); - A_int_1 a; - assert(r1(a) == 3); - A_int_1* ap = &a; - assert(r1(ap) == 3); - } - // const member function pointer - { - int (A_int_1::*fp)() const = &A_int_1::mem2; - std::reference_wrapper<int (A_int_1::*)() const> r1(fp); - A_int_1 a; - assert(r1(a) == 4); - A_int_1* ap = &a; - assert(r1(ap) == 4); - } - // member data pointer - { - int A_int_1::*fp = &A_int_1::data_; - std::reference_wrapper<int A_int_1::*> r1(fp); - A_int_1 a; - assert(r1(a) == 5); - r1(a) = 6; - assert(r1(a) == 6); - A_int_1* ap = &a; - assert(r1(ap) == 6); - r1(ap) = 7; - assert(r1(ap) == 7); - } -} - -// 2 arg, return void - -void f_void_2(int i, int j) -{ - count += i+j; -} - -struct A_void_2 -{ - void operator()(int i, int j) - { - count += i+j; - } - - void mem1(int i) {count += i;} - void mem2(int i) const {count += i;} -}; - -void -test_void_2() -{ - int save_count = count; - // function - { - std::reference_wrapper<void (int, int)> r1(f_void_2); - int i = 2; - int j = 3; - r1(i, j); - assert(count == save_count+5); - save_count = count; - } - // function pointer - { - void (*fp)(int, int) = f_void_2; - std::reference_wrapper<void (*)(int, int)> r1(fp); - int i = 3; - int j = 4; - r1(i, j); - assert(count == save_count+7); - save_count = count; - } - // functor - { - A_void_2 a0; - std::reference_wrapper<A_void_2> r1(a0); - int i = 4; - int j = 5; - r1(i, j); - assert(count == save_count+9); - save_count = count; - } - // member function pointer - { - void (A_void_2::*fp)(int) = &A_void_2::mem1; - std::reference_wrapper<void (A_void_2::*)(int)> r1(fp); - A_void_2 a; - int i = 3; - r1(a, i); - assert(count == save_count+3); - save_count = count; - A_void_2* ap = &a; - r1(ap, i); - assert(count == save_count+3); - save_count = count; - } - // const member function pointer - { - void (A_void_2::*fp)(int) const = &A_void_2::mem2; - std::reference_wrapper<void (A_void_2::*)(int) const> r1(fp); - A_void_2 a; - int i = 4; - r1(a, i); - assert(count == save_count+4); - save_count = count; - A_void_2* ap = &a; - r1(ap, i); - assert(count == save_count+4); - save_count = count; - } -} - -// 2 arg, return int - -int f_int_2(int i, int j) -{ - return i+j; -} - -struct A_int_2 -{ - int operator()(int i, int j) - { - return i+j; - } - - int mem1(int i) {return i+1;} - int mem2(int i) const {return i+2;} -}; - -void -testint_2() -{ - // function - { - std::reference_wrapper<int (int, int)> r1(f_int_2); - int i = 2; - int j = 3; - assert(r1(i, j) == i+j); - } - // function pointer - { - int (*fp)(int, int) = f_int_2; - std::reference_wrapper<int (*)(int, int)> r1(fp); - int i = 3; - int j = 4; - assert(r1(i, j) == i+j); - } - // functor - { - A_int_2 a0; - std::reference_wrapper<A_int_2> r1(a0); - int i = 4; - int j = 5; - assert(r1(i, j) == i+j); - } - // member function pointer - { - int(A_int_2::*fp)(int) = &A_int_2::mem1; - std::reference_wrapper<int (A_int_2::*)(int)> r1(fp); - A_int_2 a; - int i = 3; - assert(r1(a, i) == i+1); - A_int_2* ap = &a; - assert(r1(ap, i) == i+1); - } - // const member function pointer - { - int (A_int_2::*fp)(int) const = &A_int_2::mem2; - std::reference_wrapper<int (A_int_2::*)(int) const> r1(fp); - A_int_2 a; - int i = 4; - assert(r1(a, i) == i+2); - A_int_2* ap = &a; - assert(r1(ap, i) == i+2); - } -} - -int main() -{ - test_void_1(); - test_int_1(); - test_void_2(); - testint_2(); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp deleted file mode 100644 index 61357a7fa394..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_int_0.pass.cpp +++ /dev/null @@ -1,76 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <class... ArgTypes> -// requires Callable<T, ArgTypes&&...> -// Callable<T, ArgTypes&&...>::result_type -// operator()(ArgTypes&&... args) const; - -#include <functional> -#include <cassert> - -// 0 args, return int - -int count = 0; - -int f_int_0() -{ - return 3; -} - -struct A_int_0 -{ - int operator()() {return 4;} -}; - -void -test_int_0() -{ - // function - { - std::reference_wrapper<int ()> r1(f_int_0); - assert(r1() == 3); - } - // function pointer - { - int (*fp)() = f_int_0; - std::reference_wrapper<int (*)()> r1(fp); - assert(r1() == 3); - } - // functor - { - A_int_0 a0; - std::reference_wrapper<A_int_0> r1(a0); - assert(r1() == 4); - } -} - -// 1 arg, return void - -void f_void_1(int i) -{ - count += i; -} - -struct A_void_1 -{ - void operator()(int i) - { - count += i; - } -}; - -int main() -{ - test_int_0(); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp deleted file mode 100644 index 8d700508cdc1..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/refwrap.invoke/invoke_void_0.pass.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// template <class... ArgTypes> -// requires Callable<T, ArgTypes&&...> -// Callable<T, ArgTypes&&...>::result_type -// operator()(ArgTypes&&... args) const; - -#include <functional> -#include <cassert> - -// 0 args, return void - -int count = 0; - -void f_void_0() -{ - ++count; -} - -struct A_void_0 -{ - void operator()() {++count;} -}; - -void -test_void_0() -{ - int save_count = count; - // function - { - std::reference_wrapper<void ()> r1(f_void_0); - r1(); - assert(count == save_count+1); - save_count = count; - } - // function pointer - { - void (*fp)() = f_void_0; - std::reference_wrapper<void (*)()> r1(fp); - r1(); - assert(count == save_count+1); - save_count = count; - } - // functor - { - A_void_0 a0; - std::reference_wrapper<A_void_0> r1(a0); - r1(); - assert(count == save_count+1); - save_count = count; - } -} - -int main() -{ - test_void_0(); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/type.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/type.pass.cpp deleted file mode 100644 index 68e406798145..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/type.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// check for member typedef type - -#include <functional> -#include <type_traits> - -class C {}; - -int main() -{ - static_assert((std::is_same<std::reference_wrapper<C>::type, - C>::value), ""); - static_assert((std::is_same<std::reference_wrapper<void ()>::type, - void ()>::value), ""); - static_assert((std::is_same<std::reference_wrapper<int* (double*)>::type, - int* (double*)>::value), ""); - static_assert((std::is_same<std::reference_wrapper<void(*)()>::type, - void(*)()>::value), ""); - static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::type, - int*(*)(double*)>::value), ""); - static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::type, - int*(C::*)(double*)>::value), ""); - static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::type, - int (C::*)(double*) const volatile>::value), ""); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/unary.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/unary.pass.cpp deleted file mode 100644 index 528a8f327d96..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/unary.pass.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// check for deriving from unary_function - -#include <functional> -#include <type_traits> - -class functor1 - : public std::unary_function<int, char> -{ -}; - -class functor2 - : public std::binary_function<char, int, double> -{ -}; - -class functor3 - : public std::unary_function<int, int>, - public std::binary_function<char, int, double> -{ -public: - typedef float result_type; -}; - -class functor4 - : public std::unary_function<int, int>, - public std::binary_function<char, int, double> -{ -public: -}; - -struct C -{ - typedef int argument_type; - typedef int result_type; -}; - -int main() -{ - static_assert((std::is_base_of<std::unary_function<int, char>, - std::reference_wrapper<functor1> >::value), ""); - static_assert((!std::is_base_of<std::unary_function<char, int>, - std::reference_wrapper<functor2> >::value), ""); - static_assert((std::is_base_of<std::unary_function<int, int>, - std::reference_wrapper<functor3> >::value), ""); - static_assert((std::is_base_of<std::unary_function<int, int>, - std::reference_wrapper<functor4> >::value), ""); - static_assert((!std::is_base_of<std::unary_function<int, int>, - std::reference_wrapper<C> >::value), ""); - static_assert((!std::is_base_of<std::unary_function<int, float>, - std::reference_wrapper<float(*)()> >::value), ""); - static_assert((std::is_base_of<std::unary_function<int, float>, - std::reference_wrapper<float (int)> >::value), ""); - static_assert((!std::is_base_of<std::unary_function<int, float>, - std::reference_wrapper<float (int, int)> >::value), ""); - static_assert((std::is_base_of<std::unary_function<int, float>, - std::reference_wrapper<float(*)(int)> >::value), ""); - static_assert((!std::is_base_of<std::unary_function<int, float>, - std::reference_wrapper<float(*)(int, int)> >::value), ""); - static_assert((std::is_base_of<std::unary_function<C*, float>, - std::reference_wrapper<float(C::*)()> >::value), ""); - static_assert((std::is_base_of<std::unary_function<const volatile C*, float>, - std::reference_wrapper<float(C::*)() const volatile> >::value), ""); - static_assert((!std::is_base_of<std::unary_function<C*, float>, - std::reference_wrapper<float(C::*)(int)> >::value), ""); -} diff --git a/libcxx/test/utilities/function.objects/refwrap/weak_result.pass.cpp b/libcxx/test/utilities/function.objects/refwrap/weak_result.pass.cpp deleted file mode 100644 index 609094dae406..000000000000 --- a/libcxx/test/utilities/function.objects/refwrap/weak_result.pass.cpp +++ /dev/null @@ -1,82 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// reference_wrapper - -// has weak result type - -#include <functional> -#include <type_traits> - -class functor1 - : public std::unary_function<int, char> -{ -}; - -class functor2 - : public std::binary_function<char, int, double> -{ -}; - -class functor3 - : public std::unary_function<char, int>, - public std::binary_function<char, int, double> -{ -public: - typedef float result_type; -}; - -class functor4 - : public std::unary_function<char, int>, - public std::binary_function<char, int, double> -{ -public: -}; - -class C {}; - -template <class T> -struct has_result_type -{ -private: - struct two {char _; char __;}; - template <class U> static two test(...); - template <class U> static char test(typename U::result_type* = 0); -public: - static const bool value = sizeof(test<T>(0)) == 1; -}; - -int main() -{ - static_assert((std::is_same<std::reference_wrapper<functor1>::result_type, - char>::value), ""); - static_assert((std::is_same<std::reference_wrapper<functor2>::result_type, - double>::value), ""); - static_assert((std::is_same<std::reference_wrapper<functor3>::result_type, - float>::value), ""); - static_assert((std::is_same<std::reference_wrapper<void()>::result_type, - void>::value), ""); - static_assert((std::is_same<std::reference_wrapper<int*(double*)>::result_type, - int*>::value), ""); - static_assert((std::is_same<std::reference_wrapper<void(*)()>::result_type, - void>::value), ""); - static_assert((std::is_same<std::reference_wrapper<int*(*)(double*)>::result_type, - int*>::value), ""); - static_assert((std::is_same<std::reference_wrapper<int*(C::*)(double*)>::result_type, - int*>::value), ""); - static_assert((std::is_same<std::reference_wrapper<int (C::*)(double*) const volatile>::result_type, - int>::value), ""); - static_assert((std::is_same<std::reference_wrapper<C()>::result_type, - C>::value), ""); - static_assert(has_result_type<std::reference_wrapper<functor3> >::value, ""); - static_assert(!has_result_type<std::reference_wrapper<functor4> >::value, ""); - static_assert(!has_result_type<std::reference_wrapper<C> >::value, ""); -} diff --git a/libcxx/test/utilities/function.objects/unord.hash/floating.pass.cpp b/libcxx/test/utilities/function.objects/unord.hash/floating.pass.cpp deleted file mode 100644 index 988950d4dc9a..000000000000 --- a/libcxx/test/utilities/function.objects/unord.hash/floating.pass.cpp +++ /dev/null @@ -1,68 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template <class T> -// struct hash -// : public unary_function<T, size_t> -// { -// size_t operator()(T val) const; -// }; - -// Not very portable - -#include <functional> -#include <cassert> -#include <type_traits> -#include <limits> -#include <cmath> - -template <class T> -void -test() -{ - static_assert((std::is_base_of<std::unary_function<T, std::size_t>, - std::hash<T> >::value), ""); - std::hash<T> h; - std::size_t t0 = h(0.); - std::size_t tn0 = h(-0.); - std::size_t tp1 = h(0.1); - std::size_t t1 = h(1); - std::size_t tn1 = h(-1); - std::size_t pinf = h(INFINITY); - std::size_t ninf = h(-INFINITY); - assert(t0 == tn0); - assert(t0 != tp1); - assert(t0 != t1); - assert(t0 != tn1); - assert(t0 != pinf); - assert(t0 != ninf); - - assert(tp1 != t1); - assert(tp1 != tn1); - assert(tp1 != pinf); - assert(tp1 != ninf); - - assert(t1 != tn1); - assert(t1 != pinf); - assert(t1 != ninf); - - assert(tn1 != pinf); - assert(tn1 != ninf); - - assert(pinf != ninf); -} - -int main() -{ - test<float>(); - test<double>(); - test<long double>(); -} diff --git a/libcxx/test/utilities/function.objects/unord.hash/integral.pass.cpp b/libcxx/test/utilities/function.objects/unord.hash/integral.pass.cpp deleted file mode 100644 index e5f7ca616245..000000000000 --- a/libcxx/test/utilities/function.objects/unord.hash/integral.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template <class T> -// struct hash -// : public unary_function<T, size_t> -// { -// size_t operator()(T val) const; -// }; - -// Not very portable - -#include <functional> -#include <cassert> -#include <type_traits> -#include <limits> - -template <class T> -void -test() -{ - static_assert((std::is_base_of<std::unary_function<T, std::size_t>, - std::hash<T> >::value), ""); - std::hash<T> h; - for (int i = 0; i <= 5; ++i) - { - T t(i); - if (sizeof(T) <= sizeof(std::size_t)) - assert(h(t) == t); - } -} - -int main() -{ - test<bool>(); - test<char>(); - test<signed char>(); - test<unsigned char>(); - test<char16_t>(); - test<char32_t>(); - test<wchar_t>(); - test<short>(); - test<unsigned short>(); - test<int>(); - test<unsigned int>(); - test<long>(); - test<unsigned long>(); - test<long long>(); - test<unsigned long long>(); -} diff --git a/libcxx/test/utilities/function.objects/unord.hash/pointer.pass.cpp b/libcxx/test/utilities/function.objects/unord.hash/pointer.pass.cpp deleted file mode 100644 index e4e011295c98..000000000000 --- a/libcxx/test/utilities/function.objects/unord.hash/pointer.pass.cpp +++ /dev/null @@ -1,42 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -// template <class T> -// struct hash -// : public unary_function<T, size_t> -// { -// size_t operator()(T val) const; -// }; - -// Not very portable - -#include <functional> -#include <cassert> -#include <type_traits> -#include <limits> - -template <class T> -void -test() -{ - static_assert((std::is_base_of<std::unary_function<T, std::size_t>, - std::hash<T> >::value), ""); - std::hash<T> h; - typedef typename std::remove_pointer<T>::type type; - type i; - type j; - assert(h(&i) != h(&j)); -} - -int main() -{ - test<int*>(); -} diff --git a/libcxx/test/utilities/function.objects/version.pass.cpp b/libcxx/test/utilities/function.objects/version.pass.cpp deleted file mode 100644 index 99d731a74543..000000000000 --- a/libcxx/test/utilities/function.objects/version.pass.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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> - -#include <functional> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} |
