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/refwrap | |
| 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/refwrap')
18 files changed, 0 insertions, 1144 deletions
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, ""); -} |
