1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <functional>
10
11// UNSUPPORTED: c++03
12
13// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
14
15#include <functional>
16#include <cassert>
17
18int identity(int v) { return v; }
19int sum(int a, int b) { return a + b; }
20
21struct Foo {
22 int const_zero() const { return 0; }
23 int const_identity(int v) const { return v; }
24 int zero() { return 0; }
25 int identity(int v) { return v; }
26};
27
28void f() {
29 typedef std::pointer_to_unary_function<int, int> PUF; // expected-warning {{'pointer_to_unary_function<int, int>' is deprecated}}
30 typedef std::pointer_to_binary_function<int, int, int> PBF; // expected-warning {{'pointer_to_binary_function<int, int, int>' is deprecated}}
31 std::ptr_fun<int, int>(x: identity); // expected-warning {{'ptr_fun<int, int>' is deprecated}}
32 std::ptr_fun<int, int, int>(x: sum); // expected-warning {{'ptr_fun<int, int, int>' is deprecated}}
33
34 typedef std::mem_fun_t<int, Foo> MFT0; // expected-warning {{'mem_fun_t<int, Foo>' is deprecated}}
35 typedef std::mem_fun1_t<int, Foo, int> MFT1; // expected-warning {{'mem_fun1_t<int, Foo, int>' is deprecated}}
36 typedef std::const_mem_fun_t<int, Foo> CMFT0; // expected-warning {{'const_mem_fun_t<int, Foo>' is deprecated}}
37 typedef std::const_mem_fun1_t<int, Foo, int> CMFT1; // expected-warning {{'const_mem_fun1_t<int, Foo, int>' is deprecated}}
38 std::mem_fun<int, Foo>(f: &Foo::zero); // expected-warning {{'mem_fun<int, Foo>' is deprecated}}
39 std::mem_fun<int, Foo, int>(f: &Foo::identity); // expected-warning {{'mem_fun<int, Foo, int>' is deprecated}}
40 std::mem_fun<int, Foo>(f: &Foo::const_zero); // expected-warning {{'mem_fun<int, Foo>' is deprecated}}
41 std::mem_fun<int, Foo, int>(f: &Foo::const_identity); // expected-warning {{'mem_fun<int, Foo, int>' is deprecated}}
42
43 typedef std::mem_fun_ref_t<int, Foo> MFR0; // expected-warning {{'mem_fun_ref_t<int, Foo>' is deprecated}}
44 typedef std::mem_fun1_ref_t<int, Foo, int> MFR1; // expected-warning {{'mem_fun1_ref_t<int, Foo, int>' is deprecated}}
45 typedef std::const_mem_fun_ref_t<int, Foo> CMFR0; // expected-warning {{'const_mem_fun_ref_t<int, Foo>' is deprecated}}
46 typedef std::const_mem_fun1_ref_t<int, Foo, int> CMFR1; // expected-warning {{'const_mem_fun1_ref_t<int, Foo, int>' is deprecated}}
47 std::mem_fun_ref<int, Foo>(f: &Foo::zero); // expected-warning {{'mem_fun_ref<int, Foo>' is deprecated}}
48 std::mem_fun_ref<int, Foo, int>(f: &Foo::identity); // expected-warning {{'mem_fun_ref<int, Foo, int>' is deprecated}}
49 std::mem_fun_ref<int, Foo>(f: &Foo::const_zero); // expected-warning {{'mem_fun_ref<int, Foo>' is deprecated}}
50 std::mem_fun_ref<int, Foo, int>(f: &Foo::const_identity); // expected-warning {{'mem_fun_ref<int, Foo, int>' is deprecated}}
51}
52

source code of libcxx/test/libcxx/depr/depr.function.objects/adaptors.depr_in_cxx11.verify.cpp