Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/iterator/indirect unary predicate"

From cppreference.com
< cpp‎ | iterator
(Applied P2997R1 (Removing the common reference requirement from the indirectly invocable concepts).)
(~ apply P2997R1 as DR20)
 
(One intermediate revision by one user not shown)
Line 3: Line 3:
 
{{dcl begin}}
 
{{dcl begin}}
 
{{dcl header|iterator}}
 
{{dcl header|iterator}}
{{dcl rev begin}}
+
{{dcl|since=c++20|1=
{{dcl|since=c++20|until=c++26|1=
+
 
template< class F, class I >
 
template< class F, class I >
 
concept indirect_unary_predicate =
 
concept indirect_unary_predicate =
 
     std::indirectly_readable<I> &&
 
     std::indirectly_readable<I> &&
 
     std::copy_constructible<F> &&
 
     std::copy_constructible<F> &&
     std::predicate<F&, std::iter_value_t<I>&> &&
+
     std::predicate<F&, /*indirect-value-t*/<I>> &&
    std::predicate<F&, std::iter_reference_t<I>> &&
+
    std::predicate<F&, std::iter_common_reference_t<I>>;
+
}}
+
{{dcl|since=c++26|1=
+
template< class F, class I >
+
concept indirect_unary_predicate =
+
    std::indirectly_readable<I> &&
+
    std::copy_constructible<F> &&
+
    std::predicate<F&, std::iter_value_t<I>&> &&
+
 
     std::predicate<F&, std::iter_reference_t<I>>;
 
     std::predicate<F&, std::iter_reference_t<I>>;
 
}}
 
}}
{{dcl rev end}}
 
 
{{dcl end}}
 
{{dcl end}}
  
 
The concept {{tt|indirect_unary_predicate}} specifies requirements for algorithms that call unary predicates as their arguments. The key difference between this concept and {{lc|std::predicate}} is that it is applied to the type that {{tt|I}} references, rather than {{tt|I}} itself.
 
The concept {{tt|indirect_unary_predicate}} specifies requirements for algorithms that call unary predicates as their arguments. The key difference between this concept and {{lc|std::predicate}} is that it is applied to the type that {{tt|I}} references, rather than {{tt|I}} itself.
 +
 +
===Defect reports===
 +
{{dr list begin}}
 +
{{dr list item|paper=P2609R3|std=C++20|before=one of the requirements was defined in terms of {{c|std::iter_value_t<I>&}}<br>which mishandled projections resulting in incompatibility with predicate {{c|F&}}|after=defined in terms of {{c|/*indirect-value-t*/<I>}}<br>to correctly handle such projections}}
 +
{{dr list item|paper=P2997R1|std=C++20|before={{tt|indirect_unary_predicate}} required {{c|F&}} to satisfy {{lconcept|predicate}} with<br>{{c|std::iter_common_reference_t<I>}}|after=does not require}}
 +
{{dr list end}}
  
 
{{langlinks|es|ja|zh}}
 
{{langlinks|es|ja|zh}}

Latest revision as of 17:59, 23 August 2024

 
 
Iterator library
Iterator concepts
Iterator primitives
Algorithm concepts and utilities
Indirect callable concepts
indirect_unary_predicate
(C++20)
Common algorithm requirements
(C++20)
(C++20)
(C++20)
Utilities
(C++20)
Iterator adaptors
Range access
(C++11)(C++14)
(C++14)(C++14)  
(C++11)(C++14)
(C++14)(C++14)  
(C++17)(C++20)
(C++17)
(C++17)
 
Defined in header <iterator>
template< class F, class I >

concept indirect_unary_predicate =
    std::indirectly_readable<I> &&
    std::copy_constructible<F> &&
    std::predicate<F&, /*indirect-value-t*/<I>> &&

    std::predicate<F&, std::iter_reference_t<I>>;
(since C++20)

The concept indirect_unary_predicate specifies requirements for algorithms that call unary predicates as their arguments. The key difference between this concept and std::predicate is that it is applied to the type that I references, rather than I itself.

[edit] Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

DR Applied to Behavior as published Correct behavior
P2609R3 C++20 one of the requirements was defined in terms of std::iter_value_t<I>&
which mishandled projections resulting in incompatibility with predicate F&
defined in terms of /*indirect-value-t*/<I>
to correctly handle such projections
P2997R1 C++20 indirect_unary_predicate required F& to satisfy predicate with
std::iter_common_reference_t<I>
does not require