//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // template // class function { // public: // typedef R result_type; // typedef T1 argument_type; // iff sizeof...(ArgTypes) == 1 and // // the type in ArgTypes is T1 // typedef T1 first_argument_type; // iff sizeof...(ArgTypes) == 2 and // // ArgTypes contains T1 and T2 // typedef T2 second_argument_type; // iff sizeof...(ArgTypes) == 2 and // // ArgTypes contains T1 and T2 // ... // }; // This test runs in C++03, but we have deprecated using std::function in C++03. // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS #include #include #include "test_macros.h" template class has_argument_type { typedef char yes; typedef long no; template static yes check( typename C::argument_type * ); template static no check(...); public: enum { value = sizeof(check(0)) == sizeof(yes) }; }; template class has_first_argument_type { typedef char yes; typedef long no; template static yes check( typename C::first_argument_type * ); template static no check(...); public: enum { value = sizeof(check(0)) == sizeof(yes) }; }; template class has_second_argument_type { typedef char yes; typedef long no; template static yes check( typename C::second_argument_type *); template static no check(...); public: enum { value = sizeof(check(0)) == sizeof(yes) }; }; template void test_nullary_function () { #if TEST_STD_VER <= 17 static_assert((std::is_same::value), "" ); #endif static_assert((!has_argument_type::value), "" ); static_assert((!has_first_argument_type::value), "" ); static_assert((!has_second_argument_type::value), "" ); } template void test_unary_function () { #if TEST_STD_VER <= 17 static_assert((std::is_same::value), "" ); static_assert((std::is_same::value), "" ); #endif static_assert((!has_first_argument_type::value), "" ); static_assert((!has_second_argument_type::value), "" ); } template void test_binary_function () { #if TEST_STD_VER <= 17 static_assert((std::is_same::value), "" ); static_assert((std::is_same::value), "" ); static_assert((std::is_same::value), "" ); #endif static_assert((!has_argument_type::value), "" ); } template void test_other_function () { #if TEST_STD_VER <= 17 static_assert((std::is_same::value), "" ); #endif static_assert((!has_argument_type::value), "" ); static_assert((!has_first_argument_type::value), "" ); static_assert((!has_second_argument_type::value), "" ); } int main(int, char**) { test_nullary_function, int>(); test_unary_function , double, int>(); test_binary_function , double, int, char>(); test_other_function , double>(); return 0; }