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

source code of libcxx/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp