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 // <functional>
10 
11 // template <class F, class ...Args>
12 // result_of_t<F&&(Args&&...)> invoke(F&&, Args&&...);
13 
14 #include <functional>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 
19 #if TEST_STD_VER <= 14
20 # ifdef __cpp_lib_invoke
21 #   error Feature test macro should be defined
22 # endif
23 #else
24 # ifndef __cpp_lib_invoke
25 #   error Feature test macro not defined
26 # endif
27 # if __cpp_lib_invoke != 201411
28 #   error __cpp_lib_invoke has the wrong value
29 # endif
30 #endif
31 
32 int foo(int) { return 42; }
33 
34 int main(int, char**) {
35 #if defined(__cpp_lib_invoke)
36   assert(std::invoke(foo, 101) == 42);
37 #endif
38 
39   return 0;
40 }
41