aboutsummaryrefslogtreecommitdiff
path: root/test/std/utilities/function.objects/bind/func.bind/func.bind.bind
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 18:01:01 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 18:01:01 +0000
commitb7332b04df5d50c92640c74cfeb138ecb7e3f7ae (patch)
treeb1b49faa0cab1482905e0cda6f0ee5d97e3fe08f /test/std/utilities/function.objects/bind/func.bind/func.bind.bind
parent6012fe9abb1f01b1b5b4ca908464804c21ff8602 (diff)
Notes
Diffstat (limited to 'test/std/utilities/function.objects/bind/func.bind/func.bind.bind')
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp35
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp133
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp37
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp51
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp55
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp290
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp268
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp74
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp52
9 files changed, 0 insertions, 995 deletions
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp
deleted file mode 100644
index 943e162172b0..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp
+++ /dev/null
@@ -1,35 +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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <functional>
-
-// template<CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-
-// https://bugs.llvm.org/show_bug.cgi?id=23141
-#include <functional>
-#include <type_traits>
-
-struct Fun
-{
- template<typename T, typename U>
- void operator()(T &&, U &&) const
- {
- static_assert(std::is_same<U, int &>::value, "");
- }
-};
-
-int main()
-{
- std::bind(Fun{}, std::placeholders::_1, 42)("hello");
-}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp
deleted file mode 100644
index a543fffedbb5..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/bind_return_type.pass.cpp
+++ /dev/null
@@ -1,133 +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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <functional>
-
-// template<CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-
-// Check that the call operators have the proper return type and that they
-// only SFINAE away when too few arguments are provided. Otherwise they should
-// be well formed and should ignore any additional arguments.
-
-#include <functional>
-#include <type_traits>
-#include <cassert>
-
-#include "test_macros.h"
-
-int dummy = 42;
-
-int return_value(int) { return dummy; }
-int& return_lvalue(int) { return dummy; }
-const int& return_const_lvalue(int) { return dummy; }
-int&& return_rvalue(int) { return std::move(dummy); }
-const int&& return_const_rvalue(int) { return std::move(dummy); }
-
-template <class Bind, class ...Args>
-auto CheckCallImp(int)
- -> decltype((std::declval<Bind>()(std::declval<Args>()...)), std::true_type{});
-
-template <class Bind, class ...>
-auto CheckCallImp(long) -> std::false_type;
-
-template <class ...Args>
-constexpr bool CheckCall() {
- return decltype(CheckCallImp<Args...>(0))::value;
-}
-
-template <class Expect, class Fn>
-void do_test(Fn* func) {
- using namespace std::placeholders;
- auto ret = std::bind(func, _1);
- auto ret_r = std::bind<Expect>(func, _1);
- using Bind = decltype(ret);
- using BindR = decltype(ret_r);
-
- using Ret = decltype(ret(42));
- using Ret2 = decltype(ret(42, 43)); // Test that the extra argument is discarded.
- using RetR = decltype(ret_r(42));
- using RetR2 = decltype(ret_r(42, 43));
-
- static_assert(std::is_same<Ret, Expect>::value, "");
- static_assert(std::is_same<Ret2, Expect>::value, "");
- static_assert(std::is_same<RetR, Expect>::value, "");
- static_assert(std::is_same<RetR2, Expect>::value, "");
-
- Expect exp = ret(100); // the input value is ignored. dummy is returned.
- Expect exp2 = ret(101, 102);
- Expect exp_r = ret_r(100);
- Expect exp_r2 = ret_r(101, 102);
-
- assert(exp == 42);
- assert(exp2 == 42);
- assert(exp_r == 42);
- assert(exp_r2 == 42);
-
- if ((std::is_reference<Expect>::value)) {
- assert(&exp == &dummy);
- assert(&exp2 == &dummy);
- assert(&exp_r == &dummy);
- assert(&exp_r2 == &dummy);
- }
- // Check that the call operator SFINAE's away when too few arguments
- // are provided but is well-formed otherwise.
- {
- LIBCPP_STATIC_ASSERT(!CheckCall<Bind>(), "");
- static_assert(CheckCall<Bind, int>(), "");
- static_assert(CheckCall<Bind, int, int>(), "");
- LIBCPP_STATIC_ASSERT(!CheckCall<BindR>(), "");
- static_assert(CheckCall<BindR, int>(), "");
- static_assert(CheckCall<BindR, int, int>(), "");
- }
-}
-
-
-// Test but with an explicit return type which differs from the real one.
-template <class Expect, class Fn>
-void do_test_r(Fn* func) {
- using namespace std::placeholders;
- auto ret = std::bind<Expect>(func, _1);
- using Bind = decltype(ret);
- using Ret = decltype(ret(42));
- using Ret2 = decltype(ret(42, 43)); // Test that the extra argument is discarded.
- static_assert(std::is_same<Ret, Expect>::value, "");
- static_assert(std::is_same<Ret2, Expect>::value, "");
- Expect exp = ret(100); // the input value is ignored
- Expect exp2 = ret(101, 102);
- assert(exp == 42);
- assert(exp2 == 42);
- // Check that the call operator SFINAE's away when too few arguments
- // are provided but is well-formed otherwise.
- {
- LIBCPP_STATIC_ASSERT(!CheckCall<Bind>(), "");
- static_assert(CheckCall<Bind, int>(), "");
- static_assert(CheckCall<Bind, int, int>(), "");
- }
-}
-
-int main()
-{
- do_test<int>(return_value);
- do_test<int&>(return_lvalue);
- do_test<const int&>(return_const_lvalue);
- do_test<int&&>(return_rvalue);
- do_test<const int&&>(return_const_rvalue);
-
- do_test_r<long>(return_value);
- do_test_r<long>(return_lvalue);
- do_test_r<long>(return_const_lvalue);
- do_test_r<long>(return_rvalue);
- do_test_r<long>(return_const_rvalue);
-
-}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
deleted file mode 100644
index a4d502bb800e..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <functional>
-
-// template<CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-
-// https://bugs.llvm.org/show_bug.cgi?id=16385
-
-#include <functional>
-#include <cmath>
-#include <cassert>
-
-float _pow(float a, float b)
-{
- return std::pow(a, b);
-}
-
-int main()
-{
- std::function<float(float, float)> fnc = _pow;
- auto task = std::bind(fnc, 2.f, 4.f);
- auto task2(task);
- assert(task() == 16);
- assert(task2() == 16);
-}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
deleted file mode 100644
index a9a38b83cb4e..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
+++ /dev/null
@@ -1,51 +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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <functional>
-
-// template<CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-
-// https://bugs.llvm.org/show_bug.cgi?id=22003
-
-#include <functional>
-
-struct DummyUnaryFunction
-{
- template <typename S>
- int operator()(S const &) const { return 0; }
-};
-
-struct BadUnaryFunction
-{
- template <typename S>
- constexpr int operator()(S const &) const
- {
- // Trigger a compile error if this function is instantiated.
- // The constexpr is needed so that it is instantiated while checking
- // __invoke_of<BadUnaryFunction &, ...>.
- static_assert(!std::is_same<S, S>::value, "Shit");
- return 0;
- }
-};
-
-int main()
-{
- // Check that BadUnaryFunction::operator()(S const &) is not
- // instantiated when checking if BadUnaryFunction is a nested bind
- // expression during b(0). See PR22003.
- auto b = std::bind(DummyUnaryFunction(), BadUnaryFunction());
- b(0);
- auto b2 = std::bind<long>(DummyUnaryFunction(), BadUnaryFunction());
- b2(0);
-}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
deleted file mode 100644
index 815096f6b157..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp
+++ /dev/null
@@ -1,55 +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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <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/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
deleted file mode 100644
index dbbd184c7833..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp
+++ /dev/null
@@ -1,290 +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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <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;
- }
-}
-
-struct TFENode
-{
- bool foo(unsigned long long) const
- {
- return true;
- }
-};
-
-void
-test3()
-{
- using namespace std;
- using namespace std::placeholders;
- const auto f = bind(&TFENode::foo, _1, 0UL);
- const TFENode n = TFENode{};
- bool b = f(n);
- assert(b);
-}
-
-int main()
-{
- test_void_1();
- test_int_1();
- test_void_2();
- test3();
-}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp
deleted file mode 100644
index a1137ee388c1..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <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/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
deleted file mode 100644
index 73f26e4b585a..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp
+++ /dev/null
@@ -1,74 +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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <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;}
-
-int g() {++count; return 0;}
-
-struct A_void_0
-{
- void operator()() {++count;}
- void operator()() const {count += 2;}
-};
-
-struct A_int_0
-{
- int operator()() {++count; return 4;}
- int operator()() const {count += 2; return 5;}
-};
-
-int main()
-{
- test(std::bind(f));
- test(std::bind(&f));
- test(std::bind(A_void_0()));
- test_const(std::bind(A_void_0()));
-
- test(std::bind<void>(f));
- test(std::bind<void>(&f));
- test(std::bind<void>(A_void_0()));
- test_const(std::bind<void>(A_void_0()));
-
- test(std::bind<void>(g));
- test(std::bind<void>(&g));
- test(std::bind<void>(A_int_0()));
- test_const(std::bind<void>(A_int_0()));
-}
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
deleted file mode 100644
index ac43dd769ed6..000000000000
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.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.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <functional>
-
-// template<CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
-// unspecified bind(Fn, Types...);
-
-// https://bugs.llvm.org/show_bug.cgi?id=16343
-
-#include <cmath>
-#include <functional>
-#include <cassert>
-
-struct power
-{
- template <typename T>
- T
- operator()(T a, T b)
- {
- return static_cast<T>(std::pow(a, b));
- }
-};
-
-struct plus_one
-{
- template <typename T>
- T
- operator()(T a)
- {
- return a + 1;
- }
-};
-
-int main()
-{
- using std::placeholders::_1;
-
- auto g = std::bind(power(), 2, _1);
- assert(g(5) == 32);
- assert(std::bind(plus_one(), g)(5) == 33);
-}