//===----------------------------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // // reference_wrapper // has weak result type // REQUIRES: c++03 || c++11 || c++14 || c++17 #include #include #include "test_macros.h" template struct my_unary_function { // std::unary_function was removed in C++17 typedef Arg argument_type; typedef Result result_type; }; template struct my_binary_function { // std::binary_function was removed in C++17 typedef Arg1 first_argument_type; typedef Arg2 second_argument_type; typedef Result result_type; }; class functor1 : public my_unary_function { }; class functor2 : public my_binary_function { }; class functor3 : public my_unary_function, public my_binary_function { public: typedef float result_type; }; class functor4 : public my_unary_function, public my_binary_function { public: }; class C {}; template struct has_result_type { private: struct two {char _; char __;}; template static two test(...); template static char test(typename U::result_type* = 0); public: static const bool value = sizeof(test(0)) == 1; }; int main(int, char**) { static_assert((std::is_same::result_type, char>::value), ""); static_assert((std::is_same::result_type, double>::value), ""); static_assert((std::is_same::result_type, float>::value), ""); static_assert((std::is_same::result_type, void>::value), ""); static_assert((std::is_same::result_type, int*>::value), ""); static_assert((std::is_same::result_type, void>::value), ""); static_assert((std::is_same::result_type, int*>::value), ""); static_assert((std::is_same::result_type, int*>::value), ""); static_assert((std::is_same::result_type, int>::value), ""); static_assert((std::is_same::result_type, C>::value), ""); static_assert(has_result_type >::value, ""); static_assert(!has_result_type >::value, ""); static_assert(!has_result_type >::value, ""); return 0; }