1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // result_of<Fn(ArgTypes...)>
14 #include <type_traits>
17 typedef bool (&PF1)();
18 typedef short (*PF2)(long);
23 double operator()(char, int&);
24 void calc(long) const;
28 typedef void (S::*PMS)(long) const;
33 wat& operator*() { return *this; }
37 template <class T, class U>
38 void test_result_of_imp()
40 static_assert((std::is_same<typename std::result_of<T>::type, U>::value), "");
41 #if _LIBCPP_STD_VER > 11
42 static_assert((std::is_same<std::result_of_t<T>, U>::value), "");
48 test_result_of_imp<S(int), short> ();
49 test_result_of_imp<S&(unsigned char, int&), double> ();
50 test_result_of_imp<PF1(), bool> ();
51 test_result_of_imp<PMS(std::unique_ptr<S>, int), void> ();
52 test_result_of_imp<PMS(S, int), void> ();
53 test_result_of_imp<PMS(const S&, int), void> ();
54 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
55 test_result_of_imp<PMD(S), char&&> ();
57 test_result_of_imp<PMD(const S*), const char&> ();
58 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
59 using type1 = std::result_of<decltype(&wat::foo)(wat)>::type;
61 #if _LIBCPP_STD_VER > 11
62 using type2 = std::result_of_t<decltype(&wat::foo)(wat)>;
67 static_assert((std::is_same<std::result_of<S(int)>::type, short>::value), "Error!");
68 static_assert((std::is_same<std::result_of<S&(unsigned char, int&)>::type, double>::value), "Error!");
69 static_assert((std::is_same<std::result_of<PF1()>::type, bool>::value), "Error!");
70 static_assert((std::is_same<std::result_of<PMS(std::unique_ptr<S>, int)>::type, void>::value), "Error!");
71 static_assert((std::is_same<std::result_of<PMS(S, int)>::type, void>::value), "Error!");
72 static_assert((std::is_same<std::result_of<PMS(const S&, int)>::type, void>::value), "Error!");
73 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
74 static_assert((std::is_same<std::result_of<PMD(S)>::type, char&&>::value), "Error!");
76 static_assert((std::is_same<std::result_of<PMD(const S*)>::type, const char&>::value), "Error!");
77 #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
78 using type = std::result_of<decltype(&wat::foo)(wat)>::type;