C++ 范围库 std::ranges::transform_view template< bool Const > class /*sentinel*/ (C++20 起) 底层类型非 common_range 时tranform_view::end 的返回类型。 const 限定重载返回 /*sentinel*/<true> 。非 const 限定重载返回 /*sentinel*/<false>。 此类模板的名称(此处示为 /*sentinel*/ )是...
std::ranges::transform,std::ranges::unary_transform_result,std::ranges::binary_transform_result C++ Algorithm library Constrained algorithms, e.g.ranges::copy,ranges::sort, ... Constrained algorithms Defined in header<algorithm> Call signature ...
std::convertible_to<ranges::iterator_t<V>,ranges::iterator_t<Base>>; (3)(C++20 起) 构造迭代器。 1)默认构造函数。值初始化底层迭代器,并以nullptr初始化指向父transform_view的指针。 2)以std::move(current)初始化底层迭代器,并以std::addressof(parent)初始化指向父视图的指针。
int main() { const auto v = { 0, 1, 2, 3, 4 }; auto x2 = [](int x) { return x << 1; }; std::ranges::transform_view tv{ v, x2 }; std::ostream_iterator<int> ostr{ std::cout, " " }; std::ranges::copy(v, ostr), std::cout << '\n'; std::ranges::copy(...
operator-(transform_view::iterator,transform_view::sentinel) (C++20) constexpr/*iterator*/<false>begin(); (1)(since C++20) constexpr/*iterator*/<true>begin()const requiresranges::range<constV>&& std::regular_invocable<constF&,ranges::range_reference_t<constV>>; ...
std::ranges::views::transform,std::ranges::transform_view 定义于头文件<ranges> template<ranges::input_rangeV, std::copy_constructibleF> requires ranges::view<V>&& std::is_object_v<F>&& std::regular_invocable<F&, ranges::range_reference_t<V>>&& ...
C++ 范围库 std::ranges::transform_view /*sentinel*/()=default; (1)(C++20 起) constexprexplicit/*sentinel*/(ranges::sentinel_t<Base>end); (2)(C++20 起) constexpr/*sentinel*/(/*sentinel*/<!Const>i) requires Const&& std::convertible_to<ranges::sentinel_t<V>,ranges::sentinel_t<Base...
Effectively returns std::invoke(*parent_->fun_, *current_), where *parent_->fun_ is the transformation function stored in the parent transform_view, and current_ is the underlying iterator into V. Parameters(none) Return valueThe transformed element. Notes...
C++ 范围库 std::ranges::transform_view template< class R, class F > transform_view( R&&, F ) -> transform_view<views::all_t<R>, F>;(C++20 起) 为std::ranges::transform_view 提供一个推导指引以允许从 range 和变换函数推导。
std::ranges::views::transform,std::ranges::transform_view Defined in header<ranges> (1) template<ranges::input_rangeV, std::copy_constructibleF> requiresranges::view<V>&& std::is_object_v<F>&& std::regular_invocable<F&,ranges::range_reference_t<V>>&& ...