# std::indirect_result_t

> C++ Atlas: `cppatlas.com/w/cpp/iterator/indirect_result_t` | Source: https://en.cppreference.com/w/cpp/iterator/indirect_result_t | Domain: Iterator | Standards: C++11, C++17, C++20, C++26

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....

## Official Specification Summary (cppreference)

```cpp
// Defined in header <iterator>

template< class F, class... Is >
    requires (std::indirectly_readable<Is> && ...) &&
              std::invocable<F, std::iter_reference_t<Is>...>
using indirect_result_t = std::invoke_result_t<F, std::iter_reference_t<Is>...>; // (since C++20)
```

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...`.

### Template parameters

- `F` - an invocable type
- `Is` - indirectly readable types that are dereferenced to arguments

### Example

```cpp
#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() {}
```

### See also

- [`result_of`](https://en.cppreference.com/w/cpp/types/result_of) (C++11), [`invoke_result`](https://en.cppreference.com/w/cpp/types/result_of) (removed in C++20): deduces the result type of invoking a callable object with a set of arguments (class template)
- [`projected_value_t`](https://en.cppreference.com/w/cpp/iterator/projected_value_t) (C++26): computes the value type of an `indirectly_readable` type by projection (alias template)

---
Attribution: content from https://en.cppreference.com/w/cpp/iterator/indirect_result_t (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.