std::projected_C++中文网

          std::indirectly_regular_unary_invocable<I> Proj >
struct projected {
    using value_type = std::remove_cvref_t<std::indirect_result_t<Proj&, I>>;
    std::indirect_result_t<Proj&, I> operator*() const; // 不定义

};

(1) (C++20 起)

template< std::weakly_incrementable I, class Proj >

struct incrementable_traits<std::projected<I, Proj>> {
    using difference_type = std::iter_difference_t<I>;

};

(2) (C++20 起)

1) 类模板 projected 组合

indirectly_readable

类型 I 与可调用对象类型 Proj 到新的 indirectly_readable 类型中,其引用类型是应用 Projstd::iter_reference_t<I> 的结果。

2) std::incrementable_traits 的此特化使 std::projected<I, Proj>I

weakly_incrementable

类型时亦为 weakly_incrementable 类型。

projected 仅用于制约接受可调用对象与投影的算法,从而其 operator*() 不被定义。

模板形参

I - 间接可读类型
Proj - 应用到解引用的 I 的投影