tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
invoke_r.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_FUNCTIONAL_INVOKE_R_HPP
5#define TETL_FUNCTIONAL_INVOKE_R_HPP
6
7#include <etl/_functional/invoke.hpp>
8#include <etl/_type_traits/is_invocable_r.hpp>
9#include <etl/_type_traits/is_void.hpp>
10#include <etl/_utility/forward.hpp>
11
12namespace etl {
13
14/// \todo Add noexcept(is_nothrow_invocable_r_v<R, F, Args...>)
15template <typename R, typename F, typename... Args>
16 requires(etl::is_invocable_r_v<R, F, Args...>)
17constexpr auto invoke_r(F&& f, Args&&... args) -> R
18{
19 if constexpr (etl::is_void_v<R>) {
20 etl::invoke(etl::forward<F>(f), etl::forward<Args>(args)...);
21 } else {
22 return etl::invoke(etl::forward<F>(f), etl::forward<Args>(args)...);
23 }
24}
25
26} // namespace etl
27
28#endif // TETL_FUNCTIONAL_INVOKE_R_HPP
Definition adjacent_find.hpp:9
constexpr auto invoke_r(F &&f, Args &&... args) -> R
Definition invoke_r.hpp:17