Pigweed
 
Loading...
Searching...
No Matches
pointer.h
Go to the documentation of this file.
1// Copyright 2023 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14#pragma once
15
27
28#include <utility>
29
30#include "pw_function/internal/static_invoker.h"
31
32namespace pw::function {
33
67template <typename FunctionType>
68constexpr auto GetFunctionPointer() {
69 return internal::StaticInvoker<
70 FunctionType,
71 decltype(&FunctionType::operator())>::InvokeWithContextLast;
72}
73
76template <typename FunctionType>
77constexpr auto GetFunctionPointer(const FunctionType&) {
78 return GetFunctionPointer<FunctionType>();
79}
80
83template <typename FunctionType>
85 return internal::StaticInvoker<
86 FunctionType,
87 decltype(&FunctionType::operator())>::InvokeWithContextFirst;
88}
89
92template <typename FunctionType>
93constexpr auto GetFunctionPointerContextFirst(const FunctionType&) {
94 return GetFunctionPointerContextFirst<FunctionType>();
95}
96
97} // namespace pw::function
constexpr auto GetFunctionPointerContextFirst()
Definition: pointer.h:84
constexpr auto GetFunctionPointer()
Definition: pointer.h:68