Files
2025-10-25 03:02:53 +03:00

5.5 KiB
Raw Permalink Blame History

[range.adaptor.object]

25 Ranges library [ranges]

25.7 Range adaptors [range.adaptors]

25.7.2 Range adaptor objects [range.adaptor.object]

1

#

A range adaptor closure object is a unary function object that accepts a range argument.

For a range adaptor closure object C and an expression R such thatdecltype((R)) models range, the following expressions are equivalent:C(R) R | C

Given an additional range adaptor closure object D, the expression C | D produces another range adaptor closure object E.

E is a perfect forwarding call wrapper ([func.require]) with the following properties:

  • (1.1)

    Its target object is an object d of type decay_t<decltype((D))> direct-non-list-initialized with D.

  • (1.2)

    It has one bound argument entity, an object c of type decay_t<decltype((C))> direct-non-list-initialized with C.

  • (1.3)

    Its call pattern is d(c(arg)), where arg is the argument used in a function call expression of E.

The expression C | D is well-formed if and only if the initializations of the state entities of E are all well-formed.

2

#

Given an object t of type T, where

t is a unary function object that accepts a range argument,

T models derived_from<range_adaptor_closure>,

T has no other base classes of type range_adaptor_closure for any other type U, and

T does not model range

then the implementation ensures that t is a range adaptor closure object.

3

#

The template parameter D for range_adaptor_closure may be an incomplete type.

If an expression of type cv D is used as an operand to the | operator,D shall be complete and model derived_from<range_adaptor_closure>.

The behavior of an expression involving an object of type cv D as an operand to the | operator is undefined if overload resolution selects a program-defined operator| function.

4

#

If an expression of type cv U is used as an operand to the | operator, where U has a base class of type range_adaptor_closure for some type T other than U, the behavior is undefined.

5

#

The behavior of a program that adds a specialization for range_adaptor_closure is undefined.

6

#

A range adaptor object is a customization point object ([customization.point.object]) that accepts a viewable_range as its first argument and returns a view.

7

#

If a range adaptor object accepts only one argument, then it is a range adaptor closure object.

8

#

If a range adaptor object adaptor accepts more than one argument, then let range be an expression such that decltype((range)) models viewable_range, let args... be arguments such that adaptor(range, args...) is a well-formed expression as specified in the rest of subclause [range.adaptors], and let BoundArgs be a pack that denotes decay_t<decltype((args))>....

The expression adaptor(args...) produces a range adaptor closure object f that is a perfect forwarding call wrapper ([func.require]) with the following properties:

  • (8.1)

    Its target object is a copy of adaptor.

  • (8.2)

    Its bound argument entities bound_args consist of objects of types BoundArgs... direct-non-list-initialized with std::forward<decltype((args))>(args)..., respectively.

  • (8.3)

    Its call pattern is adaptor(r, bound_args...), where r is the argument used in a function call expression of f.

The expression adaptor(args...) is well-formed if and only if the initialization of the bound argument entities of the result, as specified above, are all well-formed.