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 | // UNSUPPORTED: c++03 |
10 | |
11 | // <functional> |
12 | |
13 | // template<class T> struct is_bind_expression |
14 | |
15 | #include <functional> |
16 | #include "test_macros.h" |
17 | |
18 | template <bool Expected, class T> |
19 | void |
20 | test(const T&) |
21 | { |
22 | static_assert(std::is_bind_expression<T>::value == Expected, "" ); |
23 | LIBCPP_STATIC_ASSERT(std::is_bind_expression<T&>::value == Expected, "" ); |
24 | LIBCPP_STATIC_ASSERT(std::is_bind_expression<const T>::value == Expected, "" ); |
25 | LIBCPP_STATIC_ASSERT(std::is_bind_expression<const T&>::value == Expected, "" ); |
26 | static_assert(std::is_base_of<std::integral_constant<bool, Expected>, std::is_bind_expression<T> >::value, "" ); |
27 | |
28 | #if TEST_STD_VER > 14 |
29 | ASSERT_SAME_TYPE(decltype(std::is_bind_expression_v<T>), const bool); |
30 | static_assert(std::is_bind_expression_v<T> == Expected, "" ); |
31 | LIBCPP_STATIC_ASSERT(std::is_bind_expression_v<T&> == Expected, "" ); |
32 | LIBCPP_STATIC_ASSERT(std::is_bind_expression_v<const T> == Expected, "" ); |
33 | LIBCPP_STATIC_ASSERT(std::is_bind_expression_v<const T&> == Expected, "" ); |
34 | #endif |
35 | } |
36 | |
37 | struct C {int operator()(...) const { return 0; }}; |
38 | |
39 | int main(int, char**) |
40 | { |
41 | test<true>(std::bind(f: C())); |
42 | test<true>(std::bind(f: C(), args: std::placeholders::_2)); |
43 | test<true>(std::bind<int>(f: C())); |
44 | test<false>(1); |
45 | test<false>(std::placeholders::_2); |
46 | |
47 | return 0; |
48 | } |
49 | |