//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // result_of #include #include #include #include "test_macros.h" struct S { typedef short (*FreeFunc)(long); operator FreeFunc() const; double operator()(char, int&); double const& operator()(char, int&) const; double volatile& operator()(char, int&) volatile; double const volatile& operator()(char, int&) const volatile; }; struct SD : public S { }; struct NotDerived {}; template struct Voider { typedef void type; }; template struct HasType : std::false_type {}; template struct HasType::type> : std::true_type {}; #if TEST_STD_VER > 14 template struct test_invoke_result; template struct test_invoke_result { static void call() { static_assert(std::is_invocable::value, ""); static_assert(std::is_invocable_r::value, ""); static_assert((std::is_same::type, Ret>::value), ""); } }; #endif template void test_result_of() { static_assert((std::is_same::type, U>::value), ""); #if TEST_STD_VER > 14 test_invoke_result::call(); #endif } #if TEST_STD_VER > 14 template struct test_invoke_no_result; template struct test_invoke_no_result { static void call() { static_assert(std::is_invocable::value == false, ""); static_assert((!HasType >::value), ""); } }; #endif template void test_no_result() { #if TEST_STD_VER >= 11 static_assert((!HasType >::value), ""); #endif #if TEST_STD_VER > 14 test_invoke_no_result::call(); #endif } int main() { typedef NotDerived ND; { // functor object test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); } { // pointer to function typedef bool (&RF0)(); typedef bool* (&RF1)(int); typedef bool& (&RF2)(int, int); typedef bool const& (&RF3)(int, int, int); typedef bool (&RF4)(int, ...); typedef bool (*PF0)(); typedef bool* (*PF1)(int); typedef bool& (*PF2)(int, int); typedef bool const& (*PF3)(int, int, int); typedef bool (*PF4)(int, ...); typedef bool (*&PRF0)(); typedef bool* (*&PRF1)(int); typedef bool& (*&PRF2)(int, int); typedef bool const& (*&PRF3)(int, int, int); typedef bool (*&PRF4)(int, ...); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of(); } { // pointer to member function typedef int (S::*PMS0)(); typedef int* (S::*PMS1)(long); typedef int& (S::*PMS2)(long, int); typedef const int& (S::*PMS3)(int, ...); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of), int> (); test_result_of&), int> (); test_result_of), int> (); test_result_of&), int> (); test_result_of), int> (); test_result_of), int> (); test_no_result(); test_no_result(); test_no_result(); test_no_result(); test_no_result(); test_no_result )>(); test_no_result)>(); test_no_result )>(); test_no_result )>(); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of, int), int*> (); test_result_of, int), int*> (); test_result_of, int), int*> (); test_result_of&, int), int*> (); test_result_of, int), int*> (); test_result_of&, int), int*> (); test_no_result(); test_no_result(); test_no_result(); test_no_result(); test_no_result(); test_no_result, int)>(); test_no_result, int)>(); test_no_result, int)>(); test_no_result, int)>(); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of, int, int), int&> (); test_result_of, int, int), int&> (); test_result_of, int, int), int&> (); test_result_of&, int, int), int&> (); test_result_of, int, int), int&> (); test_result_of&, int, int), int&> (); test_no_result(); test_no_result(); test_no_result(); test_no_result, int, int)>(); test_no_result, int, int)>(); test_no_result(); test_no_result, int, int)>(); test_no_result, int, int)>(); test_result_of(); test_result_of(); typedef int (S::*PMS0C)() const; typedef int* (S::*PMS1C)(long) const; typedef int& (S::*PMS2C)(long, int) const; typedef const int& (S::*PMS3C)(int, ...) const; test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of), int> (); test_result_of), int> (); test_result_of ), int> (); test_result_of ), int> (); test_result_of & ), int> (); test_result_of &), int> (); test_result_of ), int> (); test_result_of ), int> (); test_result_of & ), int> (); test_result_of &), int> (); test_no_result(); test_no_result(); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of, int), int*> (); test_no_result(); test_no_result(); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of, int, int), int&> (); test_no_result(); test_no_result(); test_result_of(); test_result_of(); typedef int (S::*PMS0V)() volatile; typedef int* (S::*PMS1V)(long) volatile; typedef int& (S::*PMS2V)(long, int) volatile; typedef const int& (S::*PMS3V)(int, ...) volatile; test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of), int> (); test_no_result(); test_no_result(); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of, int), int*> (); test_no_result(); test_no_result(); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of, int, int), int&> (); test_no_result(); test_no_result(); test_result_of(); test_result_of(); typedef int (S::*PMS0CV)() const volatile; typedef int* (S::*PMS1CV)(long) const volatile; typedef int& (S::*PMS2CV)(long, int) const volatile; typedef const int& (S::*PMS3CV)(int, ...) const volatile; test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of), int> (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of, int), int*> (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of, int, int), int&> (); test_result_of(); test_result_of(); } { // pointer to member data typedef char S::*PMD; test_result_of(); test_result_of(); test_result_of(); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of (); test_result_of(); test_result_of(); test_result_of(); test_result_of(); test_result_of), char &>(); test_result_of), const char&>(); #if TEST_STD_VER >= 11 test_result_of), char&>(); test_result_of), const char&>(); #endif test_no_result(); } }