JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
jh::ranges::to_fn< C > Struct Template Referencefinal

Function object implementing jh::ranges::to. More...

#include <jh/ranges/to.h>

Public Member Functions

template<std::ranges::range R, typename... Args>
constexpr auto operator() (R &&r, Args &&... args) const
 Construct container C directly from range R and optional arguments.
template<typename... Args>
requires (sizeof...(Args) == 0 || !(std::ranges::range< std::remove_cvref_t< std::tuple_element_t<0, std::tuple<Args...>> > >))
constexpr auto operator() (Args &&... args) const
 Return a closure object capturing constructor arguments for pipe usage.

Detailed Description

template<typename C>
struct jh::ranges::to_fn< C >

Function object implementing jh::ranges::to.

Provides both direct-call and pipe-style interfaces for constructing a closable container from a compatible range.

Direct form

constexpr to_fn< C > to
Global instance of the to adaptor.
Definition to.h:347

Pipe form

With extra arguments

std::pmr::monotonic_buffer_resource pool;
auto pmr_vec = v | jh::ranges::to<std::pmr::vector<int>>(std::pmr::polymorphic_allocator<int>(&pool));

The adaptor supports additional constructor arguments for allocator- or parameterized container types and automatically deduces the correct construction path.

Template Parameters
CThe target container type.
See also
jh::ranges::to_adaptor
jh::ranges::to

The documentation for this struct was generated from the following file:
  • include/jh/ranges/to.h