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 20 template <bool Expected, class T> 21 void 22 test(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 39 struct C {int operator()(...) const { return 0; }}; 40 41 int main(int, char**) 42 { 43 test<true>(std::bind(C())); 44 test<true>(std::bind(C(), std::placeholders::_2)); 45 test<true>(std::bind<int>(C())); 46 test<false>(1); 47 test<false>(std::placeholders::_2); 48 49 return 0; 50 } 51