Created
July 4, 2018 03:56
-
-
Save EricWF/6355d7d59718fb749c718d3f605cfa9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //===----------------------------------------------------------------------===// | |
| // | |
| // 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> | |
| // REQUIRES: verify-support | |
| // MODULES_DEFINES: _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS | |
| #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS | |
| #include <functional> | |
| #include <cassert> | |
| #include "test_macros.h" | |
| int identity(int v) { return v; } | |
| int sum(int a, int b) { return a + b; } | |
| struct Foo { | |
| int zero() const { return 0; } | |
| int identity(int v) const { return v; } | |
| int sum(int a, int b) const { return a + b; } | |
| }; | |
| int main() | |
| { | |
| #if TEST_STD_VER < 11 | |
| // expected-no-diagnostics | |
| #else | |
| // expected-error@* 1 {{'pointer_to_unary_function<int, int>' is deprecated}} | |
| // expected-error@* 1 {{'pointer_to_binary_function<int, int, int>' is deprecated}} | |
| // expected-error@* 1 {{'ptr_fun<int, int>' is deprecated}} | |
| // expected-error@* 1 {{'ptr_fun<int, int, int>' is deprecated}} | |
| // expected-error@* 1 {{'mem_fun_ref_t<int, Foo>' is deprecated}} | |
| // expected-error@* 1 {{'const_mem_fun_ref_t<int, Foo>' is deprecated}} | |
| // expected-error@* 1 {{'mem_fun_ref<int, Foo>' is deprecated}} | |
| // expected-error@* 1 {{'mem_fun_ref<int, Foo, int>' is deprecated}} | |
| #endif | |
| typedef std::pointer_to_unary_function<int, int> PUF; | |
| typedef std::pointer_to_binary_function<int, int, int> PBF; | |
| assert((std::ptr_fun<int, int>(identity)(4) == 4)); | |
| assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9)); | |
| Foo f; | |
| assert((std::mem_fn(&Foo::identity)(f, 5) == 5)); | |
| assert((std::mem_fn(&Foo::sum)(f, 5, 6) == 11)); | |
| typedef std::mem_fun_ref_t<int, Foo> MFR; | |
| typedef std::const_mem_fun_ref_t<int, Foo> CMFR; | |
| assert((std::mem_fun_ref(&Foo::zero)(f) == 0)); | |
| assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment