Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/named req/ConstexprIterator"

From cppreference.com
< cpp‎ | named req
m (Text replace - "cpp/concept" to "cpp/named req")
m (+ added link to std::optional (c++26))
 
(18 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{cpp/named req/title|ConstexprIterator}}
+
{{cpp/named req/title|ConstexprIterator|notes={{mark since c++20}}}}
 
{{cpp/named req/navbar}}
 
{{cpp/named req/navbar}}
  
A {{tt|ConstexprIterator}} is an {{concept|Iterator}} that can be used during constant expression evaluation.
+
A {{named req|ConstexprIterator}} is a {{named req|Iterator}} that can be used during constant expression evaluation.
  
 
===Requirements===
 
===Requirements===
The type {{tt|It}} satisfies {{tt|ConstexprIterator}} if
+
The type {{c|It}} satisfies {{named req/core|ConstexprIterator}} if
  
* The type {{tt|It}} satisfies some iterator concept {{tt|MeowIterator}}
+
* The type {{c|It}} satisfies some iterator requirements {{named req/core|MeowIterator}}
  
 
And, for every  
 
And, for every  
* {{tt|purr}}, an operation on {{tt|It}} that is required to be supported by {{tt|MeowIterator}},
+
* {{c|purr}}, an operation on {{c|It}} that is required to be supported by {{named req/core|MeowIterator}},
* {{tt|kittens...}}, a set of arguments to {{tt|purr}} that meets the requirements for that operation,
+
* {{c|kittens...}}, a set of arguments to {{c|purr}} that meets the requirements for that operation,
  
 
Then
 
Then
  
* {{tt|purr(kittens...)}} may be used in a constant expression if {{tt|kittens...}} can be so used, unless {{tt|purr}} is
+
* {{c|purr(kittens...)}} may be used in a constant expression if {{c|kittens...}} can also be used.
 
+
:* construction of {{tt|It}} with a singular value;
+
:* an explicit [[cpp/language/destructor|destructor]] call (if {{tt|It}} is a class type); or
+
:* a [[cpp/language/operator_member_access#Built-in_member_access_operators|pseudo-destructor call]] (if {{tt|It}} is a scalar type)
+
  
 
===Standard library===
 
===Standard library===
 +
The following standard library types are {{named req|ConstexprIterator}}s.
  
The following standard library types are {{concept|ConstexprIterator}}s.
+
* {{ltt|cpp/container/array|array::iterator}} and {{ltt|cpp/container/array|array::const_iterator}}.
 
+
* {{ltt|cpp/container/array|array::iterator}}.
+
 
* {{ltt|cpp/string/basic_string_view|basic_string_view::iterator}}.
 
* {{ltt|cpp/string/basic_string_view|basic_string_view::iterator}}.
 +
* {{ltt|cpp/container/span|span::iterator}}.
 +
* {{ltt|cpp/container/vector|vector::iterator}} and {{ltt|cpp/container/vector|vector::const_iterator}}.
 +
{{rrev|since=c++26|
 +
* {{ltt|cpp/utility/optional|optional::iterator}} and {{ltt|cpp/utility/optional|optional::const_iterator}}
 +
}}
  
 
===See also===
 
===See also===
* [[cpp/iterator|Iterator library]]
+
{{dsc begin}}
 +
{{see_also_iterator_library}}
 +
{{dsc end}}
  
{{langlinks|zh}}
+
{{langlinks|es|ja|ru|zh}}

Latest revision as of 16:08, 25 August 2024

 
 
C++ named requirements
 

A ConstexprIterator is a LegacyIterator that can be used during constant expression evaluation.

[edit] Requirements

The type It satisfies ConstexprIterator if

  • The type It satisfies some iterator requirements MeowIterator

And, for every

  • purr, an operation on It that is required to be supported by MeowIterator,
  • kittens..., a set of arguments to purr that meets the requirements for that operation,

Then

  • purr(kittens...) may be used in a constant expression if kittens... can also be used.

[edit] Standard library

The following standard library types are ConstexprIterators.

(since C++26)

[edit] See also

Iterator library provides definitions for iterators, iterator traits, adaptors, and utility functions