1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // UNSUPPORTED: c++98, c++03
11 //
12 // <functional>
13 //
14 // result_of<Fn(ArgTypes...)>
15
16 #include <type_traits>
17 #include "test_macros.h"
18
19 struct wat
20 {
operator *wat21 wat& operator*() { return *this; }
22 void foo();
23 };
24
25 struct F {};
26
27 template <class T, class U>
test_result_of_imp()28 void test_result_of_imp()
29 {
30 static_assert((std::is_same<typename std::result_of<T>::type, U>::value), "");
31 #if TEST_STD_VER > 11
32 static_assert((std::is_same<std::result_of_t<T>, U>::value), "");
33 #endif
34 }
35
main()36 int main()
37 {
38 {
39 typedef char F::*PMD;
40 test_result_of_imp<PMD(F &), char &>();
41 test_result_of_imp<PMD(F const &), char const &>();
42 test_result_of_imp<PMD(F volatile &), char volatile &>();
43 test_result_of_imp<PMD(F const volatile &), char const volatile &>();
44
45 test_result_of_imp<PMD(F &&), char &&>();
46 test_result_of_imp<PMD(F const &&), char const &&>();
47 test_result_of_imp<PMD(F volatile &&), char volatile &&>();
48 test_result_of_imp<PMD(F const volatile &&), char const volatile &&>();
49
50 test_result_of_imp<PMD(F ), char &&>();
51 test_result_of_imp<PMD(F const ), char &&>();
52 test_result_of_imp<PMD(F volatile ), char &&>();
53 test_result_of_imp<PMD(F const volatile ), char &&>();
54 }
55 {
56 test_result_of_imp<int (F::* (F &)) () &, int> ();
57 test_result_of_imp<int (F::* (F &)) () const &, int> ();
58 test_result_of_imp<int (F::* (F &)) () volatile &, int> ();
59 test_result_of_imp<int (F::* (F &)) () const volatile &, int> ();
60 test_result_of_imp<int (F::* (F const &)) () const &, int> ();
61 test_result_of_imp<int (F::* (F const &)) () const volatile &, int> ();
62 test_result_of_imp<int (F::* (F volatile &)) () volatile &, int> ();
63 test_result_of_imp<int (F::* (F volatile &)) () const volatile &, int> ();
64 test_result_of_imp<int (F::* (F const volatile &)) () const volatile &, int> ();
65
66 test_result_of_imp<int (F::* (F &&)) () &&, int> ();
67 test_result_of_imp<int (F::* (F &&)) () const &&, int> ();
68 test_result_of_imp<int (F::* (F &&)) () volatile &&, int> ();
69 test_result_of_imp<int (F::* (F &&)) () const volatile &&, int> ();
70 test_result_of_imp<int (F::* (F const &&)) () const &&, int> ();
71 test_result_of_imp<int (F::* (F const &&)) () const volatile &&, int> ();
72 test_result_of_imp<int (F::* (F volatile &&)) () volatile &&, int> ();
73 test_result_of_imp<int (F::* (F volatile &&)) () const volatile &&, int> ();
74 test_result_of_imp<int (F::* (F const volatile &&)) () const volatile &&, int> ();
75
76 test_result_of_imp<int (F::* (F )) () &&, int> ();
77 test_result_of_imp<int (F::* (F )) () const &&, int> ();
78 test_result_of_imp<int (F::* (F )) () volatile &&, int> ();
79 test_result_of_imp<int (F::* (F )) () const volatile &&, int> ();
80 test_result_of_imp<int (F::* (F const )) () const &&, int> ();
81 test_result_of_imp<int (F::* (F const )) () const volatile &&, int> ();
82 test_result_of_imp<int (F::* (F volatile )) () volatile &&, int> ();
83 test_result_of_imp<int (F::* (F volatile )) () const volatile &&, int> ();
84 test_result_of_imp<int (F::* (F const volatile )) () const volatile &&, int> ();
85 }
86
87 test_result_of_imp<decltype(&wat::foo)(wat), void>();
88 }
89