9 Iterators library [iterators]

9.4 Indirect callable requirements [indirectcallable]

9.4.1 General [indirectcallable.general]

There are several concepts that group requirements of algorithms that take callable objects ( ISO/IEC 14882:2014 §[func.require]) as arguments.

9.4.2 Indirect callables [indirectcallable.indirectinvocable]

The indirect callable concepts are used to constrain those algorithms that accept callable objects ( ISO/IEC 14882:2014 §[func.def]) as arguments.

  template <class F, class I>
  concept bool IndirectUnaryInvocable =
    Readable<I> &&
    CopyConstructible<F> &&
    Invocable<F&, value_type_t<I>&> &&
    Invocable<F&, reference_t<I>> &&
    Invocable<F&, iter_common_reference_t<I>> &&
    CommonReference<
      result_of_t<F&(value_type_t<I>&)>,
      result_of_t<F&(reference_t<I>&&)>>;

  template <class F, class I>
  concept bool IndirectRegularUnaryInvocable =
    Readable<I> &&
    CopyConstructible<F> &&
    RegularInvocable<F&, value_type_t<I>&> &&
    RegularInvocable<F&, reference_t<I>> &&
    RegularInvocable<F&, iter_common_reference_t<I>> &&
    CommonReference<
      result_of_t<F&(value_type_t<I>&)>,
      result_of_t<F&(reference_t<I>&&)>>;

  template <class F, class I>
  concept bool IndirectUnaryPredicate =
    Readable<I> &&
    CopyConstructible<F> &&
    Predicate<F&, value_type_t<I>&> &&
    Predicate<F&, reference_t<I>> &&
    Predicate<F&, iter_common_reference_t<I>>;

  template <class F, class I1, class I2 = I1>
  concept bool IndirectRelation =
    Readable<I1> && Readable<I2> &&
    CopyConstructible<F> &&
    Relation<F&, value_type_t<I1>&, value_type_t<I2>&> &&
    Relation<F&, value_type_t<I1>&, reference_t<I2>> &&
    Relation<F&, reference_t<I1>, value_type_t<I2>&> &&
    Relation<F&, reference_t<I1>, reference_t<I2>> &&
    Relation<F&, iter_common_reference_t<I1>, iter_common_reference_t<I2>>;

  template <class F, class I1, class I2 = I1>
  concept bool IndirectStrictWeakOrder =
    Readable<I1> && Readable<I2> &&
    CopyConstructible<F> &&
    StrictWeakOrder<F&, value_type_t<I1>&, value_type_t<I2>&> &&
    StrictWeakOrder<F&, value_type_t<I1>&, reference_t<I2>> &&
    StrictWeakOrder<F&, reference_t<I1>, value_type_t<I2>&> &&
    StrictWeakOrder<F&, reference_t<I1>, reference_t<I2>> &&
    StrictWeakOrder<F&, iter_common_reference_t<I1>, iter_common_reference_t<I2>>;

  template <class> struct indirect_result_of { };

  template <class F, class... Is>
    requires Invocable<F, reference_t<Is>...>
  struct indirect_result_of<F(Is...)> :
    result_of<F(reference_t<Is>&&...)> { };

9.4.3 Class template projected [projected]

The projected class template is intended for use when specifying the constraints of algorithms that accept callable objects and projections ([defns.projection]). It bundles a Readable type I and a function Proj into a new Readable type whose reference type is the result of applying Proj to the reference_t of I.

  template <Readable I, IndirectRegularUnaryInvocable<I> Proj>
  struct projected {
    using value_type = remove_cv_t<remove_reference_t<indirect_result_of_t<Proj&(I)>>>;
    indirect_result_of_t<Proj&(I)> operator*() const;
  };

  template <WeaklyIncrementable I, class Proj>
  struct difference_type<projected<I, Proj>> {
    using type = difference_type_t<I>;
  };

Note: projected is only used to ease constraints specification. Its member function need not be defined. — end note ]