std::indirect_result_t
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Iterator library
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)(C++23)(C++20)(C++20)
(deprecated in C++17)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++14)
(C++11)
(C++11)
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++23)
(C++23)
(C++23)
(C++23)
(C++23)
(C++11)(C++14)
(C++14)(C++14)
Defined in header
<iterator>
template< class F, class... Is >
(since C++20)
requires (std::indirectly_readable <Is> && ...) &&
std::invocable <F, std::iter_reference_t <Is>...>
The alias template indirect_result_t
obtains the result type of invoking an invocable
type F
on the result of dereferencing indirectly_readable
types Is...
.
[edit] Template parameters
F
-
an invocable type
Is
-
indirectly readable types that are dereferenced to arguments
[edit] Example
Run this code
#include <iterator> #include <type_traits> struct Fn { long operator()(const int&); int operator()(int&&); short operator()(int, int) const; auto operator()(const float) -> int&; void operator()(int[8]); }; static_assert( std::is_same_v <std::indirect_result_t<Fn, const int*>, long> and std::is_same_v <std::indirect_result_t<Fn, std::move_iterator <int*>>, int> and std::is_same_v <std::indirect_result_t<const Fn, int*, int*>, short> and std::is_same_v <std::indirect_result_t<Fn, float*>, int&> and std::is_same_v <std::indirect_result_t<Fn, int**>, void> ); int main() {}
[edit] See also
(C++11)(removed in C++20)(C++17)
(class template) [edit]