source: mainline/uspace/lib/cpp/include/__bits/functional/functional.hpp@ c6f23a7

Last change on this file since c6f23a7 was b57ba05, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago

Update headers in C++ files

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 * SPDX-FileCopyrightText: 2018 Jaroslav Jindrak
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef LIBCPP_BITS_FUNCTIONAL
8#define LIBCPP_BITS_FUNCTIONAL
9
10#include <__bits/functional/conditional_function_typedefs.hpp>
11#include <__bits/functional/invoke.hpp>
12#include <limits>
13#include <memory>
14#include <type_traits>
15#include <utility>
16
17namespace std
18{
19 /**
20 * 20.9.3, invoke:
21 */
22
23 template<class F, class... Args>
24 decltype(auto) invoke(F&& f, Args&&... args)
25 {
26 return aux::INVOKE(forward<F>(f),forward<Args>(args)...);
27 }
28
29 /**
30 * 20.9.11, member function adaptors:
31 */
32
33 namespace aux
34 {
35 template<class F>
36 class mem_fn_t
37 : public conditional_function_typedefs<remove_cv_t<remove_reference_t<F>>>
38 {
39 public:
40 mem_fn_t(F f)
41 : func_{f}
42 { /* DUMMY BODY */ }
43
44 template<class... Args>
45 decltype(auto) operator()(Args&&... args)
46 {
47 return INVOKE(func_, forward<Args>(args)...);
48 }
49
50 private:
51 F func_;
52 };
53 }
54
55 template<class R, class T>
56 aux::mem_fn_t<R T::*> mem_fn(R T::* f)
57 {
58 return aux::mem_fn_t<R T::*>{f};
59 }
60}
61
62#endif
Note: See TracBrowser for help on using the repository browser.