This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++17 status.

2433. uninitialized_copy()/etc. should tolerate overloaded operator&

Section: 27.11 [specialized.algorithms] Status: C++17 Submitter: Stephan T. Lavavej Opened: 2014-10-01 Last modified: 2017-07-30

Priority: 0

View other active issues in [specialized.algorithms].

View all other issues in [specialized.algorithms].

View all issues with C++17 status.

Discussion:

This restriction isn't necessary anymore. In fact, this is the section that defines addressof().

(Editorial note: We can depict these algorithms as calling addressof() instead of std::addressof() thanks to 16.4.2.2 [contents]/3 "Whenever a name x defined in the standard library is mentioned, the name x is assumed to be fully qualified as ::std::x, unless explicitly described otherwise.")

[Urbana 2014-11-07: Move to Ready]

Proposed resolution:

This wording is relative to N3936.

  1. Change 27.11 [specialized.algorithms] p1 as depicted:

    -1- All the iterators that are used as formal template parameters in the following algorithms are required to have their operator* return an object for which operator& is defined and returns a pointer to T. In the algorithm uninitialized_copy, the formal template parameter InputIterator is required to satisfy the requirements of an input iterator (24.2.3). In all of the following algorithms, the formal template parameter ForwardIterator is required to satisfy the requirements of a forward iterator (24.2.5), and is required to have the property that no exceptions are thrown from increment, assignment, comparison, or indirection through valid iterators. In the following algorithms, if an exception is thrown there are no effects.

  2. Change 27.11.5 [uninitialized.copy] p1 as depicted:

    -1- Effects:

    for (; first != last; ++result, ++first)
      ::new (static_cast<void*>(addressof(&*result)))
        typename iterator_traits<ForwardIterator>::value_type(*first);
    
  3. Change 27.11.5 [uninitialized.copy] p3 as depicted:

    -3- Effects:

    for (; n > 0; ++result, ++first, --n) {
      ::new (static_cast<void*>(addressof(&*result)))
        typename iterator_traits<ForwardIterator>::value_type(*first);
    }
    
  4. Change 27.11.7 [uninitialized.fill] p1 as depicted:

    -1- Effects:

    for (; first != last; ++first)
      ::new (static_cast<void*>(addressof(&*first)))
        typename iterator_traits<ForwardIterator>::value_type(x);
    
  5. Change [uninitialized.fill.n] p1 as depicted:

    -1- Effects:

    for (; n--; ++first)
      ::new (static_cast<void*>(addressof(&*first)))
        typename iterator_traits<ForwardIterator>::value_type(x);
    return first;