Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:LegacyOutputIterator

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      ALegacyOutputIterator is aLegacyIterator that can write to the pointed-to element.

      An example of a type that implementsLegacyOutputIterator isstd::ostream_iterator.

      WhenLegacyForwardIterator,LegacyBidirectionalIterator, orLegacyRandomAccessIterator satisfies theLegacyOutputIterator requirements in addition to its own requirements, it is described asmutable.

      Contents

      [edit]Requirements

      The typeX satisfiesLegacyOutputIterator if

      And, given

      • o, a value of some type that is writable to the output iterator (there may be multiple types that are writable, e.g. ifoperator= may be a template. There is no notion ofvalue_type as for the input iterators)
      • r, an lvalue of typeX,

      The following expressions must be valid and have their specified effects

      ExpressionReturnEquivalent expressionPre-conditionPost-conditionsNotes
      *r= o(not used)r is dereferenceabler is incrementableAfter this operationr is not required to be dereferenceable and any copies of the previous value ofr are no longer required to be dereferenceable or incrementable.
      ++rX&r is incrementabler and++r designate the same iterator object,r is dereferenceable or past-the-endAfter this operationr is not required to be incrementable and any copies of the previous value ofr are no longer required to be dereferenceable or incrementable.
      r++convertible toconst X&X temp= r;

      ++r;
      return temp;

      *r++= o(not used)*r= o;

      ++r;

      [edit]Notes

      The only valid use ofoperator* with an output iterator is on the left of an assignment:operator* may return a proxy object, which defines a memberoperator= (which may be a template).

      Equality and inequality may not be defined for output iterators. Even if anoperator== is defined,x== y need not imply++x==++y.

      Assignment through the same value of an output iterator happens only once: algorithms on output iterators must be single-pass algorithms.

      Assignment through an output iterator is expected to alternate with incrementing. Double-increment is undefined behavior (C++ standard currently claims that double increment is supported, contrary to the STL documentation; this isLWG issue 2035).

      Pure output-only iterator is allowed to declare itsiterator_traits<X>::value_type,iterator_traits<X>::difference_type,iterator_traits<X>::pointer, anditerator_traits<X>::reference to bevoid (and iterators such asstd::back_insert_iterator do just that except fordifference_type, which is now defined to satisfystd::output_iterator(since C++20)).

      [edit]Standard library

      The following standard library iterators are output iterators that are not forward iterators:

      output iterator that writes tostd::basic_ostream
      (class template)[edit]
      output iterator that writes tostd::basic_streambuf
      (class template)[edit]
      iterator adaptor for insertion into a container
      (class template)[edit]
      iterator adaptor for insertion at the end of a container
      (class template)[edit]
      iterator adaptor for insertion at the front of a container
      (class template)[edit]

      [edit]See also

      specifies that a type is an output iterator for a given value type, that is, values of that type can be written to it and it can be both pre- and post-incremented
      (concept)[edit]
      Iterator library provides definitions for iterators, iterator traits, adaptors, and utility functions
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/OutputIterator&oldid=177800"

      [8]ページ先頭

      ©2009-2025 Movatter.jp