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 // [func.require] 11 12 #include <type_traits> 13 #include <functional> 14 15 #include "test_macros.h" 16 17 template <typename T, int N> 18 struct Array 19 { 20 typedef T type[N]; 21 }; 22 23 struct Type 24 { 25 Array<char, 1>::type& f1(); 26 Array<char, 2>::type& f2() const; 27 #if TEST_STD_VER >= 11 28 Array<char, 1>::type& g1() &; 29 Array<char, 2>::type& g2() const &; 30 Array<char, 3>::type& g3() &&; 31 Array<char, 4>::type& g4() const &&; 32 #endif 33 }; 34 35 int main() 36 { 37 static_assert(sizeof(std::__invoke(&Type::f1, std::declval<Type >())) == 1, ""); 38 static_assert(sizeof(std::__invoke(&Type::f2, std::declval<Type const >())) == 2, ""); 39 #if TEST_STD_VER >= 11 40 static_assert(sizeof(std::__invoke(&Type::g1, std::declval<Type &>())) == 1, ""); 41 static_assert(sizeof(std::__invoke(&Type::g2, std::declval<Type const &>())) == 2, ""); 42 static_assert(sizeof(std::__invoke(&Type::g3, std::declval<Type &&>())) == 3, ""); 43 static_assert(sizeof(std::__invoke(&Type::g4, std::declval<Type const&&>())) == 4, ""); 44 #endif 45 } 46