1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // [func.require]
10
11 #include <type_traits>
12 #include <functional>
13
14 #include "test_macros.h"
15
16 template <typename T, int N>
17 struct Array
18 {
19 typedef T type[N];
20 };
21
22 struct Type
23 {
24 Array<char, 1>::type& f1();
25 Array<char, 2>::type& f2() const;
26 #if TEST_STD_VER >= 11
27 Array<char, 1>::type& g1() &;
28 Array<char, 2>::type& g2() const &;
29 Array<char, 3>::type& g3() &&;
30 Array<char, 4>::type& g4() const &&;
31 #endif
32 };
33
main(int,char **)34 int main(int, char**)
35 {
36 static_assert(sizeof(std::__invoke(&Type::f1, std::declval<Type >())) == 1, "");
37 static_assert(sizeof(std::__invoke(&Type::f2, std::declval<Type const >())) == 2, "");
38 #if TEST_STD_VER >= 11
39 static_assert(sizeof(std::__invoke(&Type::g1, std::declval<Type &>())) == 1, "");
40 static_assert(sizeof(std::__invoke(&Type::g2, std::declval<Type const &>())) == 2, "");
41 static_assert(sizeof(std::__invoke(&Type::g3, std::declval<Type &&>())) == 3, "");
42 static_assert(sizeof(std::__invoke(&Type::g4, std::declval<Type const&&>())) == 4, "");
43 #endif
44
45 return 0;
46 }
47