Doc. no. N3312=11-0082
Date: 2011-09-06
Project: Programming Language C++
Reply to: Alisdair Meredith <lwgchair@gmail.com>

C++ Standard Library Active Issues List (Revision R76)

Revised 2011-09-06 at 13:09:55 UTC

Reference ISO/IEC IS 14882:2003(E)

Also see:

The purpose of this document is to record the status of issues which have come before the Library Working Group (LWG) of the INCITS PL22.16 and ISO WG21 C++ Standards Committee. Issues represent potential defects in the ISO/IEC IS 14882:2003(E) document.

This document contains only library issues which are actively being considered by the Library Working Group, i.e., issues which have a status of New, Open, Ready, or Review. See Library Defect Reports List for issues considered defects and Library Closed Issues List for issues considered closed.

The issues in these lists are not necessarily formal ISO Defect Reports (DR's). While some issues will eventually be elevated to official Defect Report status, other issues will be disposed of in other ways. See Issue Status.

Prior to Revision 14, library issues lists existed in two slightly different versions; a Committee Version and a Public Version. Beginning with Revision 14 the two versions were combined into a single version.

This document includes [bracketed italicized notes] as a reminder to the LWG of current progress on issues. Such notes are strictly unofficial and should be read with caution as they may be incomplete or incorrect. Be aware that LWG support for a particular resolution can quickly change if new viewpoints or killer examples are presented in subsequent discussions.

For the most current official version of this document see http://www.open-std.org/jtc1/sc22/wg21/. Requests for further information about this document should include the document number above, reference ISO/IEC 14882:2003(E), and be submitted to Information Technology Industry Council (ITI), 1250 Eye Street NW, Washington, DC 20005.

Public information as to how to obtain a copy of the C++ Standard, join the standards committee, submit an issue, or comment on an issue can be found in the comp.std.c++ FAQ.

How to submit an issue

  1. Mail your issue to the author of this list.
  2. Specify a short descriptive title. If you fail to do so, the subject line of your mail will be used as the issue title.
  3. If the "From" on your email is not the name you wish to appear as issue submitter, then specify issue submitter.
  4. Provide a brief discussion of the problem you wish to correct. Refer to the latest working draft or standard using [section.tag] and paragraph numbers where appropriate.
  5. Provide proposed wording. This should indicate exactly how you want the standard to be changed. General solution statements belong in the discussion area. This area contains very clear and specific directions on how to modify the current draft. If you are not sure how to word a solution, you may omit this part. But your chances of a successful issue greatly increase if you attempt wording.
  6. It is not necessary for you to use html markup. However, if you want to, you can <ins>insert text like this</ins> and <del>delete text like this</del>. The only strict requirement is to communicate clearly to the list maintainer exactly how you want your issue to look.
  7. It is not necessary for you to specify other html font/formatting mark-up, but if you do the list maintainer will attempt to respect your formatting wishes (as described by html markup, or other common idioms).
  8. It is not necessary for you to specify open date or last modified date (the date of your mail will be used).
  9. It is not necessary for you to cross reference other issues, but you can if you like. You do not need to form the hyperlinks when you do, the list maintainer will take care of that.
  10. One issue per email is best.
  11. Between the time you submit the issue, and the next mailing deadline (date at the top of the Revision History), you own this issue. You control the content, the stuff that is right, the stuff that is wrong, the format, the misspellings, etc. You can even make the issue disappear if you want. Just let the list maintainer know how you want it to look, and he will try his best to accommodate you. After the issue appears in an official mailing, you no longer enjoy exclusive ownership of it.

Revision History

Issue Status

New - The issue has not yet been reviewed by the LWG. Any Proposed Resolution is purely a suggestion from the issue submitter, and should not be construed as the view of LWG.

Open - The LWG has discussed the issue but is not yet ready to move the issue forward. There are several possible reasons for open status:

A Proposed Resolution for an open issue is still not be construed as the view of LWG. Comments on the current state of discussions are often given at the end of open issues in an italic font. Such comments are for information only and should not be given undue importance.

Deferred - The LWG has discussed the issue, is not yet ready to move the issue forward, but neither does it deem the issue significant enough to delay publishing a standard or Technical Report. A typical deferred issue would be seeking to clarify wording that might be technically correct, but easily mis-read.

A Proposed Resolution for a deferred issue is still not be construed as the view of LWG. Comments on the current state of discussions are often given at the end of open issues in an italic font. Such comments are for information only and should not be given undue importance.

Dup - The LWG has reached consensus that the issue is a duplicate of another issue, and will not be further dealt with. A Rationale identifies the duplicated issue's issue number.

NAD - The LWG has reached consensus that the issue is not a defect in the Standard.

NAD Editorial - The LWG has reached consensus that the issue can either be handled editorially, or is handled by a paper (usually linked to in the rationale).

NAD Concepts - The LWG has reached consensus that the issue is NAD for now, but represents a real issue when the library is done with language-supported concepts.

NAD Future - In addition to the regular status, the LWG believes that this issue should be revisited at the next revision of the standard.

Review - Exact wording of a Proposed Resolution is now available for review on an issue for which the LWG previously reached informal consensus.

Ready - The LWG has reached consensus that the issue is a defect in the Standard, the Proposed Resolution is correct, and the issue is ready to forward to the full committee for further action as a Defect Report (DR).

Resolved - The LWG has reached consensus that the issue is a defect in the Standard, but the resolution adopted to resolve the issue came via some other mechanism than this issue in the list - typically by applying a formal paper, occasionally as a side effect of consolidating several interacting issue resolutions into a single issue.

DR - (Defect Report) - The full WG21/PL22.16 committee has voted to forward the issue to the Project Editor to be processed as a Potential Defect Report. The Project Editor reviews the issue, and then forwards it to the WG21 Convenor, who returns it to the full committee for final disposition. This issues list accords the status of DR to all these Defect Reports regardless of where they are in that process.

TC1 - (Technical Corrigenda 1) - The full WG21/PL22.16 committee has voted to accept the Defect Report's Proposed Resolution as a Technical Corrigenda. Action on this issue is thus complete and no further action is possible under ISO rules.

CD1 - (Committee Draft 2008) - The full WG21/PL22.16 committee has voted to accept the Defect Report's Proposed Resolution into the Fall 2008 Committee Draft.

TRDec - (Decimal TR defect) - The LWG has voted to accept the Defect Report's Proposed Resolution into the Decimal TR. Action on this issue is thus complete and no further action is expected.

WP - (Working Paper) - The proposed resolution has not been accepted as a Technical Corrigendum, but the full WG21/PL22.16 committee has voted to apply the Defect Report's Proposed Resolution to the working paper.

Tentatively - This is a status qualifier. The issue has been reviewed online, or at an unofficial meeting, but not in an official meeting, and some support has been formed for the qualified status. Tentatively qualified issues may be moved to the unqualified status and forwarded to full committee (if Ready) within the same meeting. Unlike Ready issues, Tentatively Ready issues will be reviewed in subcommittee prior to forwarding to full committee. When a status is qualified with Tentatively, the issue is still considered active.

Pending - This is a status qualifier. When prepended to a status this indicates the issue has been processed by the committee, and a decision has been made to move the issue to the associated unqualified status. However for logistical reasons the indicated outcome of the issue has not yet appeared in the latest working paper.

Issues are always given the status of New when they first appear on the issues list. They may progress to Open or Review while the LWG is actively working on them. When the LWG has reached consensus on the disposition of an issue, the status will then change to Dup, NAD, or Ready as appropriate. Once the full J16 committee votes to forward Ready issues to the Project Editor, they are given the status of Defect Report ( DR). These in turn may become the basis for Technical Corrigenda (TC1), or are closed without action other than a Record of Response (Resolved ). The intent of this LWG process is that only issues which are truly defects in the Standard move to the formal ISO DR status.

Active Issues


1169. num_get not fully compatible with strto*

Section: 22.4.2.1.2 [facet.num.get.virtuals] Status: Review Submitter: Cosmin Truta Opened: 2009-07-04 Last modified: 2011-09-06

View all other issues in [facet.num.get.virtuals].

View all issues with Review status.

Discussion:

As specified in the latest draft, N2914, num_get is still not fully compatible with the following C functions: strtoul, strtoull, strtof and strtod.

In C, when conversion of a string to an unsigned integer type falls outside the representable range, strtoul and strtoull return ULONG_MAX and ULLONG_MAX, respectively, regardless whether the input field represents a positive or a negative value. On the other hand, the result of num_get conversion of negative values to unsigned integer types is zero. This raises a compatibility issue.

Moreover, in C, when conversion of a string to a floating-point type falls outside the representable range, strtof, strtod and strtold return ±HUGE_VALF, ±HUGE_VAL and ±HUGE_VALL, respectively. On the other hand, the result of num_get conversion of such out-of-range floating-point values results in the most positive/negative representable value. Although many C library implementations do implement HUGE_VAL (etc.) as the highest representable (which is, usually, the infinity), this isn't required by the C standard. The C library specification makes no statement regarding the value of HUGE_VAL and friends, which potentially raises the same compatibility issue as in the above case of unsigned integers. In addition, neither C nor C++ define symbolic constants for the maximum representable floating-point values (they only do so only for the maximum representable finite floating-point values), which raises a usability issue (it would be hard for the programmer to check the result of num_get against overflow).

As such, we propose to adjust the specification of num_get to closely follow the behavior of all of its underlying C functions.

[ 2010 Rapperswil: ]

Some concern that this is changing the specification for an existing C++03 function, but it was pointed out that this was underspecified as resolved by issue 23. This is clean-up for that issue in turn. Some concern that we are trying to solve the same problem in both clause 22 and 27.

Bill: There's a change here as to whether val is stored to in an error case.

Pablo: Don't think this changes whether val is stored to or not, but changes the value that is stored.

Bill: Remembers having skirmishes with customers and testers as to whether val is stored to, and the resolution was not to store in error cases.

Howard: Believes since C++03 we made a change to always store in overflow.

Everyone took some time to review the issue.

Pablo: C++98 definitely did not store any value during an error condition.

Dietmar: Depends on the question of what is considered an error, and whether overflow is an error or not, which was the crux of LWG 23.

Pablo: Yes, but given the "zero, if the conversion function fails to convert the entire field", we are requiring every error condition to store.

Bill: When did this happen?

Alisdair: One of the last two or three meetings.

Dietmar: To store a value in case of failure is a very bad idea.

Move to Open, needs more study.

[2011-03-24 Madrid meeting]

Move to deferred

[ 2011 Bloomington ]

The proposed wording looks good, no-one sure why this was held back before. Move to Review.

Proposed resolution:

Change 22.4.2.1.2 [facet.num.get.virtuals] as follows:

Stage 3: The sequence of chars accumulated in stage 2 (the field) is converted to a numeric value by the rules of one of the functions declared in the header <cstdlib>:

The numeric value to be stored can be one of:

The resultant numeric value is stored in val. If the conversion function fails to convert the entire field, or if the field represents a value outside the range of representable values, ios_base::failbit is assigned to err.


1175. unordered complexity

Section: 23.2.5 [unord.req] Status: Review Submitter: Pablo Halpern Opened: 2009-07-17 Last modified: 2011-09-06

View all other issues in [unord.req].

View all issues with Review status.

Discussion:

When I look at the unordered_* constructors, I think the complexity is poorly described and does not follow the style of the rest of the standard.

The complexity for the default constructor is specified as constant. Actually, it is proportional to n, but there are no invocations of value_type constructors or other value_type operations.

For the iterator-based constructor the complexity should be:

Complexity: exactly n calls to construct value_type from InputIterator::value_type (where n = distance(f,l)). The number of calls to key_equal::operator() is proportional to n in the average case and n*n in the worst case.

[ 2010 Rapperswil: ]

Concern that the current wording may require O(1) where that cannot be delivered. We need to look at both the clause 23 requirements tables and the constructor description of each unordered container to be sure.

Howard suggests NAD Editorial as we updated the container requirement tables since this issue was written.

Daniel offers to look deeper, and hopefully produce wording addressing any outstanding concerns at the next meeting.

Move to Open.

[2011-02-26: Daniel provides wording]

I strongly suggest to clean-up the differences between requirement tables and individual specifications. In the usual way, the most specific specifications wins, which is in this case the wrong one. In regard to the concern expressed about missing DefaultConstructible requirements of the value type I disagree: The function argument n is no size-control parameter, but only some effective capacity parameter: No elements will be value-initialized by these constructors. The necessary requirement for the value type, EmplaceConstructible into *this, is already listed in Table 103 — Unordered associative container requirements. Another part of the proposed resolution is the fact that there is an inconsistency of the complexity counting when both a range and a bucket count is involved compared to constructions where only bucket counts are provided: E.g. the construction X a(n); has a complexity of n bucket allocations, but this part of the work is omitted for X a(i, j, n);, even though it is considerable larger (in the average case) for n ≫ distance(i, j).

[2011-03-24 Madrid meeting]

Move to deferred

[ 2011 Bloomington ]

The proposed wording looks good. Move to Review.

Proposed resolution:

  1. Modify the following rows in Table 103 — Unordered associative container requirements to add the explicit bucket allocation overhead of some constructions. As editorial recommendation it is suggested not to shorten the sum 𝒪(n) + 𝒪(N) to 𝒪(n + N), because two different work units are involved.

    Table 103 — Unordered associative container requirements (in addition to container)
    Expression Return type Assertion/note pre-/post-condition Complexity
    X(i, j, n, hf, eq)
    X a(i, j, n, hf, eq)
    X
    Effects: Constructs an empty container with at least n
    buckets, using hf as the hash function and eq as the key
    equality predicate, and inserts elements from [i, j) into it.
    Average case 𝒪(n) + 𝒪(N) (N is distance(i, j)),
    worst case 𝒪(n) + 𝒪(N2)
    X(i, j, n, hf)
    X a(i, j, n, hf)
    X
    Effects: Constructs an empty container with at least n
    buckets, using hf as the hash function and key_equal() as the key
    equality predicate, and inserts elements from [i, j) into it.
    Average case 𝒪(n) + 𝒪(N) (N is distance(i, j)),
    worst case 𝒪(n) + 𝒪(N2)
    X(i, j, n)
    X a(i, j, n)
    X
    Effects: Constructs an empty container with at least n
    buckets, using hasher() as the hash function and key_equal() as the key
    equality predicate, and inserts elements from [i, j) into it.
    Average case 𝒪(n) + 𝒪(N) (N is distance(i, j)),
    worst case 𝒪(n) + 𝒪(N2)
  2. Modify 23.5.4.2 [unord.map.cnstr] p. 1-4 as indicated (The edits of p. 1 and p. 3 attempt to fix some editorial oversight.):

    explicit unordered_map(size_type n = see below,
                           const hasher& hf = hasher(),
                           const key_equal& eql = key_equal(),
                           const allocator_type& a = allocator_type());
    

    1 Effects: Constructs an empty unordered_map using the specified hash function, key equality function, and allocator, and using at least n buckets. If n is not provided, the number of buckets is implementation-definedimpldefdefault number of buckets in unordered_map. max_load_factor() returns 1.0.

    2 Complexity: Constant if n is not provided, otherwise linear in n to construct the buckets.

    template <class InputIterator>
    unordered_map(InputIterator f, InputIterator l,
                  size_type n = see below,
                  const hasher& hf = hasher(),
                  const key_equal& eql = key_equal(),
                  const allocator_type& a = allocator_type());
    

    3 Effects: Constructs an empty unordered_map using the specified hash function, key equality function, and allocator, and using at least n buckets. If n is not provided, the number of buckets is implementation-definedimpldefdefault number of buckets in unordered_map. Then inserts elements from the range [f, l). max_load_factor() returns 1.0.

    4 Complexity: Average case linear, worst case quadraticConstant if n is not provided, else linear in n to construct the buckets. In the average case linear in N and in the worst case quadratic in N to insert the elements, where N is equal to distance(f, l).

  3. Modify 23.5.5.2 [unord.multimap.cnstr] p. 1-4 as indicated (The edits of p. 1 and p. 3 attempt to fix some editorial oversight.):

    explicit unordered_multimap(size_type n = see below,
                                const hasher& hf = hasher(),
                                const key_equal& eql = key_equal(),
                                const allocator_type& a = allocator_type());
    

    1 Effects: Constructs an empty unordered_multimap using the specified hash function, key equality function, and allocator, and using at least n buckets. If n is not provided, the number of buckets is implementation-definedimpldefdefault number of buckets in unordered_multimap. max_load_factor() returns 1.0.

    2 Complexity: Constant if n is not provided, otherwise linear in n to construct the buckets.

    template <class InputIterator>
    unordered_multimap(InputIterator f, InputIterator l,
                       size_type n = see below,
                       const hasher& hf = hasher(),
                       const key_equal& eql = key_equal(),
                       const allocator_type& a = allocator_type());
    

    3 Effects: Constructs an empty unordered_multimap using the specified hash function, key equality function, and allocator, and using at least n buckets. If n is not provided, the number of buckets is implementation-definedimpldefdefault number of buckets in unordered_multimap. Then inserts elements from the range [f, l). max_load_factor() returns 1.0.

    4 Complexity: Average case linear, worst case quadraticConstant if n is not provided, else linear in n to construct the buckets. In the average case linear in N and in the worst case quadratic in N to insert the elements, where N is equal to distance(f, l).

  4. Modify 23.5.6.2 [unord.set.cnstr] p. 1-4 as indicated (The edits of p. 1 and p. 3 attempt to fix some editorial oversight.):

    explicit unordered_set(size_type n = see below,
                           const hasher& hf = hasher(),
                           const key_equal& eql = key_equal(),
                           const allocator_type& a = allocator_type());
    

    1 Effects: Constructs an empty unordered_set using the specified hash function, key equality function, and allocator, and using at least n buckets. If n is not provided, the number of buckets is implementation-definedimpldefdefault number of buckets in unordered_set. max_load_factor() returns 1.0.

    2 Complexity: Constant if n is not provided, otherwise linear in n to construct the buckets.

    template <class InputIterator>
    unordered_set(InputIterator f, InputIterator l,
                  size_type n = see below,
                  const hasher& hf = hasher(),
                  const key_equal& eql = key_equal(),
                  const allocator_type& a = allocator_type());
    

    3 Effects: Constructs an empty unordered_set using the specified hash function, key equality function, and allocator, and using at least n buckets. If n is not provided, the number of buckets is implementation-definedimpldefdefault number of buckets in unordered_set. Then inserts elements from the range [f, l). max_load_factor() returns 1.0.

    4 Complexity: Average case linear, worst case quadraticConstant if n is not provided, else linear in n to construct the buckets. In the average case linear in N and in the worst case quadratic in N to insert the elements, where N is equal to distance(f, l).

  5. Modify 23.5.7.2 [unord.multiset.cnstr] p. 1-4 as indicated (The edits of p. 1 and p. 3 attempt to fix some editorial oversight.):

    explicit unordered_multiset(size_type n = see below,
                                const hasher& hf = hasher(),
                                const key_equal& eql = key_equal(),
                                const allocator_type& a = allocator_type());
    

    1 Effects: Constructs an empty unordered_multiset using the specified hash function, key equality function, and allocator, and using at least n buckets. If n is not provided, the number of buckets is implementation-definedimpldefdefault number of buckets in unordered_multiset. max_load_factor() returns 1.0.

    2 Complexity: Constant if n is not provided, otherwise linear in n to construct the buckets.

    template <class InputIterator>
    unordered_multiset(InputIterator f, InputIterator l,
                       size_type n = see below,
                       const hasher& hf = hasher(),
                       const key_equal& eql = key_equal(),
                       const allocator_type& a = allocator_type());
    

    3 Effects: Constructs an empty unordered_multiset using the specified hash function, key equality function, and allocator, and using at least n buckets. If n is not provided, the number of buckets is implementation-definedimpldefdefault number of buckets in unordered_multiset. Then inserts elements from the range [f, l). max_load_factor() returns 1.0.

    4 Complexity: Average case linear, worst case quadraticConstant if n is not provided, else linear in n to construct the buckets. In the average case linear in N and in the worst case quadratic in N to insert the elements, where N is equal to distance(f, l).


1213. Meaning of valid and singular iterator underspecified

Section: 24.2 [iterator.requirements] Status: Deferred Submitter: Daniel Krügler Opened: 2009-09-19 Last modified: 2011-03-24

View all other issues in [iterator.requirements].

View all issues with Deferred status.

Discussion:

The terms valid iterator and singular aren't properly defined. The fuzziness of those terms became even worse after the resolution of 208 (including further updates by 278). In 24.2 [iterator.requirements] as of N2723 the standard says now:

5 - These values are called past-the-end values. Values of an iterator i for which the expression *i is defined are called dereferenceable. The library never assumes that past-the-end values are dereferenceable. Iterators can also have singular values that are not associated with any container. [...] Results of most expressions are undefined for singular values; the only exceptions are destroying an iterator that holds a singular value and the assignment of a non-singular value to an iterator that holds a singular value. [...] Dereferenceable values are always non-singular.

10 - An invalid iterator is an iterator that may be singular.

First, issue 208 intentionally removed the earlier constraint that past-the-end values are always non-singular. The reason for this was to support null pointers as past-the-end iterators of e.g. empty sequences. But there seem to exist different views on what a singular (iterator) value is. E.g. according to the SGI definition a null pointer is not a singular value:

Dereferenceable iterators are always nonsingular, but the converse is not true. For example, a null pointer is nonsingular (there are well defined operations involving null pointers) even thought it is not dereferenceable.

and proceeds:

An iterator is valid if it is dereferenceable or past-the-end.

Even if the standard prefers a different meaning of singular here, the change was incomplete, because by restricting feasible expressions of singular iterators to destruction and assignment isn't sufficient for a past-the-end iterator: Of-course it must still be equality-comparable and in general be a readable value.

Second, the standard doesn't clearly say whether a past-the-end value is a valid iterator or not. E.g. 20.6.12 [specialized.algorithms]/1 says:

In all of the following algorithms, the formal template parameter ForwardIterator is required to satisfy the requirements of a forward iterator (24.1.3) [..], and is required to have the property that no exceptions are thrown from [..], or dereference of valid iterators.

The standard should make better clear what "singular pointer" and "valid iterator" means. The fact that the meaning of a valid value has a core language meaning doesn't imply that for an iterator concept the term "valid iterator" has the same meaning.

Let me add a final example: In X [allocator.concepts.members] of N2914 we find:

pointer X::allocate(size_type n);

11 Returns: a pointer to the allocated memory. [Note: if n == 0, the return value is unspecified. —end note]

[..]

void X::deallocate(pointer p, size_type n);

Preconditions: p shall be a non-singular pointer value obtained from a call to allocate() on this allocator or one that compares equal to it.

If singular pointer value would include null pointers this make the preconditions unclear if the pointer value is a result of allocate(0): Since the return value is unspecified, it could be a null pointer. Does that mean that programmers need to check the pointer value for a null value before calling deallocate?

[ 2010-11-09 Daniel comments: ]

A later paper is in preparation.

[ 2010 Batavia: ]

Doesn't need to be resolved for Ox

Proposed resolution:

Consider to await the paper.


1214. Insufficient/inconsistent key immutability requirements for associative containers

Section: 23.2.4 [associative.reqmts] Status: Ready Submitter: Daniel Krügler Opened: 2009-09-20 Last modified: 2011-09-06

View other active issues in [associative.reqmts].

View all other issues in [associative.reqmts].

View all issues with Ready status.

Discussion:

Scott Meyers' mentions on a recent posting on c.s.c++ some arguments that point to an incomplete resolution of 103 and to an inconsistency of requirements on keys in ordered and unordered associative containers:

1) 103 introduced the term immutable without defining it in a unique manner in 23.2.4 [associative.reqmts]/5:

[..] Keys in an associative container are immutable.

According to conventional dictionaries immutable is an unconditional way of saying that something cannot be changed. So without any further explicit allowance a user always runs into undefined behavior if (s)he attempts to modify such a key. IMO this was not the intend of the committee to resolve 103 in that way because the comments suggest an interpretation that should give any user the freedom to modify the key in an explicit way provided it would not affect the sort order in that container.

2) Another observation was that surprisingly no similar 'safety guards' exists against unintentional key changes for the unordered associative containers, specifically there is no such requirement as in 23.2.4 [associative.reqmts]/6 that "both iterator and const_iterator are constant iterators". But the need for such protection against unintentional changes as well as the constraints in which manner any explicit changes may be performed are both missing and necessary, because such changes could potentially change the equivalence of keys that is measured by the hasher and key_equal.

I suggest to fix the unconditional wording involved with "immutable keys" by at least adding a hint for the reader that users may perform such changes in an explicit manner and to perform similar wording changes as 103 did for the ordered associative containers also for the unordered containers.

[ 2010-03-27 Daniel provides wording. ]

This update attempts to provide normative wording that harmonizes the key and function object constraints of associative and unordered containers.

[ 2010 Batavia: ]

We're uncomfortable with the first agenda item, and we can live with the second agenda item being applied before or after Madrid.

[ 2011 Bloomington ]

Further discussion persuades us this issue is Ready (and so moved). We may need a further issue clarifying the notion of key value vs. key object, as object identity appears to be important to this wording.

Proposed resolution:

  1. Change 23.2.4 [associative.reqmts]/2 as indicated: [This ensures that associative containers make better clear what this "arbitrary" type is, as the unordered containers do in 23.2.5 [unord.req]/3]

    2 Each associative container is parameterized on Key and an ordering relation Compare that induces a strict weak ordering (25.4) on elements of Key. In addition, map and multimap associate an arbitrary mapped typetype T with the Key. The object of type Compare is called the comparison object of a container.

  2. Change 23.2.4 [associative.reqmts]/5 as indicated: [This removes the too strong requirement that keys must not be changed at all and brings this line in sync with 23.2.5 [unord.req]/7. We take care about the real constraints by the remaining suggested changes. The rationale provided by LWG 103 didn't really argue why that addition is necessary, and I believe the remaining additions make it clear that any user changes have strong restrictions]:

    5 For set and multiset the value type is the same as the key type. For map and multimap it is equal to pair<const Key, T>. Keys in an associative container are immutable.

  3. Change 23.2.5 [unord.req]/3+4 as indicated: [The current sentence of p.4 has doesn't say something really new and this whole subclause misses to define the concepts of the container-specific hasher object and predicate object. We introduce the term key equality predicate which is already used in the requirements table. This change does not really correct part of this issue, but is recommended to better clarify the nomenclature and the difference between the function objects and the function object types, which is important, because both can potentially be stateful.]

    3 Each unordered associative container is parameterized by Key, by a function object type Hash that meets the Hash requirements (20.2.4) and acts as a hash function for argument values of type Key, and by a binary predicate Pred that induces an equivalence relation on values of type Key. Additionally, unordered_map and unordered_multimap associate an arbitrary mapped type T with the Key.

    4 The container's object of type Hash - denoted by hash - is called the hash function of the container. The container's object of type Pred - denoted by pred - is called the key equality predicate of the container.A hash function is a function object that takes a single argument of type Key and returns a value of type std::size_t.

  4. Change 23.2.5 [unord.req]/5 as indicated: [This adds a similar safe-guard as the last sentence of 23.2.4 [associative.reqmts]/3]

    5 Two values k1 and k2 of type Key are considered equivalent if the container's key equality predicatekey_equal function object returns true when passed those values. If k1 and k2 are equivalent, the container's hash function shall return the same value for both. [Note: thus, when an unordered associative container is instantiated with a non-default Pred parameter it usually needs a non-default Hash parameter as well. — end note] For any two keys k1 and k2 in the same container, calling pred(k1, k2) shall always return the same value. For any key k in a container, calling hash(k) shall always return the same value.

  5. After 23.2.5 [unord.req]/7 add the following new paragraph: [This ensures the same level of compile-time protection that we already require for associative containers. It is necessary for similar reasons, because any change in the stored key which would change it's equality relation to others or would change it's hash value such that it would no longer fall in the same bucket, would break the container invariants]

    7 For unordered_set and unordered_multiset the value type is the same as the key type. For unordered_map and unordered_multimap it is std::pair<const Key, T>.

    For unordered containers where the value type is the same as the key type, both iterator and const_iterator are constant iterators. It is unspecified whether or not iterator and const_iterator are the same type. [Note: iterator and const_iterator have identical semantics in this case, and iterator is convertible to const_iterator. Users can avoid violating the One Definition Rule by always using const_iterator in their function parameter lists. — end note]


1450. [FCD] Contradiction in regex_constants

Section: 28.5.2 [re.matchflag] Status: Open Submitter: BSI Opened: 2010-08-25 Last modified: 2011-09-06

View all issues with Open status.

Discussion:

Addresses GB-127

The Bitmask Type requirements in 17.5.2.1.3 [bitmask.types] p.3 say that all elements on a bitmask type have distinct values, but 28.5.2 [re.matchflag] defines regex_constants::match_default and regex_constants::format_default as elements of the bitmask type regex_constants::match_flag_type, both with value 0. This is a contradiction.

[ Resolution proposed by ballot comment: ]

One of the bitmask elements should be removed from the declaration and should be defined separately, in the same manner as ios_base::adjustfield, ios_base::basefield and ios_base::floatfield are defined by 27.5.3.1.2 [ios::fmtflags] p.2 and Table 120. These are constants of a bitmask type, but are not distinct elements, they have more than one value set in the bitmask. regex_constants::format_default should be specified as a constant with the same value as regex_constants::match_default.

[ 2010-10-31 Daniel comments: ]

Strictly speaking, a bitmask type cannot have any element of value 0 at all, because any such value would contradict the requirement expressed in 17.5.2.1.3 [bitmask.types] p. 3:

for any pair Ci and Cj, Ci & Ci is nonzero

So, actually both regex_constants::match_default and regex_constants::format_default are only constants of the type regex_constants::match_flag_type, and no bitmask elements.

[ 2010-11-03 Daniel comments and provides a proposed resolution: ]

The proposed resolution is written against N3126 and considered as a further improvement of the fixes suggested by n3110.

[

Add the following sentence to 28.5.2 [re.matchflag] paragraph 1:

1 The type regex_constants::match_flag_type is an implementation-defined bitmask type (17.5.2.1.3). Matching a regular expression against a sequence of characters [first,last) proceeds according to the rules of the grammar specified for the regular expression object, modified according to the effects listed in Table 136 for any bitmask elements set. Type regex_constants::match_flag_type also defines the constants regex_constants::match_default and regex_constants::format_default.

]

[ 2011 Bloomington ]

It appears the key problem is the phrasing of the bitmask requirements. Jeremiah supplies updated wording.

Pete Becker has also provided an alternative resolution.

Ammend 17.5.2.1.3 [bitmask.types]:

Change the list of values for "enum bit mask" in p2 from

V0 = 1 << 0, V1 = 1 << 1, V2 = 1 << 2, V3 = 1 << 3, ....

to

V0 = 0, V1 = 1 << 0, V2 = 1 << 1, V3 = 1 << 2, ....

Here, the names C0, C1, etc. represent bitmask elements for this particular bitmask type. All such non-zero elements have distinct values such that, for any pair Ci and Cj where i != j, Ci & Ci is nonzero and Ci & Cj is zero.

Change bullet 3 of paragraph 4:

TheA non-zero value Y is set in the object X if the expression X & Y is nonzero.

Proposed resolution:

Ammend 17.5.2.1.3 [bitmask.types] p3:

Here, the names C0, C1, etc. represent bitmask elements for this particular bitmask type. All such elements have distinct, non-zero values such that, for any pair Ci and Cj where i != j, Ci & Ci is nonzero and Ci & Cj is zero. Additionally, the value 0 is used to represent an empty bitmask, in which no bitmask elements are set.

Add the following sentence to 28.5.2 [re.matchflag] paragraph 1:

1 The type regex_constants::match_flag_type is an implementation-defined bitmask type (17.5.2.1.3). The constants of that type, except for match_default and format_default, are bitmask elements. The match_default and format_default constants are empty bitmasks. Matching a regular expression against a sequence of characters [first,last) proceeds according to the rules of the grammar specified for the regular expression object, modified according to the effects listed in Table 136 for any bitmask elements set.


1526. [FCD] C++ should not impose thread safety requirements on C99 library implementations

Section: 17.6.5.9 [res.on.data.races] Status: Deferred Submitter: BSI Opened: 2011-03-24 Last modified: 2011-09-06

View all issues with Deferred status.

Discussion:

Addresses GB-111

Section 17.6.5.9 [res.on.data.races], Data Race Avoidance, requires the C++ Standard Library to avoid data races that might otherwise result from two threads making calls to C++ Standard Library functions on distinct objects. The C standard library is part of the C++ Standard Library and some C++ Standary library functions (parts of the Localization library, as well as Numeric Conversions in 21.5), are specified to make use of the C standard library. Therefore, the C++ standard indirectly imposes a requirement on the thread safety of the C standard library. However, since the C standard does not address the concept of thread safety conforming C implementations exist that do no provide such guarantees. This conflict needs to be reconciled.

Suggested resolution by national body comment:

remove the requirement to make use of strtol() and sprintf() since these functions depend on the global C locale and thus cannot be made thread safe.

[2011-03-24 Madrid meeting]

Deferred

[ 2011 Bloomington ]

Alisdair: PJ, does this cause a problem in C?

PJ: Every implementation know of is thread safe.

Pete: There a couple of effects that are specified on strtol() and sprintf() which is a problem.

PJ: When C++ talks about C calls it should be "as if" calling the function.

Pete: Culprit is to string stuff. My fault.

PJ: Not your fault. You did what you were told. Distinct resolution to change wording.

Dietmar: What would we break if we change it back?

Pete: Nothing. If implemented on top of thread safe C library you are just fine.

Alisdair: Anyone want to clean up wording and put it back to what Pete gave us?

Alisdair: No volunteers. Do we want to mark as NAD? We could leave it as deferred.

Stefanus: Did original submitter care about this?

Lawrence: There is some work to make local calls thread safe. The resolution would be to call those thread safe version.

Pete: "As if called under single threaded C program"

Action Item (Alisdair): Write wording for this issue.

Rationale:

No consensus to make a change at this time

Proposed resolution:


2003. String exception inconsistency in erase.

Section: 21.4.1 [string.require] Status: Open Submitter: José Daniel García Sánchez Opened: 2010-10-21 Last modified: 2011-03-24

View all other issues in [string.require].

View all issues with Open status.

Discussion:

Clause 21.4.1 [string.require]p3 states:

No erase() or pop_back() member function shall throw any exceptions.

However in 21.4.6.5 [string::erase] p2 the first version of erase has

Throws: out_of_range if pos > size().

[2011-03-24 Madrid meeting]

Beman: Don't want to just change this, can we just say "unless otherwise specified"?

Alisdair: Leave open, but update proposed resolution to say something like "unless otherwise specified".

General agreement that it should be corrected but not a stop-ship.

Action: Update proposed wording for issue 2003 as above, but leave Open.

Proposed resolution:

Update [string.require]p/3:

3 No erase() or pop_back() member function shall throw any exceptions.


2005. unordered_map::insert(T&&) protection should apply to map too

Section: 23.4.4.4 [map.modifiers], 23.4.5.3 [multimap.modifiers], X [unord.map.modifiers], X [unord.multimap.modifiers] Status: Review Submitter: P.J. Plauger Opened: 2010-10-14 Last modified: 2011-09-06

View all issues with Review status.

Discussion:

In [unord.map.modifiers], the signature:

template <class P>
    pair<iterator, bool> insert(P&& obj);

now has an added Remarks paragraph:

Remarks: This signature shall not participate in overload resolution unless P is implicitly convertible to value_type.

The same is true for unordered_multimap.

But neither map nor multimap have this constraint, even though it is a Good Thing(TM) in those cases as well.

[ The submitter suggests: Add the same Remarks clause to [map.modifiers] and [multimap.modifiers]. ]

[ 2010-10-29 Daniel comments: ]

I believe both paragraphs need more cleanup: First, the current Requires element conflict with the Remark; second, it seems to me that the whole single Requires element is intended to be split into a Requires and an Effects element; third, the reference to tuple is incorrect (noticed by Paolo Carlini); fourth, it refers to some non-existing InputIterator parameter relevant for a completely different overload; sixth, the return type of the overload with hint is wrong. The following proposed resolution tries to solve these issues as well and uses similar wording as for the corresponding unordered containers. Unfortunately it has some redundancy over Table 99, but I did not remove the specification because of the more general template parameter P - the Table 99 requirements apply only for an argument identical to value_type.

Daniel's Proposed resolution (not current):

  1. Change 23.4.4.4 [map.modifiers] around p. 1 as indicated:
    template <class P> pair<iterator, bool> insert(P&& x);
    template <class P> pair<iterator, bool> insert(const_iterator position, P&& x);
    

    1 Requires: P shall be convertible to value_type is constructible from std::forward<P>(x)..

    If P is instantiated as a reference type, then the argument x is copied from. Otherwise x is considered to be an rvalue as it is converted to value_type and inserted into the map. Specifically, in such cases CopyConstructible is not required of key_type or mapped_type unless the conversion from P specifically requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type must be CopyConstructible). The signature taking InputIterator parameters does not require CopyConstructible of either key_type or mapped_type if the dereferenced InputIterator returns a non-const rvalue pair<key_type,mapped_type>. Otherwise CopyConstructible is required for both key_type and mapped_type.
    ? Effects: Inserts x converted to value_type if and only if there is no element in the container with key equivalent to the key of value_type(x). For the second form, the iterator position is a hint pointing to where the search should start.

    ? Returns: For the first form, the bool component of the returned pair object indicates whether the insertion took place and the iterator component - or for the second form the returned iterator - points to the element with key equivalent to the key of value_type(x).

    ? Complexity: Logarithmic in general, but amortized constant if x is inserted right before position.

    ? Remarks: These signatures shall not participate in overload resolution unless P is implicitly convertible to value_type.

  2. Change 23.4.5.3 [multimap.modifiers] around p. 1 as indicated:
    template <class P> iterator insert(P&& x);
    template <class P> iterator insert(const_iterator position, P&& x);
    

    1 Requires: P shall be convertible to value_type is constructible from std::forward<P>(x).

    If P is instantiated as a reference type, then the argument x is copied from. Otherwise x is considered to be an rvalue as it is converted to value_type and inserted into the map. Specifically, in such cases CopyConstructible is not required of key_type or mapped_type unless the conversion from P specifically requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type must be CopyConstructible). The signature taking InputIterator parameters does not require CopyConstructible of either key_type or mapped_type if the dereferenced InputIterator returns a non-const rvalue pair<key_type, mapped_type>. Otherwise CopyConstructible is required for both key_type and mapped_type.
    ? Effects: Inserts x converted to value_type. For the second form, the iterator position is a hint pointing to where the search should start.

    ? Returns: An iterator that points to the element with key equivalent to the key of value_type(x).

    ? Complexity: Logarithmic in general, but amortized constant if x is inserted right before position.

    ? Remarks: These signatures shall not participate in overload resolution unless P is implicitly convertible to value_type.

[ 2010 Batavia: ]

We need is_convertible, not is_constructible, both in ordered and unordered containers.

[ 2011 Bloomington ]

The effects of these inserts can be concisely stated in terms of emplace(). Also, the correct term is "EmplaceConstructible", not "constructible".

New wording by Pablo, eliminating duplicate requirements already implied by the effects clause. Move to Review.

Proposed resolution:

  1. Change 23.4.4.4 [map.modifiers] around p. 1 as indicated:
    template <class P> pair<iterator, bool> insert(P&& x);
    template <class P> pair<iterator, bool> insert(const_iterator position, P&& x);
    
    1 Requires: P shall be convertible to value_type.

    If P is instantiated as a reference type, then the argument x is copied from. Otherwise x is considered to be an rvalue as it is converted to value_type and inserted into the map. Specifically, in such cases CopyConstructible is not required of key_type or mapped_type unless the conversion from P specifically requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type must be CopyConstructible). The signature taking InputIterator parameters does not require CopyConstructible of either key_type or mapped_type if the dereferenced InputIterator returns a non-const rvalue pair<key_type,mapped_type>. Otherwise CopyConstructible is required for both key_type and mapped_type.
    ? Effects: The first form is equivalent to return emplace(std::forward<P>(x)). The second form is equivalent to return emplace_hint(position, std::forward<P>(x)).

    ? Remarks: These signatures shall not participate in overload resolution unless P is implicitly convertible to value_type.

  2. Change 23.4.5.3 [multimap.modifiers] around p. 1 as indicated:
    template <class P> iterator insert(P&& x);
    template <class P> iterator insert(const_iterator position, P&& x);
    
    1 Requires: P shall be convertible to value_type.

    If P is instantiated as a reference type, then the argument x is copied from. Otherwise x is considered to be an rvalue as it is converted to value_type and inserted into the map. Specifically, in such cases CopyConstructible is not required of key_type or mapped_type unless the conversion from P specifically requires it (e.g., if P is a tuple<const key_type, mapped_type>, then key_type must be CopyConstructible). The signature taking InputIterator parameters does not require CopyConstructible of either key_type or mapped_type if the dereferenced InputIterator returns a non-const rvalue pair<key_type, mapped_type>. Otherwise CopyConstructible is required for both key_type and mapped_type.
    ? Effects: The first form is equivalent to return emplace(std::forward<P>(x)). The second form is equivalent to return emplace_hint(position, std::forward<P>(x)).

    ? Remarks: These signatures shall not participate in overload resolution unless P is implicitly convertible to value_type.

  3. Change 23.5.4.4 [unord.map.modifers] around p. 1 as indicated:
    template <class P>
    pair<iterator, bool> insert(P&& obj);
    
    1 Requires: value_type is constructible from std::forward<P>(obj).

    2 Effects: equivalent to return emplace(std::forward<P>(obj)). Inserts obj converted to value_type if and only if there is no element in the container with key equivalent to the key of value_type(obj).

    3 Returns: The bool component of the returned pair object indicates whether the insertion took place and the iterator component points to the element with key equivalent to the key of value_type(obj).

    4 Complexity: Average case O(1), worst case O(size()).

    53 Remarks: This signature shall not participate in overload resolution unless P is implicitly convertible to value_type.

    template <class P>
    iterator insert(const_iterator hint, P&& obj);
    
    6 Requires: value_type is constructible from std::forward<P>(obj).

    7? Effects: equivalent to return emplace_hint(hint, std::forward<P>(obj)). Inserts obj converted to value_type if and only if there is no element in the container with key equivalent to the key of value_type(obj). The iterator hint is a hint pointing to where the search should start.

    8 Returns: An iterator that points to the element with key equivalent to the key of value_type(obj).

    9 Complexity: Average case O(1), worst case O(size()).

    10? Remarks: This signature shall not participate in overload resolution unless P is implicitly convertible to value_type.

  4. Change 23.5.5.3 [unord.multimap.modifers] around p. 1 as indicated:
    template <class P>
    iterator insert(P&& obj);
    
    1 Requires: value_type is constructible from std::forward<P>(obj).

    2 Effects: equivalent to return emplace(std::forward<P>(obj)). Inserts obj converted to value_type.

    3 Returns: An iterator that points to the element with key equivalent to the key of value_type(obj).

    4 Complexity: Average case O(1), worst case O(size()).

    53 Remarks: This signature shall not participate in overload resolution unless P is implicitly convertible to value_type.

    template <class P>
    iterator insert(const_iterator hint, P&& obj);
    
    6 Requires: value_type is constructible from std::forward<P>(obj).

    7? Effects: equivalent to return emplace_hint(hint, std::forward<P>(obj)). Inserts obj converted to value_type. The iterator hint is a hint pointing to where the search should start.

    8 Returns: An iterator that points to the element with key equivalent to the key of value_type(obj).

    9 Complexity: Average case O(1), worst case O(size()).

    10? Remarks: This signature shall not participate in overload resolution unless P is implicitly convertible to value_type.


2009. Reporting out-of-bound values on numeric string conversions

Section: 21.5 [string.conversions] Status: Ready Submitter: Alisdair Meredith Opened: 2010-07-19 Last modified: 2011-09-06

View all other issues in [string.conversions].

View all issues with Ready status.

Discussion:

The functions (w)stoi and (w)stof are specified in terms of calling C library APIs for potentially wider types. The integer and floating-point versions have subtly different behaviour when reading values that are too large to convert. The floating point case will throw out_of_bound if the read value is too large to convert to the wider type used in the implementation, but behaviour is undefined if the converted value cannot narrow to a float. The integer case will throw out_of_bounds if the converted value cannot be represented in the narrower type, but throws invalid_argument, rather than out_of_range, if the conversion to the wider type fails due to overflow.

Suggest that the Throws clause for both specifications should be consistent, supporting the same set of fail-modes with the matching set of exceptions.

Proposed resolution:

21.5p3 [string.conversions]

int stoi(const string& str, size_t *idx = 0, int base = 10);
long stol(const string& str, size_t *idx = 0, int base = 10);
unsigned long stoul(const string& str, size_t *idx = 0, int base = 10);
long long stoll(const string& str, size_t *idx = 0, int base = 10);
unsigned long long stoull(const string& str, size_t *idx = 0, int base = 10);

...

3 Throws: invalid_argument if strtol, strtoul, strtoll, or strtoull reports that no conversion could be performed. Throws out_of_range if strtol, strtoul, strtoll or strtoull sets errno to ERANGE, or if the converted value is outside the range of representable values for the return type.

21.5p6 [string.conversions]

float stof(const string& str, size_t *idx = 0);
double stod(const string& str, size_t *idx = 0);
long double stold(const string& str, size_t *idx = 0);

...

6 Throws: invalid_argument if strtod or strtold reports that no conversion could be performed. Throws out_of_range if strtod or strtold sets errno to ERANGE or if the converted value is outside the range of representable values for the return type.


2010. is_* traits for binding operations can't be meaningfully specialized

Section: 20.8.9.1.1 [func.bind.isbind] Status: Ready Submitter: Sean Hunt Opened: 2010-07-19 Last modified: 2011-09-06

View all other issues in [func.bind.isbind].

View all issues with Ready status.

Discussion:

20.8.9.1.1 [func.bind.isbind] says for is_bind_expression:

Users may specialize this template to indicate that a type should be treated as a subexpression in a bind call.

But it also says:

If T is a type returned from bind, is_bind_expression<T> shall be publicly derived from integral_constant<bool, true>, otherwise from integral_constant<bool, false>.

This means that while the user is free to specialize, any specialization would have to be false to avoid violating the second requirement. A similar problem exists for is_placeholder.

[ 2010 Batavia (post meeting session) ]

Alisdair recognises this is clearly a bug introduced by some wording he wrote, the sole purpose of this metafunction is as a customization point for users to write their own bind-expression types that participate in the standard library bind protocol. The consensus was that this should be fixed in Madrid, moved to Open.

[2011-05-13 Jonathan Wakely comments and provides proposed wording]

The requirements are that is_bind_expression<T>::value is true when T is a type returned from bind, false for any other type, except when there's a specialization involving a user-defined type (N.B. 17.6.4.2.1 [namespace.std] means we don't need to say e.g. is_bind_expression<string> is false.)

The obvious way to meet the requirements is for the primary template to derive from integral_constant<bool, false> and for implementations to provide specializations for the unspecified types returned from bind. User-defined specializations can do whatever they like, as long as is_bind_expression::value is sane. There's no reason to forbid users from defining is_bind_expression<user_defined_type>::value=false if that's what they want to do.

Similar reasoning applies to is_placeholder, but a further issue is that 20.8.9.1.1 [func.bind.isbind] contains wording for is_placeholder but contains no definition of it and the sub-clause name only refers to is_bind_expression. The wording below proposes splitting paragraphs 3 and 4 of 20.8.9.1.1 [func.bind.isbind] into a new sub-clause covering is_placeholder.

If the template specializations added by the proposed wording are too vague then they could be preceded by "for exposition only" comments

[2011-05-18 Daniel comments and provides some refinements to the P/R]

Both bind-related type traits should take advantage of the UnaryTypeTrait requirements. Additionally, the updated wording does not imply that the implementation provides several specializations. Wording was used similar to the specification of the uses_allocator type trait (which unfortunately is not expressed in terms of BinaryTypeTrait requirements).

[Bloomington, 2011]

Move to Ready

Proposed resolution:

This wording is relative to the FDIS.

  1. Change 20.8.9.1.1 [func.bind.isbind] to:

    namespace std {
      template<class T> struct is_bind_expression; // see below
        : integral_constant<bool, see below> { };
    }
    

    -1- is_bind_expression can be used to detect function objects generated by bind. bind uses is_bind_expression to detect subexpressions. Users may specialize this template to indicate that a type should be treated as a subexpression in a bind call.

    -2- If T is a type returned from bind, is_bind_expression<T> shall be publicly derived from integral_constant<bool, true>, otherwise from integral_constant<bool, false>Instantiations of the is_bind_expression template shall meet the UnaryTypeTrait requirements ([meta.rqmts]). The implementation shall provide a definition that has a BaseCharacteristic of true_type if T is a type returned from bind, otherwise it shall have a BaseCharacteristic of false_type. A program may specialize this template for a user-defined type T to have a BaseCharacteristic of true_type to indicate that T should be treated as a subexpression in a bind call..

    -3- is_placeholder can be used to detect the standard placeholders _1, _2, and so on. bind uses is_placeholder to detect placeholders. Users may specialize this template to indicate a placeholder type.

    -4- If T is the type of std::placeholders::_J, is_placeholder<T> shall be publicly derived from integral_constant<int, J>, otherwise from integral_constant<int, 0>.

  2. Insert a new sub-clause immediately following sub-clause 20.8.9.1.1 [func.bind.isbind], the suggested sub-clause tag is [func.bind.isplace]:

    20.8.9.1.? Class template is_placeholder [func.bind.isplace]

    namespace std {
      template<class T> struct is_placeholder; // see below
    }
    

    -?- is_placeholder can be used to detect the standard placeholders _1, _2, and so on. bind uses is_placeholder to detect placeholders.

    -?- Instantiations of the is_placeholder template shall meet the UnaryTypeTrait requirements ([meta.rqmts]). The implementation shall provide a definition that has a BaseCharacteristic of integral_constant<int, J> if T is the type of std::placeholders::_J, otherwise it shall have a BaseCharacteristic of integral_constant<int, 0>. A program may specialize this template for a user-defined type T to have a BaseCharacteristic of integral_constant<int, N> with N > 0 to indicate that T should be treated as a placeholder type.


2011. Unexpected output required of strings

Section: 21.4.8.9 [string.io] Status: Review Submitter: James Kanze Opened: 2010-07-23 Last modified: 2011-09-06

View all other issues in [string.io].

View all issues with Review status.

Discussion:

What should the following code output?

#include <string>
#include <iostream>
#include <iomanip>

int main() 
{ 
   std::string test("0X1Y2Z"); 
   std::cout.fill('*'); 
   std::cout.setf(std::ios::internal, std::ios::adjustfield); 
   std::cout << std::setw(8) << test << std::endl; 
} 

I would expect "**0X1Y2Z", and this is what the compilers I have access to (VC++, g++ and Sun CC) do. But according to the standard, it should be "0X**1Y2Z":

21.4.8.9 [string.io]/5:

template<class charT, class traits, class Allocator>
  basic_ostream<charT, traits>&
    operator<<(basic_ostream<charT, traits>& os, const basic_string<charT,traits,Allocator>& str);

Effects: Behaves as a formatted output function (27.7.3.6.1 [ostream.formatted.reqmts]). After constructing a sentry object, if this object returns true when converted to a value of type bool, determines padding as described in 22.4.2.2.2 [facet.num.put.virtuals], then inserts the resulting sequence of characters seq as if by calling os.rdbuf()->sputn(seq, n), where n is the larger of os.width() and str.size(); then calls os.width(0).

22.4.2.2.2 [facet.num.put.virtuals]/5:

[…]

Stage 3: A local variable is initialized as

fmtflags adjustfield= (flags & (ios_base::adjustfield));

The location of any padding is determined according to Table 88.

If str.width() is nonzero and the number of charT's in the sequence after stage 2 is less than str.width(), then enough fill characters are added to the sequence at the position indicated for padding to bring the length of the sequence to str.width(). str.width(0) is called.

Table 88 — Fill padding
State Location
adjustfield == ios_base::left pad after
adjustfield == ios_base::right pad before
adjustfield == internal and a sign occurs in the representation pad after the sign
adjustfield == internal and representation after stage 1 began with 0x or 0X pad after x or X
otherwise pad before

Although it's not 100% clear what "the sequence after stage 2" should mean here, when there is no stage 2, the only reasonable assumption is that it is the contents of the string being output. In the above code, the string being output is "0X1Y2Z", which starts with "0X", so the padding should be inserted "after x or X", and not before the string. I believe that this is a defect in the standard, and not in the three compilers I tried.

[ 2010 Batavia (post meeting session) ]

Consensus that all known implementations are consistent, and disagree with the standard. Preference is to fix the standard before implementations start trying to conform to the current spec, as the current implementations have the preferred form. Howard volunteered to drught for Madrid, move to Open.

[2011-03-24 Madrid meeting]

Daniel Krügler volunteered to provide wording, interacting with Dietmar and Bill.

[2011-06-24 Daniel comments and provides wording]

The same problem applies to the output provided by const char* and similar character sequences as of 27.7.3.6.4 [ostream.inserters.character] p. 5. and even for single character output (!) as described in 27.7.3.6.4 [ostream.inserters.character] p. 1, just consider the character value '-' where '-' is the sign character. In this case Table 91 — "Fill padding" requires to pad after the sign, i.e. the output for the program

#include <iostream>
#include <iomanip>

int main() 
{ 
   char c = '-'; 
   std::cout.fill('*'); 
   std::cout.setf(std::ios::internal, std::ios::adjustfield); 
   std::cout << std::setw(2) << c << std::endl; 
} 

According to the current wording this program should output "-*", but all tested implementations output "*-" instead.

I suggest to replace the reference to 22.4.2.2.2 [facet.num.put.virtuals] in all three places. It is not very complicated to describe the padding rules for simple character sequences "inline". A similar approach is used as for the money_put functions.

[ 2011 Bloomington ]

Move to Review, the resolution seems correct but it would be nice if some factoring of the common words were proposed.

Proposed resolution:

The new wording refers to the FDIS numbering.

  1. Change 21.4.8.9 [string.io]/5 as indicated:

    template<class charT, class traits, class Allocator>
      basic_ostream<charT, traits>&
        operator<<(basic_ostream<charT, traits>& os,
                   const basic_string<charT,traits,Allocator>& str);
    

    -5- Effects: Behaves as a formatted output function ([ostream.formatted.reqmts]). After constructing a sentry object, if this object returns true when converted to a value of type bool, determines padding as described in [facet.num.put.virtuals],follows: A charT character sequence is produced, initially consisting of the elements defined by the range [str.begin(), str.end()). If str.size() is less than os.width(), then enough copies of os.fill() are added to this sequence as necessary to pad to a width of os.width() characters. If (os.flags() & ios_base::adjustfield) == ios_base::left is true, the fill characters are placed after the character sequence; otherwise, they are placed before the character sequence. Tthen inserts the resulting sequence of characters seq as if by calling os.rdbuf()->sputn(seq, n), where n is the larger of os.width() and str.size(); then calls os.width(0).

  2. Change 27.7.3.6.4 [ostream.inserters.character]/1 as indicated (An additional editorial fix is suggested for the first prototype declaration):

    template<class charT, class traits>
      basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
                                              charT c});
    template<class charT, class traits>
      basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
                                              char c);
    // specialization
    template<class traits>
      basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
                                             char c);
    // signed and unsigned
    template<class traits>
      basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
                                             signed char c);
    template<class traits>
      basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
                                             unsigned char c);
    

    -1- Effects: Behaves like a formatted inserter (as described in [ostream.formatted.reqmts]) of out. After a sentry object is constructed it inserts characters. In case c has type char and the character type of the stream is not char, then the character to be inserted is out.widen(c); otherwise the character is c. Padding is determined as described in [facet.num.put.virtuals]follows: A character sequence is produced, initially consisting of the insertion character. If out.width() is greater than one, then enough copies of out.fill() are added to this sequence as necessary to pad to a width of out.width() characters. If (out.flags() & ios_base::adjustfield) == ios_base::left is true, the fill characters are placed after the insertion character; otherwise, they are placed before the insertion character. width(0) is called. The insertion character and any required padding are inserted into out; then calls os.width(0).

  3. Change 27.7.3.6.4 [ostream.inserters.character]/5 as indicated:

    template<class charT, class traits>
      basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
                                              const charT* s);
    template<class charT, class traits>
      basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>& out,
                                              const char* s);
    template<class traits>
      basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
                                             const char* s);
    template<class traits>
      basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
                                             const signed char* s);
    template<class traits>
      basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>& out,
                                             const unsigned char* s);
    

    […]

    -5- Padding is determined as described in [facet.num.put.virtuals]. The n characters starting at s are widened using out.widen ([basic.ios.members])follows: A character sequence is produced, initially consisting of the elements defined by the n characters starting at s widened using out.widen ([basic.ios.members]). If n is less than out.width(), then enough copies of out.fill() are added to this sequence as necessary to pad to a width of out.width() characters. If (out.flags() & ios_base::adjustfield) == ios_base::left is true, the fill characters are placed after the character sequence; otherwise, they are placed before the character sequence. The widened characters and any required padding are inserted into out. Calls width(0).


2012. Associative maps should insert pair, not tuple

Section: 23.4 [associative] Status: Open Submitter: Paolo Carlini Opened: 2010-10-29 Last modified: 2011-09-06

View all other issues in [associative].

View all issues with Open status.

Discussion:

I'm seeing something strange in the paragraphs 23.4.4.4 [map.modifiers] and 23.4.5.3 [multimap.modifiers]: they both talk about tuple<const key_type, mapped_type> but I think they should be talking about pair<const key_type, mapped_type> because, among other reasons, a tuple is not convertible to a pair. If I replace tuple with pair everything makes sense to me.

The proposed resolution is obvious.

[ 2010-11-07 Daniel comments ]

This is by far not the only necessary fix within both sub-clauses. For details see the 2010-10-29 comment in 2005.

[2011-03-24 Madrid meeting]

Paolo: Don't think we can do it now.

Daniel K: Agrees.

[ 2011 Bloomington ]

Consensus that this issue will be resolved by 2005, but held open until that issue is resolved.

Proposed resolution:

Apply the resolution proposed by the 2010-10-29 comment in 2005.


2013. Do library implementers have the freedom to add constexpr?

Section: 17.6.5.6 [constexpr.functions] Status: Ready Submitter: Matt Austern Opened: 2010-11-12 Last modified: 2011-09-06

View all issues with Ready status.

Discussion:

Suppose that a particular function is not tagged as constexpr in the standard, but that, in some particular implementation, it is possible to write it within the constexpr constraints. If an implementer tags such a function as constexpr, is that a violation of the standard or is it a conforming extension?

There are two questions to consider. First, is this allowed under the as-if rule? Second, if it does not fall under as-if, is there (and should there be) any special license granted to implementers to do this anyway, sort of the way we allow elision of copy constructors even though it is detectable by users?

I believe that this does not fall under "as-if", so implementers probably don't have that freedom today. I suggest changing the WP to grant it. Even if we decide otherwise, however, I suggest that we make it explicit.

[ 2011 Bloomington ]

General surprise this was not already in 'Ready' status, and so moved.

Proposed resolution:

In 17.6.4.6 [constexpr.functions], change paragraph 1 to:

This standard explicitly requires that certain standard library functions are constexpr [dcl.constexpr]. Additionally, an implementation may declare any function to be constexpr if that function's definition satisfies the necessary constraints. Within any header that provides any non-defining declarations of constexpr functions or constructors an implementation shall provide corresponding definitions.


2015. Incorrect pre-conditions for some type traits

Section: 20.9.4 [meta.unary] Status: Ready Submitter: Nikolay Ivchenkov Opened: 2010-11-08 Last modified: 2011-09-06

View all other issues in [meta.unary].

View all issues with Ready status.

Discussion:

According to N3126 ‑ 3.9/9,

"Scalar types, trivial class types (Clause 9), arrays of such types and cv‑qualified versions of these types (3.9.3) are collectively called trivial types."

Thus, an array (possibly of unknown bound) can be trivial type, non‑trivial type, or an array type whose triviality cannot be determined because its element type is incomplete.

According to N3126 ‑ Table 45, preconditions for std::is_trivial are defined as follows:

"T shall be a complete type, (possibly cv-qualified) void, or an array of unknown bound"

It seems that "an array of unknown bound" should be changed to "an array of unknown bound of a complete element type". Preconditions for some other templates (e.g., std::is_trivially_copyable, std::is_standard_layout, std::is_pod, and std::is_literal_type) should be changed similarly.

On the other hand, some preconditions look too restrictive. For example, std::is_empty and std::is_polymorphic might accept any incomplete non‑class type.

[2011-02-18: Daniel provides wording proposal]

While reviewing the individual preconditions I could find three different groups of either too weakening or too strengthening constraints:

  1. is_empty/is_polymorphic/is_abstract/has_virtual_destructor:

    These traits can only apply for non‑union class types, otherwise the result must always be false

  2. is_base_of:

    Similar to the previous bullet, but the current wording comes already near to that ideal, it only misses to add the non‑union aspect.

  3. is_trivial/is_trivially_copyable/is_standard_layout/is_pod/is_literal_type:

    These traits always require that std::remove_all_extents<T>::type to be cv void or a complete type.

[Bloomington, 2011]

Move to Ready

Proposed resolution:

  1. Modify the pre-conditions of the following type traits in 20.9.4.3 [meta.unary.prop], Table 48 — Type property predicates:

    Table 48 — Type property predicates
    Template Condition Preconditions
    ...
    template <class T>
    struct is_trivial;
    T is a trivial type (3.9) remove_all_extents<T>::type
    shall be a complete type, or (possibly
    cv-qualified) void, or an array of
    unknown bound
    .
    template <class T>
    struct is_trivially_copyable;
    T is a trivially copyable
    type (3.9)
    remove_all_extents<T>::type
    shall be a complete type, or (possibly
    cv-qualified) void, or an array of
    unknown bound
    .
    template <class T>
    struct is_standard_layout;
    T is a standard-layout
    type (3.9)
    remove_all_extents<T>::type
    shall be a complete type, or (possibly
    cv-qualified) void, or an array of
    unknown bound
    .
    template <class T>
    struct is_pod;
    T is a POD type (3.9) remove_all_extents<T>::type
    shall be a complete type, or (possibly
    cv-qualified) void, or an array of
    unknown bound
    .
    template <class T>
    struct is_literal_type;
    T is a literal type (3.9) remove_all_extents<T>::type
    shall be a complete type, or (possibly
    cv-qualified) void, or an array of
    unknown bound
    .
    template <class T>
    struct is_empty;
    T is a class type, but not a
    union type, with no
    non-static data members
    other than bit-fields of
    length 0, no virtual
    member functions, no
    virtual base classes, and
    no base class B for which
    is_empty<B>::value is
    false.
    T shall be a complete type,
    (possibly cv-qualified) void, or
    an array of unknown bound
    If T
    is a non‑union class type, T
    shall be a complete type
    .
    template <class T>
    struct is_polymorphic;
    T is a polymorphic
    class (10.3)
    T shall be a complete type,
    type, (possibly cv-qualified) void, or
    an array of unknown bound
    If T
    is a non‑union class type, T
    shall be a complete type
    .
    template <class T>
    struct is_abstract;
    T is an abstract
    class (10.4)
    T shall be a complete type,
    type, (possibly cv-qualified) void, or
    an array of unknown bound
    If T
    is a non‑union class type, T
    shall be a complete type
    .
    ...
    template <class T>
    struct has_virtual_destructor;
    T has a virtual
    destructor (12.4)
    T shall be a complete type,
    (possibly cv-qualified) void, or
    an array of unknown bound
    If T
    is a non‑union class type, T
    shall be a complete type
    .
  2. Modify the pre-conditions of the following type traits in 20.9.6 [meta.rel], Table 50 — Type relationship predicates:

    Table 50 — Type relationship predicates
    Template Condition Comments
    ...
    template <class Base, class
    Derived>
    struct is_base_of;
    Base is a base class of
    Derived (10) without
    regard to cv-qualifiers
    or Base and Derived
    are not unions and
    name the same class
    type without regard to
    cv-qualifiers
    If Base and Derived are
    non‑union class types
    and are different types
    (ignoring possible cv-qualifiers)
    then Derived shall be a complete
    type. [ Note: Base classes that
    are private, protected, or
    ambigious are, nonetheless, base
    classes. — end note ]
    ...

2016. Allocators must be no-throw swappable

Section: 17.6.3.5 [allocator.requirements] Status: Open Submitter: Daniel Krügler Opened: 2010-11-17 Last modified: 2011-03-24

View other active issues in [allocator.requirements].

View all other issues in [allocator.requirements].

View all issues with Open status.

Discussion:

During the Batavia meeting it turned out that there is a definition hole for types satisfying the Allocators requirements: The problem became obvious when it was discussed whether all swap functions of Containers with internal data handles can be safely tagged with noexcept or not. While it is correct that the implicit swap function of an allocator is required to be a no-throw operation (because move/copy-constructors and assignment operators are required to be no-throw functions), there are no such requirements for specialized swap overloads for a particular allocator.

But this requirement is essential because the Containers are required to support swappable Allocators, when the value allocator_traits<>::propagate_on_container_swap evaluates to true.

[2011-02-10 Alberto, Daniel, and Pablo collaborated on the proposed wording]

The proposed resolution (based on N3225) attempts to solve the following problems:

  1. Table 44 — Allocator requirements, expression rows X::propagate_on_container_copy_assignment, X::propagate_on_container_move_assignment, and X::propagate_on_container_swap only describe operations, but no requirements. In fact, if and only if these compile-time predicates evaluate to true, the additional requirements CopyAssignable, no-throw MoveAssignable, and no-throw lvalue Swappable, respectively, are imposed on the allocator types.
  2. 23.2.1 [container.requirements.general] p. 9 misses to refer to the correct swap conditions: The current wording does not relate to 17.6.3.2 [swappable.requirements] as it should and omits to mention that lvalues shall be swapped. Additional there is one situation described twice in p. 8 and p. 9 (undefined behaviour unless a.get_allocator() == b.get_allocator() or allocator_traits<allocator_type>::propagate_on_container_swap::value == true), which should be cleaned up.

Proposed resolution:

  1. Adapt the following three rows from Table 44 — Allocator requirements:

    Table 44 — Allocator requirements
    Expression Return type Assertion/note
    pre-/post-condition
    Default
    X::propagate_on_container_copy_assignment Identical to or derived from true_type
    or false_type
    true_type only if an allocator of type X should be copied
    when the client container is copy-assigned. See Note B, below.
    false_type
    X::propagate_on_container_move_assignment Identical to or derived from true_type
    or false_type
    true_type only if an allocator of type X should be moved
    when the client container is move-assigned. See Note B, below.
    false_type
    X::propagate_on_container_swap Identical to or derived from true_type
    or false_type
    true_type only if an allocator of type X should be swapped
    when the client container is swapped. See Note B, below.
    false_type
  2. Following 17.6.3.5 [allocator.requirements] p. 3 insert a new normative paragraph:

    Note B: If X::propagate_on_container_copy_assignment::value is true, X shall satisfy the CopyAssignable requirements (Table 39 [copyassignable]). If X::propagate_on_container_move_assignment::value is true, X shall satisfy the MoveAssignable requirements (Table 38 [moveassignable]) and the move operation shall not throw exceptions. If X::propagate_on_container_swap::value is true, lvalues of X shall be swappable (17.6.3.2 [swappable.requirements]) and the swap operation shall not throw exceptions.

  3. Modify 23.2.1 [container.requirements.general] p. 8 and p. 9 as indicated:

    8 - [..] The allocator may be replaced only via assignment or swap(). Allocator replacement is performed by copy assignment, move assignment, or swapping of the allocator only if allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value, allocator_traits<allocator_type>::propagate_on_container_move_assignment::value, or allocator_traits<allocator_type>::propagate_on_container_swap::value is true within the implementation of the corresponding container operation. The behavior of a call to a container's swap function is undefined unless the objects being swapped have allocators that compare equal or allocator_traits<allocator_type>::propagate_on_container_swap::value is true. In all container types defined in this Clause, the member get_allocator() returns a copy of the allocator used to construct the container or, if that allocator has been replaced, a copy of the most recent replacement.

    9 - The expression a.swap(b), for containers a and b of a standard container type other than array, shall exchange the values of a and b without invoking any move, copy, or swap operations on the individual container elements. Lvalues of aAny Compare, Pred, or Hash objects belonging to a and b shall be swappable and shall be exchanged by unqualified calls to non-member calling swap as described in 17.6.3.2 [swappable.requirements]. If allocator_traits<allocator_type>::propagate_on_container_swap::value is true, then lvalues of allocator_type shall be swappable and the allocators of a and b shall also be exchanged using a an unqualified call to non-member swap call as described in 17.6.3.2 [swappable.requirements]. Otherwise, theythe allocators shall not be swapped, and the behavior is undefined unless a.get_allocator() == b.get_allocator(). Every iterator referring to an element in one container before the swap shall refer to the same element in the other container after the swap. It is unspecified whether an iterator with value a.end() before the swap will have value b.end() after the swap.


2018. regex_traits::isctype Returns clause is wrong

Section: 28.7 [re.traits] Status: Open Submitter: Jonathan Wakely Opened: 2010-11-16 Last modified: 2011-09-06

View all other issues in [re.traits].

View all issues with Open status.

Discussion:

28.7 [re.traits] p. 12 says:

returns true if f bitwise or'ed with the result of calling lookup_classname with an iterator pair that designates the character sequence "w" is not equal to 0 and c == '_'

If the bitmask value corresponding to "w" has a non-zero value (which it must do) then the bitwise or with any value is also non-zero, and so isctype('_', f) returns true for any f. Obviously this is wrong, since '_' is not in every ctype category.

There's a similar problem with the following phrases discussing the "blank" char class.

[2011-05-06: Jonathan Wakely comments and provides suggested wording]

DR 2019 added isblank support to <locale> which simplifies the definition of regex_traits::isctype by removing the special case for the "blank" class.

My suggestion for 2018 is to add a new table replacing the lists of recognized names in the Remarks clause of regex_traits::lookup_classname. I then refer to that table in the Returns clause of regex_traits::isctype to expand on the "in an unspecified manner" wording which is too vague. The conversion can now be described using the "is set" term defined by 17.5.2.1.3 [bitmask.types] and the new table to convey the intented relationship between e.g. [[:digit:]] and ctype_base::digit, which is not actually stated in the FDIS.

The effects of isctype can then most easily be described in code, given an "exposition only" function prototype to do the not-quite-so-unspecified conversion from char_class_type to ctype_base::mask.

The core of LWG 2018 is the "bitwise or'ed" wording which gives the wrong result, always evaluating to true for all values of f. That is replaced by the condition (f&x) == x where x is the result of calling lookup_classname with "w". I believe that's necessary, because the "w" class could be implemented by an internal "underscore" class i.e. x = _Alnum|_Underscore in which case (f&x) != 0 would give the wrong result when f==_Alnum.

The proposed resolution also makes use of ctype::widen which addresses the problem that the current wording only talks about "w" and '_' which assumes charT is char. There's still room for improvement here: the regex grammar in 28.13 [re.grammar] says that the class names in the table should always be recognized, implying that e.g. U"digit" should be recognized by regex_traits<char32_t>, but the specification of regex_traits::lookup_classname doesn't cover that, only mentioning char and wchar_t. Maybe the table should not distinguish narrow and wide strings, but should just have one column and add wording to say that regex_traits widens the name as if by using use_facet<ctype<charT>>::widen().

Another possible improvement would be to allow additional implementation-defined extensions in isctype. An implementation is allowed to support additional class names in lookup_classname, e.g. [[:octdigit:]] for [0-7] or [[:bindigit:]] for [01], but the current definition of isctype provides no way to use them unless ctype_base::mask also supports them.

[2011-05-10: Alberto and Daniel perform minor fixes in the P/R]

[ 2011 Bloomington ]

Consensus that this looks to be a correct solution, and the presentation as a table is a big improvement.

Concern that the middle section wording is a little muddled and confusing, Stefanus volunteered to reword.

Proposed resolution:

This wording is relative to the FDIS.

  1. Modify 28.7 [re.traits] p. 10 as indicated:

    template <class ForwardIterator>
      char_class_type lookup_classname(
        ForwardIterator first, ForwardIterator last, bool icase = false) const;
    

    -9- Returns: an unspecified value that represents the character classification named by the character sequence designated by the iterator range [first,last). If the parameter icase is true then the returned mask identifies the character classification without regard to the case of the characters being matched, otherwise it does honor the case of the characters being matched.(footnote 335) The value returned shall be independent of the case of the characters in the character sequence. If the name is not recognized then returns a value that compares equal to 0.

    -10- Remarks: For regex_traits<char>, at least the names "d", "w", "s", "alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper" and "xdigit"narrow character names in Table X shall be recognized. For regex_traits<wchar_t>, at least the names L"d", L"w", L"s", L"alnum", L"alpha", L"blank", L"cntrl", L"digit", L"graph", L"lower", L"print", L"punct", L"space", L"upper" and L"xdigit"wide character names in Table X shall be recognized.

  2. Modify 28.7 [re.traits] p. 12 as indicated:

    bool isctype(charT c, char_class_type f) const;
    

    -11- Effects: Determines if the character c is a member of the character classification represented by f.

    -12- Returns: Converts f into a value m of type std::ctype_base::mask in an unspecified manner, and returns true if use_facet<ctype<charT> >(getloc()).is(m, c) is true. Otherwise returns true if f bitwise or'ed with the result of calling lookup_classname with an iterator pair that designates the character sequence "w" is not equal to 0 and c == '_', or if f bitwise or'ed with the result of calling lookup_classname with an iterator pair that designates the character sequence "blank" is not equal to 0 and c is one of an implementation-defined subset of the characters for which isspace(c, getloc()) returns true, otherwise returns false.except that when f represents membership of a character class named in Table X, the corresponding ctype_base::mask value shall be set in m. Given the function prototype

    template<class C>
       ctype_base::mask convert(typename regex_traits<C>::char_class_type);
    

    the result is determined as if by

    
    ctype_base::mask m = convert<charT>(f);
    const ctype<charT>& ct = use_facet<ctype<charT> >(getloc());
    if (ct.is(m, c))
      return true;
    charT w[1] = { ct.widen('w') };
    char_class_type x = lookup_classname(w, w+1);
    if ((f&x) == x && c == ct.widen('_'))
      return true;
    return false;
    

    [Example:

    
    regex_traits<char> t;
    string d("d");
    string u("upper");
    regex_traits<char>::char_class_type f;
    f = t.lookup_classname(d.begin(), d.end());
    f |= t.lookup_classname(u.begin(), u.end());
    ctype_base::mask m = convert<char>(f); // m == ctype_base::digit|ctype_base::upper
    

    end example]

    [Example:

    
    regex_traits<char> t;
    string w("w");
    regex_traits<char>::char_class_type f;
    f = t.lookup_classname(w.begin(), w.end());
    t.isctype('A', f); // returns true
    t.isctype('_', f); // returns true
    t.isctype(' ', f); // returns false
    

    end example]

  3. At the end of [re.traits] add a new Table X — Character class names and corresponding ctype masks:

    Table X — Character class names and corresponding ctype masks
    Narrow character name Wide character name Corresponding ctype_base::mask value
    "alnum" L"alnum" ctype_base::alnum
    "alpha" L"alpha" ctype_base::alpha
    "blank" L"blank" ctype_base::blank
    "cntrl" L"cntrl" ctype_base::cntrl
    "digit" L"digit" ctype_base::digit
    "d" L"d" ctype_base::digit
    "graph" L"graph" ctype_base::graph
    "lower" L"lower" ctype_base::lower
    "print" L"print" ctype_base::print
    "punct" L"punct" ctype_base::punct
    "space" L"space" ctype_base::space
    "s" L"s" ctype_base::space
    "upper" L"upper" ctype_base::upper
    "w" L"w" ctype_base::alnum
    "xdigit" L"xdigit" ctype_base::xdigit

2021. Further incorrect usages of result_of

Section: 20.8.9.1.2 [func.bind.bind], 30.6.1 [futures.overview], 30.6.8 [futures.async] Status: Ready Submitter: Daniel Krügler Opened: 2010-12-07 Last modified: 2011-09-06

View all other issues in [func.bind.bind].

View all issues with Ready status.

Discussion:

Issue 2017 points out some incorrect usages of result_of in the declaration of the function call operator overload of reference_wrapper, but there are more such specification defects:

  1. According to 20.8.9.1.2 [func.bind.bind] p. 3:

    [..] The effect of g(u1, u2, ..., uM) shall be INVOKE(fd, v1, v2, ..., vN, result_of<FD cv (V1, V2, ..., VN)>::type) [..]

    but fd is defined as "an lvalue of type FD constructed from std::forward<F>(f)". This means that the above usage must refer to result_of<FD cv & (V1, V2, ..., VN)> instead.

  2. Similar in 20.8.9.1.2 [func.bind.bind] p. 10 bullet 2 we have:

    if the value of is_bind_expression<TiD>::value is true, the argument is tid(std::forward<Uj>(uj)...) and its type Vi is result_of<TiD cv (Uj...)>::type

    Again, tid is defined as "lvalue of type TiD constructed from std::forward<Ti>(ti)". This means that the above usage must refer to result_of<TiD cv & (Uj...)> instead. We also have similar defect as in 2017 in regard to the argument types, this leads us to the further corrected form result_of<TiD cv & (Uj&&...)>. This is not the end: Since the Vi are similar sensitive to the argument problem, the last part must say:

    "[..] its type Vi is result_of<TiD cv & (Uj&&...)>::type &&"

    (The bound arguments Vi can never be void types, therefore we don't need to use the more defensive std::add_rvalue_reference type trait)

  3. The function template async is declared as follows (the other overload has the same problem):

    template <class F, class... Args>
    future<typename result_of<F(Args...)>::type>
    async(F&& f, Args&&... args);
    

    This usage has the some same problems as we have found in reference_wrapper (2017) and more: According to the specification in 30.6.8 [futures.async] the effective result type is that of the call of

    INVOKE(decay_copy(std::forward<F>(f)), decay_copy(std::forward<Args>(args))...)
    

    First, decay_copy potentially modifies the effective types to decay<F>::type and decay<Args>::type.... Second, the current specification is not really clear, what the value category of callable type or the arguments shall be: According to the second bullet of 30.6.8 [futures.async] p. 3:

    Invocation of the deferred function evaluates INVOKE(g, xyz) where g is the stored value of decay_copy(std::forward<F>(f)) and xyz is the stored copy of decay_copy(std::forward<Args>(args))....

    This seems to imply that lvalues are provided in contrast to the direct call expression of 30.6.8 [futures.async] p. 2 which implies rvalues instead. The specification needs to be clarified.

[2011-06-13: Daniel comments and refines the proposed wording changes]

The feedback obtained following message c++std-lib-30745 and follow-ups point to the intention, that the implied provision of lvalues due to named variables in async should be provided as rvalues to support move-only types, but the functor type should be forwarded as lvalue in bind.

If bind were newly invented, the value strategy could be improved, because now we have a preference of ref & qualified function call operator overloads. But such a change seems to be too late now. User-code that needs to bind a callable object with an ref && qualified function call operator (or conversion function to function pointer) needs to use a corresponding wrapper similar to reference_wrapper that forwards the reference as rvalue-reference instead.

The wording has been adapted to honor these observations and to fit to FDIS numbering as well.

[Bloomington, 2011]

Move to Ready

Proposed resolution:

The suggested wording changes are against the FDIS.

  1. Change 20.8.9.1.2 [func.bind.bind] p. 3 as indicated:

    template<class F, class... BoundArgs>
      unspecified bind(F&& f, BoundArgs&&... bound_args);
    

    -2- Requires: is_constructible<FD, F>::value shall be true. For each Ti in BoundArgs, is_constructible<TiD, Ti>::value shall be true. INVOKE(fd, w1, w2, ..., wN) (20.8.2) shall be a valid expression for some values w1, w2, ..., wN, where N == sizeof...(bound_args).

    -3- Returns: A forwarding call wrapper g with a weak result type (20.8.2). The effect of g(u1, u2, ..., uM) shall be INVOKE(fd, std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN), result_of<FD cv & (V1, V2, ..., VN)>::type), where cv represents the cv-qualifiers of g and the values and types of the bound arguments v1, v2, ..., vN are determined as specified below. […]

  2. Change 20.8.9.1.2 [func.bind.bind] p. 7 as indicated:

    template<class R, class F, class... BoundArgs>
       unspecified bind(F&& f, BoundArgs&&... bound_args);
    

    -6- Requires: is_constructible<FD, F>::value shall be true. For each Ti in BoundArgs, is_constructible<TiD, Ti>::value shall be true. INVOKE(fd, w1, w2, ..., wN) shall be a valid expression for some values w1, w2, ..., wN, where N == sizeof...(bound_args).

    -7- Returns: A forwarding call wrapper g with a nested type result_type defined as a synonym for R. The effect of g(u1, u2, ..., uM) shall be INVOKE(fd, std::forward<V1>(v1), std::forward<V2>(v2), ..., std::forward<VN>(vN), R), where the values and types of the bound arguments v1, v2, ..., vN are determined as specified below. […]

  3. Change 20.8.9.1.2 [func.bind.bind] p. 10 as indicated:

    -10- The values of the bound arguments v1, v2, ..., vN and their corresponding types V1, V2, ..., VN depend on the types TiD derived from the call to bind and the cv-qualifiers cv of the call wrapper g as follows:

    • if TiD is reference_wrapper<T>, the argument is tid.get() and its type Vi is T&;
    • if the value of is_bind_expression<TiD>::value is true, the argument is tid(std::forward<Uj>(uj)...) and its type Vi is result_of<TiD cv & (Uj&&...)>::type&&;
    • if the value j of is_placeholder<TiD>::value is not zero, the argument is std::forward<Uj>(uj) and its type Vi is Uj&&;
    • otherwise, the value is tid and its type Vi is TiD cv &.
  4. This resolution assumes that the wording of 30.6.8 [futures.async] is intended to provide rvalues as arguments of INVOKE.

    Change the function signatures in header <future> synopsis 30.6.1 [futures.overview] p. 1 and in 30.6.8 [futures.async] p. 1 as indicated:

    template <class F, class... Args>
    future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
    async(F&& f, Args&&... args);
    template <class F, class... Args>
    future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type>
    async(launch policy, F&& f, Args&&... args);
    
  5. Change 30.6.8 [futures.async] as indicated: (Remark: There is also a tiny editorial correction in p. 4 that completes one :: scope specifier)

    -3- Effects: […]

    • […]
    • if policy & launch::deferred is non-zero — Stores DECAY_COPY(std::forward<F>(f)) and DECAY_COPY(std::forward<Args>(args))... in the shared state. These copies of f and args constitute a deferred function. Invocation of the deferred function evaluates INVOKE(std::move(g), std::move(xyz)) where g is the stored value of DECAY_COPY(std::forward<F>(f)) and xyz is the stored copy of DECAY_COPY(std::forward<Args>(args)).... The shared state is not made ready until the function has completed. The first call to a non-timed waiting function (30.6.4) on an asynchronous return object referring to this shared state shall invoke the deferred function in the thread that called the waiting function. Once evaluation of INVOKE(std::move(g), std::move(xyz)) begins, the function is no longer considered deferred. [ Note: If this policy is specified together with other policies, such as when using a policy value of launch::async | launch::deferred, implementations should defer invocation or the selection of the policy when no more concurrency can be effectively exploited. — end note ]

    -4- Returns: an object of type future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type> that refers to the associated asynchronous state created by this call to async.


2028. messages_base::catalog overspecified

Section: 22.4.7.1 [locale.messages] Status: Ready Submitter: Howard Hinnant Opened: 2011-02-14 Last modified: 2011-09-06

View all issues with Ready status.

Discussion:

In 22.4.7.1 [locale.messages], messages_base::catalog is specified to be a typedef to int. This type is subsequently used to open, access and close catalogs.

However, an OS may have catalog/messaging services that are indexed and managed by types other than int. For example POSIX, publishes the following messaging API:

typedef unspecified nl_catd;

nl_catd catopen(const char* name , int oflag);
char*   catgets(nl_catd catd, int set_id, int msg_id, const char* s);
int     catclose(nl_catd catd);

I.e., the catalog is managed with an unspecified type, not necessarily an int. Mac OS uses a void* for nl_catd (which is conforming to the POSIX standard). The current messages_base spec effectively outlaws using the built-in OS messaging service supplied for this very purpose!

[2011-02-24: Chris Jefferson updates the proposed wording, changing unspecified to unspecified signed integral type]

[2011-03-02: Daniel updates the proposed wording, changing unspecified signed integral type to unspecified signed integer type (We don't want to allow for bool or char)]

[2011-03-24 Madrid meeting]

Consensus that this resolution is the direction we would like to see.

Proposed resolution:

  1. Modify 22.4.7.1 [locale.messages]:

    namespace std {
      class messages_base {
      public:
        typedef intunspecified signed integer type catalog;
      };
      ...
    }
    

2033. Preconditions of reserve, shrink_to_fit, and resize functions

Section: 23.3.6.3 [vector.capacity], 23.3.3.3 [deque.capacity] Status: Ready Submitter: Nikolay Ivchenkov Opened: 2011-02-20 Last modified: 2011-09-06

View other active issues in [vector.capacity].

View all other issues in [vector.capacity].

View all issues with Ready status.

Discussion:

I have several questions with regard to the working paper N3225 (C++0x working draft):

  1. Where the working draft specifies preconditions for shrink_to_fit member function of std::vector and std::deque?

  2. Where the working draft specifies preconditions for 'void reserve(size_type n)' member function of std::vector?

  3. Does a call to 'void resize(size_type sz)' of std::vector require the element type to be DefaultConstructible? If yes, why such requirement is not listed in the Requires paragraph?

  4. Does a call to 'void resize(size_type sz)' of std::vector require the element type to be MoveAssignable because the call erase(begin() + sz, end()) mentioned in the Effects paragraph would require the element type to be MoveAssignable?

  5. Why CopyInsertable requirement is used for 'void resize(size_type sz)' of std::vector instead of MoveInsertable requirement?

[2011-06-12: Daniel comments and provides wording]

According to my understanding of the mental model of vector (and to some parts for deque) the some requirements are missing in the standard as response to above questions:

  1. The preconditions of shrink_to_fit for both std::vector and std::deque should impose the MoveInsertable requirements. The reason for this is, that these containers can host move-only types. For a container type X the C++03 idiom X(*this).swap(*this) imposes the CopyInsertable requirements which would make the function call ill-formed, which looks like an unacceptable restriction to me. Assuming the committee decides to support the move-only case, further wording has to be added for the situation where such a move-only type could throw an exception, because this can leave the object in an unspecified state. This seems consistent with the requirements of reserve, which seems like a very similar function to me (for vector). And this brings us smoothly to the following bullet:
  2. I agree that we are currently missing to specify the preconditions of the reserve function. My interpretation of the mental model of this function is that it should work for move-only types, which seems to be supported by the wording used in 23.3.6.3 [vector.capacity] p2:

    […] If an exception is thrown other than by the move constructor of a non-CopyInsertable type, there are no effects.

    Given this statement, the appropriate requirement is MoveInsertable into the vector.

  3. I agree that vector::resize(size_type) misses to list the DefaultConstructible requirements.
  4. Unfortunately the current specification in terms of erase implies the MoveAssignable requirements. I don't think that this implication is intended. This function requires "append" and "pop-back" effects, respectively, where the former can be realized in terms of MoveInsertable requirements. The same fix in regard to using pop_back instead of erase is necessary for the two argument overload of resize as well (no MoveAssignable is required).
  5. The CopyInsertable requirement is incorrect and should be MoveInsertable instead.

In addition to above mentioned items, the proposed resolution adds a linear complexity bound for shrink_to_fit and attempts to resolve the related issue 2066.

[ 2011 Bloomington ]

Move to Ready.

Note for editor: we do not normally refer to 'linear time' for complexity requirements, but there is agreement that any clean-up of such wording is editorial.

Proposed resolution:

This wording is relative to the FDIS.

  1. Edit 23.3.3.3 [deque.capacity] as indicated [Remark: The suggested change of p4 is not redundant, because CopyInsertable is not necessarily a refinement of MoveInsertable in contrast to the fact that CopyConstructible is a refinement of MoveConstructible]:

    void resize(size_type sz);
    

    -1- Effects: If sz <= size(), equivalent to erase(begin() + sz, end());calling pop_back() size() - sz times. If size() < sz, appends sz - size() value-initialized elements to the sequence.

    -2- Requires: T shall be MoveInsertable into *this and DefaultConstructible.

    void resize(size_type sz, const T& c);
    

    -3- Effects: If sz <= size(), equivalent to calling pop_back() size() - sz times. If size() < sz, appends sz - size() copies of c to the sequence.

    if (sz > size())
      insert(end(), sz-size(), c);
    else if (sz < size())
      erase(begin()+sz, end());
    else
      ; // do nothing
    

    -4- Requires: T shall be MoveInsertable into *this and CopyInsertable into *this.

    void shrink_to_fit();
    

    -?- Requires: T shall be MoveInsertable into *this.

    -?- Complexity: Takes at most linear time in the size of the sequence.

    -5- Remarks: shrink_to_fit is a non-binding request to reduce memory use but does not change the size of the sequence. [ Note: The request is non-binding to allow latitude for implementation-specific optimizations. — end note ]

  2. Edit 23.3.6.3 [vector.capacity] as indicated including edits that also resolve 2066 [Remark: The combined listing of MoveInsertable and CopyInsertable before p12 is not redundant, because CopyInsertable is not necessarily a refinement of MoveInsertable in contrast to the fact that CopyConstructible is a refinement of MoveConstructible]:

    […]

    void reserve(size_type n);
    

    -?- Requires: T shall be MoveInsertable into *this.

    -2- Effects: A directive that informs a vector of a planned change in size, so that it can manage the storage allocation accordingly. After reserve(), capacity() is greater or equal to the argument of reserve if reallocation happens; and equal to the previous value of capacity() otherwise. Reallocation happens at this point if and only if the current capacity is less than the argument of reserve(). If an exception is thrown other than by the move constructor of a non-CopyInsertable type, there are no effects.

    -3- Complexity: It does not change the size of the sequence and takes at most linear time in the size of the sequence.

    -4- Throws: length_error if n > max_size().[footnote 266]

    -5- Remarks: Reallocation invalidates all the references, pointers, and iterators referring to the elements in the sequence. It is guaranteed that no reallocation takes place during insertions that happen after a call to reserve() until the time when an insertion would make the size of the vector greater than the value of capacity().

    void shrink_to_fit();
    

    -?- Requires: T shall be MoveInsertable into *this.

    -?- Complexity: Takes at most linear time in the size of the sequence.

    -6- Remarks: shrink_to_fit is a non-binding request to reduce capacity() to size(). [ Note: The request is non-binding to allow latitude for implementation-specific optimizations. — end note ] If an exception is thrown other than by the move constructor of a non-CopyInsertable T there are no effects.

    […]

    void resize(size_type sz);
    

    -9- Effects: If sz <= size(), equivalent to erase(begin() + sz, end());calling pop_back() size() - sz times. If size() < sz, appends sz - size() value-initialized elements to the sequence.

    -10- Requires: T shall be CopyMoveInsertable into *this and DefaultConstructible.

    -??- Remarks: If an exception is thrown other than by the move constructor of a non-CopyInsertable T there are no effects.

    void resize(size_type sz, const T& c);
    

    -11- Effects: If sz <= size(), equivalent to calling pop_back() size() - sz times. If size() < sz, appends sz - size() copies of c to the sequence.

    if (sz > size())
      insert(end(), sz-size(), c);
    else if (sz < size())
      erase(begin()+sz, end());
    else
      ; // do nothing
    

    -??- Requires: T shall be MoveInsertable into *this and CopyInsertable into *this.

    -12- RequiresRemarks: If an exception is thrown other than by the move constructor of a non-CopyInsertable T there are no effects.


2035. Output iterator requirements are broken

Section: 24.2.4 [output.iterators] Status: Open Submitter: Daniel Krügler Opened: 2011-02-27 Last modified: 2011-09-06

View other active issues in [output.iterators].

View all other issues in [output.iterators].

View all issues with Open status.

Discussion:

During the Pittsburgh meeting the proposal N3066 became accepted because it fixed several severe issues related to the iterator specification. But the current working draft (N3225) does not reflect all these changes. Since I'm unaware whether every correction can be done editorial, this issue is submitted to take care of that. To give one example: All expressions of Table 108 — "Output iterator requirements" have a post-condition that the iterator is incrementable. This is impossible, because it would exclude any finite sequence that is accessed by an output iterator, such as a pointer to a C array. The N3066 wording changes did not have these effects.

[2011-03-01: Daniel comments:]

This issue has some overlap with the issue 2038 and I would prefer if we could solve both at one location. I suggest the following approach:

  1. The terms dereferencable and incrementable could be defined in a more general way not restricted to iterators (similar to the concepts HasDereference and HasPreincrement from working draft N2914). But on the other hand, all current usages of dereferencable and incrementable are involved with types that satisfy iterator requirements. Thus, I believe that it is sufficient for C++0x to add corresponding definitions to 24.2.1 [iterator.requirements.general] and to let all previous usages of these terms refer to this sub-clause. Since the same problem occurs with the past-the-end iterator, this proposal suggest providing similar references to usages that precede its definition as well.

  2. We also need to ensure that all iterator expressions get either an operational semantics in terms of others or we need to add missing pre- and post-conditions. E.g. we have the following ones without semantics:

    *r++ = o // output iterator
    *r--     // bidirectional iterator
    

    According to the SGI specification these correspond to

    { *r = o; ++r; }                         // output iterator
    { reference tmp = *r; --r; return tmp; } // bidirectional iterator
    

    respectively. Please note especially the latter expression for bidirectional iterator. It fixes a problem that we have for forward iterator as well: Both these iterator categories provide stronger guarantees than input iterator, because the result of the dereference operation is reference, and not only convertible to the value type (The exact form from the SGI documentation does not correctly refer to reference).

[2011-03-14: Daniel comments and updates the suggested wording]

In addition to the before mentioned necessary changes there is another one need, which became obvious due to issue 2042: forward_list<>::before_begin() returns an iterator value which is not dereferencable, but obviously the intention is that it should be incrementable. This leads to the conclusion that imposing dereferencable as a requirement for the expressions ++r is wrong: We only need the iterator to be incrementable. A similar conclusion applies to the expression --r of bidirectional iterators.

[ 2011 Bloomington ]

Consensus this is the correct direction, but there are (potentially) missing incrementable preconditions on some table rows, and the Remarks on when an output iterator becomes dereferencable are probably better handled outside the table, in a manner similar to the way we word for input iterators.

There was some concern about redundant pre-conditions when the operational semantic is defined in terms of operations that have preconditions, and a similar level of concern over dropping such redundancies vs. applying a consistent level of redundant specification in all the iterator tables. Wording clean-up in either direction would be welcome.

[2011-08-18: Daniel adapts the proposed resolution to honor the Bloomington request]

There is only a small number of further changes suggested to get rid of superfluous requirements and essentially non-normative assertions. Operations should not have extra pre-conditions, if defined by "in-terms-of" semantics, see e.g. a != b or a->m for Table 107. Further, some remarks, that do not impose anything or say nothing new have been removed, because I could not find anything helpful they provide. E.g. consider the remarks for Table 108 for the operations dereference-assignment and preincrement: They don't provide additional information say nothing surprising. With the new pre-conditions and post-conditions it is implied what the remarks intend to say.

Proposed resolution:

  1. Add a reference to 24.2.1 [iterator.requirements.general] to the following parts of the library preceding Clause 24 Iterators library: (I stopped from 23.2.5 [unord.req] on, because the remaining references are the concrete containers)

    1. 17.6.3.2 [swappable.requirements] p. 5:

      5 A type X satisfying any of the iterator requirements (24.2) is ValueSwappable if, for any dereferenceable (24.2.1 [iterator.requirements.general]) object x of type X, *x is swappable.

    2. 17.6.3.5 [allocator.requirements], Table 27 — "Descriptive variable definitions", row with the expression c:

      a dereferenceable (24.2.1 [iterator.requirements.general]) pointer of type C*

    3. 20.6.3.2 [pointer.traits.functions]:

      Returns: The first template function returns a dereferenceable (24.2.1 [iterator.requirements.general]) pointer to r obtained by calling Ptr::pointer_to(r); […]

    4. 21.4.3 [string.iterators] p. 2:

      Returns: An iterator which is the past-the-end value (24.2.1 [iterator.requirements.general]).

    5. 22.4.5.1.2 [locale.time.get.virtuals] p. 11:

      iter_type do_get(iter_type s, iter_type end, ios_base& f,
        ios_base::iostate& err, tm *t, char format, char modifier) const;
      

      Requires: t shall be dereferenceable (24.2.1 [iterator.requirements.general]).

    6. 23.2.1 [container.requirements.general] p. 6:

      […] end() returns an iterator which is the past-the-end (24.2.1 [iterator.requirements.general]) value for the container. […]

    7. 23.2.3 [sequence.reqmts] p. 3:

      […] q denotes a valid dereferenceable (24.2.1 [iterator.requirements.general]) const iterator to a, […]

    8. 23.2.4 [associative.reqmts] p. 8 (I omit intentionally one further reference in the same sub-clause):

      […] q denotes a valid dereferenceable (24.2.1 [iterator.requirements.general]) const iterator to a, […]

    9. 23.2.5 [unord.req] p. 10 (I omit intentionally one further reference in the same sub-clause):

      […] q and q1 are valid dereferenceable (24.2.1 [iterator.requirements.general]) const iterators to a, […]

  2. Edit 24.2.1 [iterator.requirements.general] p. 5 as indicated (The intent is to properly define incrementable and to ensure some further library guarantee related to past-the-end iterator values):

    5 Just as a regular pointer to an array guarantees that there is a pointer value pointing past the last element of the array, so for any iterator type there is an iterator value that points past the last element of a corresponding sequence. These values are called past-the-end values. Values of an iterator i for which the expression *i is defined are called dereferenceable. Values of an iterator i for which the expression ++i is defined are called incrementable. The library never assumes that past-the-end values are dereferenceable or incrementable. Iterators can also have singular values that are not associated with any sequence. […]

  3. Modify the column contents of Table 106 — "Iterator requirements", 24.2.2 [iterator.iterators], as indicated:

    Table 106 — Iterator requirements
    Expression Return type Operational semantics Assertion/note
    pre-/post-condition
    *r reference   pre: r is dereferenceable.
    ++r X&   pre: r is incrementable.
  4. Modify the column contents of Table 107 — "Input iterator requirements", 24.2.3 [input.iterators], as indicated:

    Table 107 — Input iterator requirements (in addition to Iterator)
    Expression Return type Operational semantics Assertion/note
    pre-/post-condition
    a != b contextually
    convertible to bool
    !(a == b) pre: (a, b) is in the domain
    of ==.
    *a convertible to T   pre: a is dereferenceable.
    The expression
    (void)*a, *a is equivalent
    to *a.
    If a == b and (a,b) is in
    the domain of == then *a is
    equivalent to *b.
    a->m   (*a).m pre: a is dereferenceable.
    ++r X&   pre: r is dereferenceableincrementable.
    post: r is dereferenceable or
    r is past-the-end.
    post: any copies of the
    previous value of r are no
    longer required either to be
    dereferenceable, incrementable,
    or to be in the domain of ==.
    (void)r++   (void)++r equivalent to (void)++r
    *r++ convertible to T { T tmp = *r;
    ++r;
    return tmp; }
     
  5. Modify the column contents of Table 108 — "Output iterator requirements", 24.2.4 [output.iterators], as indicated:

    Table 108 — Output iterator requirements (in addition to Iterator)
    Expression Return type Operational semantics Assertion/note
    pre-/post-condition
    *r = o result is not used   pre: r is dereferenceable.
    Remark: After this operation
    r is not required to be
    dereferenceable.

    post: r is incrementable.
    ++r X&   pre: r is incrementable.
    &r == &++r.
    Remark: After this operation
    r is not required to be
    dereferenceable.

    post: r is dereferenceable
    or r is past-the-end
    incrementable.
    r++ convertible to const X& { X tmp = r;
    ++r;
    return tmp; }
    Remark: After this operation
    r is not required to be
    dereferenceable.
    post: r is incrementable.
    *r++ = o result is not used { *r = o; ++r; } Remark: After this operation
    r is not required to be
    dereferenceable.
    post: r is incrementable.
  6. Modify the column contents of Table 109 — "Forward iterator requirements", 24.2.5 [forward.iterators], as indicated [Rationale: Since the return type of the expression *r++ is now guaranteed to be type reference, the implied operational semantics from input iterator based on value copies is wrong — end rationale]

    Table 109 — Forward iterator requirements (in addition to input iterator)
    Expression Return type Operational semantics Assertion/note
    pre-/post-condition
    r++ convertible to const X& { X tmp = r;
    ++r;
    return tmp; }
     
    *r++ reference { reference tmp = *r;
    ++r;
    return tmp; }
     
  7. Modify the column contents of Table 110 — "Bidirectional iterator requirements", 24.2.6 [bidirectional.iterators], as indicated:

    Table 110 — Bidirectional iterator requirements (in addition to forward iterator)
    Expression Return type Operational semantics Assertion/note
    pre-/post-condition
    --r X&   pre: there exists s such that
    r == ++s.
    post: r is dereferenceableincrementable.
    --(++r) == r.
    --r == --s implies r == s.
    &r == &--r.
    r-- convertible to const X& { X tmp = r;
    --r;
    return tmp; }
     
    *r-- reference { reference tmp = *r;
    --r;
    return tmp; }
     

2038. Missing definition for incrementable iterator

Section: 24.2.4 [output.iterators] Status: Open Submitter: Pete Becker Opened: 2011-02-27 Last modified: 2011-09-06

View other active issues in [output.iterators].

View all other issues in [output.iterators].

View all issues with Open status.

Discussion:

In comp.lang.c++, Vicente Botet raises the following questions:

"In "24.2.4 Output iterators" there are 3 uses of incrementable. I've not found the definition. Could some one point me where it is defined?

Something similar occurs with dereferenceable. While the definition is given in "24.2.1 In general" it is used several times before.

Shouldn't these definitions be moved to some previous section?"

He's right: both terms are used without being properly defined.

There is no definition of "incrementable".

While there is a definition of "dereferenceable", it is, in fact, a definition of "dereferenceable iterator". "dereferenceable" is used throughout Clause 23 (Containers) before its definition in Clause 24. In almost all cases it's referring to iterators, but in 17.6.3.2 [swappable.requirements] there is a mention of "dereferenceable object"; in 17.6.3.5 [allocator.requirements] the table of Descriptive variable definitions refers to a "dereferenceable pointer"; 20.6.3.2 [pointer.traits.functions] refers to a "dereferenceable pointer"; in 22.4.5.1.2 [locale.time.get.virtuals]/11 (do_get) there is a requirement that a pointer "shall be dereferenceable". In those specific cases it is not defined.

[2011-03-02: Daniel comments:]

I believe that the currently proposed resolution of issue 2035 solves this issue as well.

[ 2011 Bloomington ]

Agree with Daniel, this will be handled by the resolution of 2035.

Proposed resolution:


2039. Issues with std::reverse and std::copy_if

Section: 25.3.1 [alg.copy], 25.3.10 [alg.reverse] Status: Ready Submitter: Nikolay Ivchenkov Opened: 2011-03-02 Last modified: 2011-09-06

View all issues with Ready status.

Discussion:

  1. In the description of std::reverse

    Effects: For each non-negative integer i <= (last - first)/2, applies iter_swap to all pairs of iterators first + i, (last - i) - 1.

    should be changed to

    Effects: For each non-negative integer i < (last - first)/2, applies iter_swap to all pairs of iterators first + i, (last - i) - 1.

    Here i shall be strictly less than (last - first)/2.

  2. In the description of std::copy_if Returns paragraph is missing.

[2011-03-02: Daniel drafts wording]

Proposed resolution:

  1. Modify 25.3.10 [alg.reverse] p. 1 as indicated:

    1 Effects: For each non-negative integer i <= (last - first)/2, applies iter_swap to all pairs of iterators first + i, (last - i) - 1.

  2. Add the following Returns element after 25.3.1 [alg.copy] p. 9:

    template<class InputIterator, class OutputIterator, class Predicate>
    OutputIterator copy_if(InputIterator first, InputIterator last,
       OutputIterator result, Predicate pred);
    

    8 Requires: The ranges [first,last) and [result,result + (last - first)) shall not overlap.

    9 Effects: Copies all of the elements referred to by the iterator i in the range [first,last) for which pred(*i) is true.

    ?? Returns: The end of the resulting range.

    10 Complexity: Exactly last - first applications of the corresponding predicate.

    11 Remarks: Stable.


2044. No definition of "Stable" for copy algorithms

Section: 17.6.5.7 [algorithm.stable] Status: Ready Submitter: Pablo Halpern Opened: 2011-03-24 Last modified: 2011-09-06

View all issues with Ready status.

Discussion:

17.6.5.7 [algorithm.stable] specified the meaning of "stable" when applied to the different types of algorithms. The second bullet says:

— For the remove algorithms the relative order of the elements that are not removed is preserved.

There is no description of what "stable" means for copy algorithms, even though the term is applied to copy_if (and perhaps others now or in the future). Thus, copy_if is using the term without a precise definition.

[Bloomington, 2011]

Move to Ready

Proposed resolution:

This wording is relative to the FDIS.

  1. In 17.6.5.7 [algorithm.stable] p. 1 change as indicated:

    When the requirements for an algorithm state that it is “stable” without further elaboration, it means:

    • For the sort algorithms the relative order of equivalent elements is preserved.
    • For the remove and copy algorithms the relative order of the elements that are not removed is preserved.
    • For the merge algorithms, for equivalent elements in the original two ranges, the elements from the first range precede the elements from the second range.

2045. forward_list::merge and forward_list::splice_after with unequal allocators

Section: 23.3.4.6 [forwardlist.ops] Status: Ready Submitter: Pablo Halpern Opened: 2011-03-24 Last modified: 2011-09-06

View all other issues in [forwardlist.ops].

View all issues with Ready status.

Discussion:

See also: 1215

list::merge and list::splice have the requirement that the two lists being merged or spliced must use the same allocator. Otherwise, moving list nodes from one container to the other would corrupt the data structure. The same requirement is needed for forward_list::merge and forward_list::splice_after.

[ 2011 Bloomington ]

Move to Ready.

Proposed resolution:

This wording is relative to the FDIS.

  1. In 23.3.4.6 [forwardlist.ops] p. 1 change as indicated:

    void splice_after(const_iterator position, forward_list<T,Allocator>& x);
    void splice_after(const_iterator position, forward_list<T,Allocator>&& x);
    

    1 - Requires: position is before_begin() or is a dereferenceable iterator in the range [begin(),end()). get_allocator() == x.get_allocator(). &x != this.

  2. In 23.3.4.6 [forwardlist.ops] p. 5 change as indicated:

    void splice_after(const_iterator position, forward_list<T,Allocator>& x, const_iterator i);
    void splice_after(const_iterator position, forward_list<T,Allocator>&& x, const_iterator i);
    

    5 - Requires: position is before_begin() or is a dereferenceable iterator in the range [begin(),end()). The iterator following i is a dereferenceable iterator in x. get_allocator() == x.get_allocator().

  3. In 23.3.4.6 [forwardlist.ops] p. 9 change as indicated:

    void splice_after(const_iterator position, forward_list<T,Allocator>& x, 
                      const_iterator first, const_iterator last);
    void splice_after(const_iterator position, forward_list<T,Allocator>&& x, 
                      const_iterator first, const_iterator last);
    

    9 - Requires: position is before_begin() or is a dereferenceable iterator in the range [begin(),end()). (first,last) is a valid range in x, and all iterators in the range (first,last) are dereferenceable. position is not an iterator in the range (first,last). get_allocator() == x.get_allocator().

  4. In 23.3.4.6 [forwardlist.ops] p. 18 change as indicated:

    void merge(forward_list<T,Allocator>& x);
    void merge(forward_list<T,Allocator>&& x);
    template <class Compare> void merge(forward_list<T,Allocator>& x, Compare comp);
    template <class Compare> void merge(forward_list<T,Allocator>&& x, Compare comp);
    

    18 - Requires: comp defines a strict weak ordering ([alg.sorting]), and *this and x are both sorted according to this ordering. get_allocator() == x.get_allocator().


2047. Incorrect "mixed" move-assignment semantics of unique_ptr

Section: 20.7.1.2.3 [unique.ptr.single.asgn] Status: Ready Submitter: Daniel Krügler Opened: 2011-04-16 Last modified: 2011-09-06

View all other issues in [unique.ptr.single.asgn].

View all issues with Ready status.

Discussion:

The semantics described in 20.7.1.2.3 [unique.ptr.single.asgn] p. 6

Effects: Transfers ownership from u to *this as if […] followed by an assignment from std::forward<D>(u.get_deleter()).

contradicts to the pre-conditions described in p. 4:

Requires: If E is not a reference type, assignment of the deleter from an rvalue of type E shall be well-formed and shall not throw an exception. Otherwise, E is a reference type and assignment of the deleter from an lvalue of type E shall be well-formed and shall not throw an exception.

Either the pre-conditions are incorrect or the semantics should be an assignment from std::forward<E>(u.get_deleter()), instead.

It turns out that this contradiction is due to an incorrect transcription from the proposed resolution of 983 to the finally accepted proposal n3073 (see bullet 12) as confirmed by Howard Hinnant, thus the type argument provided to std::forward must be fixed as indicated.

[Bloomington, 2011]

Move to Ready

Proposed resolution:

This wording is relative to the FDIS.

  1. Edit 20.7.1.2.3 [unique.ptr.single.asgn] p. 6 as indicated:

    template <class U, class E> unique_ptr& operator=(unique_ptr<U, E>&& u) noexcept;
    

    4 - Requires: If E is not a reference type, assignment of the deleter from an rvalue of type E shall be well-formed and shall not throw an exception. Otherwise, E is a reference type and assignment of the deleter from an lvalue of type E shall be well-formed and shall not throw an exception.

    5 - Remarks: This operator shall not participate in overload resolution unless:

    • unique_ptr<U, E>::pointer is implicitly convertible to pointer and
    • U is not an array type.

    6 - Effects: Transfers ownership from u to *this as if by calling reset(u.release()) followed by an assignment from std::forward<DE>(u.get_deleter()).

    7 - Returns: *this.


2048. Unnecessary mem_fn overloads

Section: 20.8 [function.objects], 20.8.10 [func.memfn] Status: Review Submitter: Jonathan Wakely Opened: 2011-04-18 Last modified: 2011-09-06

View all other issues in [function.objects].

View all issues with Review status.

Discussion:

The mem_fn overloads for member functions are redundant and misleading and should be removed from the post-C++11 WP.

I believe the history of the overloads is as follows:

In TR1 and in C++0x prior to the N2798 draft, mem_fn was specified by a single signature:

template<class R, class T> unspecified mem_fn(R T::* pm);

and was accompanied by the remark "Implementations may implement mem_fn as a set of overloaded function templates." This remark predates variadic templates and was presumably to allow implementations to provide overloads for a limited number of function parameters, to meet the implementation-defined limit on numbers of template parameters.

N2770 "Concepts for the C++0x Standard Library: Utilities" added separate overloads for pointers to member functions, apparently so that function parameters would require the CopyConstructible concept (those overloads first appeared in N2322.) The overloads failed to account for varargs member functions (i.e. those declared with an ellipsis in the parameter-declaration-clause) e.g.

struct S {
 int f(int, ...);
};

Syntactically such a function would be handled by the original mem_fn(R T::* pm) signature, the only minor drawback being that there would be no CopyConstructible requirement on the parameter list. (Core DR 547 clarifies that partial specializations can be written to match cv-qualified and ref-qualified functions to support the case where R T::* matches a pointer to member function type.)

LWG issue 920 pointed out that additional overloads were missing for member functions with ref-qualifiers. These were not strictly necessary, because such functions are covered by the mem_fn(R T::* pm) signature.

Concepts were removed from the draft and N3000 restored the original single signature and accompanying remark.

LWG 1230 was opened to strike the remark again and to add an overload for member functions (this overload was unnecessary for syntactic reasons and insufficient as it didn't handle member functions with cv-qualifiers and/or ref-qualifiers.)

920 (and 1230) were resolved by restoring a full set of (non-concept-enabled) overloads for member functions with cv-qualifiers and ref-qualifiers, but as in the concept-enabled draft there were no overloads for member functions with an ellipsis in the parameter-declaration-clause. This is what is present in the FDIS.

Following the thread beginning with message c++std-lib-30675, it is my understanding that all the mem_fn overloads for member functions are unnecessary and were only ever added to allow concept requirements. I'm not aware of any reason implementations cannot implement mem_fn as a single function template. Without concepts the overloads are redundant, and the absence of overloads for varargs functions can be interpreted to imply that varargs functions are not intended to work with mem_fn. Clarifying the intent by adding overloads for varargs functions would expand the list of 12 redundant overloads to 24, it would be much simpler to remove the 12 redundant overloads entirely.

[Bloomington, 2011]

Move to Review.

The issue and resolution appear to be correct, but there is some concern that the wording of INVOKE may be different depending on whether you pass a pointer-to-member-data or pointer-to-member-function. That might make the current wording necessary after all, and then we might need to add the missing elipsis overloads.

There was some concern that the Remark confirming implementors had freedom to implement this as a set of overloaded functions may need to be restored if we delete the specification for these overloads.

Proposed resolution:

This wording is relative to the FDIS.

  1. Change the <functional> synopsis 20.8 [function.objects] p. 2 as follows:

    namespace std {
      […]
      // [func.memfn], member function adaptors:
      template<class R, class T> unspecified mem_fn(R T::*);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...));
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) const);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) volatile);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) const volatile);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) &);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) const &);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) volatile &);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) const volatile &);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) &&);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) const &&);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) volatile &&);
      template<class R, class T, class... Args>
      unspecified mem_fn(R (T::*)(Args...) const volatile &&);
    
      […]
    }
    
  2. Change 20.8.10 [func.memfn] as follows:

    template<class R, class T> unspecified mem_fn(R T::*);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...));
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) const);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) volatile);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) const volatile);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) &);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) const &);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) volatile &);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) const volatile &);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) &&);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) const &&);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) volatile &&);
    template<class R, class T, class... Args>
    unspecified mem_fn(R (T::*)(Args...) const volatile &&);
    

2049. is_destructible is underspecified

Section: 20.9.4.3 [meta.unary.prop] Status: Review Submitter: Daniel Krügler Opened: 2011-04-18 Last modified: 2011-09-06

View all other issues in [meta.unary.prop].

View all issues with Review status.

Discussion:

The conditions for the type trait is_destructible to be true are described in Table 49 — Type property predicates:

For a complete type T and given
template <class U> struct test { U u; };,
test<T>::~test() is not deleted.

This specification does not say what the result would be for function types or for abstract types:

  1. For an abstract type X the instantiation test<X> is already ill-formed, so we cannot say anything about whether the destructor would be deleted or not.
  2. In regard to function types, there exists a special rule in the core language, 14.3.1 [temp.arg.type] p. 3, which excludes member functions to be declared via the type of the template parameter:

    If a declaration acquires a function type through a type dependent on a template-parameter and this causes a declaration that does not use the syntactic form of a function declarator to have function type, the program is ill-formed.

    [ Example:

    template<class T> struct A {
      static T t;
    };
    typedef int function();
    A<function> a; // ill-formed: would declare A<function>::t
                   // as a static member function
    

    end example ]

    which has the same consequence as for abstract types, namely that the corresponding instantiation of test is already ill-formed and we cannot say anything about the destructor.

To solve this problem, I suggest to specify function types as trivially and nothrowing destructible, because above mentioned rule is very special for templates. For non-templates, a typedef can be used to introduce a member as member function as clarified in 8.3.5 [dcl.fct] p. 10.

For abstract types, two different suggestions have been brought to my attention: Either declare them as unconditionally non-destructible or check whether the expression

std::declval<T&>().~T()

is well-formed in an unevaluated context. The first solution is very easy to specify, but the second version has the advantage for providing more information to user-code. This information could be quite useful, if generic code is supposed to invoke the destructor of a reference to a base class indirectly via a delete expression, as suggested by Howard Hinnant:

template <class T>
my_pointer<T>::~my_pointer() noexcept(is_nothrow_destructible<T>::value)
{
   delete ptr_;
}

Additional to the is_destructible traits, its derived forms is_trivially_destructible and is_nothrow_destructible are similarly affected, because their wording refers to "the indicated destructor" and probably need to be adapted as well.

[ 2011 Bloomington ]

After discussion about to to handle the exceptional cases of reference types, function types (available by defererencing a function pointer) and void types, Howard supplied proposed wording.

Proposed resolution:

Update 20.9.4.3 [meta.unary.prop], table 49:

template <class T> struct is_destructible; For a complete type T and given template <class U> struct test { U u; };, test<T>:: ̃test() is not deleted.
For object types, if the expression: std::declval<T&>().~T() is well-formed in an unevaluated context then is_destructible<T>::value is true, otherwise it is false.
For void types, is_destructible<T>::value is false.
For reference types, is_destructible<T>::value is true.
For function types, is_destructible<T>::value is false.
T shall be a complete type, (possibly cv-qualified) void, or an array of unknown bound.

2050. Unordered associative containers do not use allocator_traits to define member types

Section: 23.5 [unord] Status: Ready Submitter: Tom Zieberman Opened: 2011-04-29 Last modified: 2011-09-06

View all other issues in [unord].

View all issues with Ready status.

Discussion:

The unordered associative containers define their member types reference, const_reference, pointer, const_pointer in terms of their template parameter Allocator (via allocator_type typedef). As a consequence, only the allocator types, that provide sufficient typedefs, are usable as allocators for unordered associative containers, while other containers do not have this deficiency. In addition to that, the definitions of said typedefs are different from ones used in the other containers. This is counterintuitive and introduces a certain level of confusion. These issues can be fixed by defining pointer and const_pointer typedefs in terms of allocator_traits<Allocator> and by defining reference and const_reference in terms of value_type as is done in the other containers.

[ 2011 Bloomington. ]

Move to Ready.

Proposed resolution:

This wording is relative to the FDIS.


2052. Mixup between mapped_type and value_type for associative containers

Section: 23.2.4 [associative.reqmts] Status: Open Submitter: Marc Glisse Opened: 2011-05-04 Last modified: 2011-09-06

View other active issues in [associative.reqmts].

View all other issues in [associative.reqmts].

View all issues with Open status.

Discussion:

(this is basically reopening the first part of issue 2006, as discussed in the thread starting at c++std-lib-30698 )

Section 23.2.4 [associative.reqmts]

In Table 102, several uses of T (which means mapped_type here) should be value_type instead. This is almost editorial. For instance:

a_uniq.emplace(args)

Requires: T shall be EmplaceConstructible into X from args.

Effects: Inserts a T object t constructed with std::forward<Args>(args)... if and only if there is no element in the container with key equivalent to the key of t. The bool component of the returned pair is true if and only if the insertion takes place, and the iterator component of the pair points to the element with key equivalent to the key of t.

[ 2011 Bloomington ]

Not even an exhaustive list of problem locations. No reason to doubt issue.

Pablo agrees to provide wording.

Proposed resolution:

In section [associative.reqmnts] table 102 and 23.2.5 [unord.req], table 103, make the following text replacements:

Original text, in FDIS Replacement text
T is CopyInsertable value_type is CopyInsertable
T shall be CopyInsertable value_type shall be CopyInsertable
T shall be MoveInsertable value_type shall be MoveInsertable
T shall be EmplaceConstructible value_type shall be EmplaceConstructible
T object value_type object

[ Notes to the editor: The above are carefully selected phrases that can be used for global search-and-replace within the specified sections without accidentally making changes to correct uses T. ]


2053. Errors in regex bitmask types

Section: 28.5 [re.const] Status: Ready Submitter: Jonathan Wakely Opened: 2011-05-09 Last modified: 2011-09-06

View all issues with Ready status.

Discussion:

When N3110 was applied to the WP some redundant "static" keywords were added and one form of initializer which isn't valid for enumeration types was replaced with another form of invalid initializer.

[ 2011 Bloomington. ]

Move to Ready.

Proposed resolution:

This wording is relative to the FDIS.

  1. Change 28.5.1 [re.synopt] as indicated:

    namespace std {
      namespace regex_constants {
        typedef T1 syntax_option_type;
        static constexpr syntax_option_type icase = unspecified ;
        static constexpr syntax_option_type nosubs = unspecified ;
        static constexpr syntax_option_type optimize = unspecified ;
        static constexpr syntax_option_type collate = unspecified ;
        static constexpr syntax_option_type ECMAScript = unspecified ;
        static constexpr syntax_option_type basic = unspecified ;
        static constexpr syntax_option_type extended = unspecified ;
        static constexpr syntax_option_type awk = unspecified ;
        static constexpr syntax_option_type grep = unspecified ;
        static constexpr syntax_option_type egrep = unspecified ;
      }
    }
    
  2. Change 28.5.2 [re.matchflag] as indicated:

    namespace std {
      namespace regex_constants {
        typedef T2 match_flag_type;
        static constexpr match_flag_type match_default = 0{};
        static constexpr match_flag_type match_not_bol = unspecified ;
        static constexpr match_flag_type match_not_eol = unspecified ;
        static constexpr match_flag_type match_not_bow = unspecified ;
        static constexpr match_flag_type match_not_eow = unspecified ;
        static constexpr match_flag_type match_any = unspecified ;
        static constexpr match_flag_type match_not_null = unspecified ;
        static constexpr match_flag_type match_continuous = unspecified ;
        static constexpr match_flag_type match_prev_avail = unspecified ;
        static constexpr match_flag_type format_default = 0{};
        static constexpr match_flag_type format_sed = unspecified ;
        static constexpr match_flag_type format_no_copy = unspecified ;
        static constexpr match_flag_type format_first_only = unspecified ;
      }
    }
    
  3. Change 28.5.3 [re.err] as indicated:

    namespace std {
      namespace regex_constants {
        typedef T3 error_type;
        static constexpr error_type error_collate = unspecified ;
        static constexpr error_type error_ctype = unspecified ;
        static constexpr error_type error_escape = unspecified ;
        static constexpr error_type error_backref = unspecified ;
        static constexpr error_type error_brack = unspecified ;
        static constexpr error_type error_paren = unspecified ;
        static constexpr error_type error_brace = unspecified ;
        static constexpr error_type error_badbrace = unspecified ;
        static constexpr error_type error_range = unspecified ;
        static constexpr error_type error_space = unspecified ;
        static constexpr error_type error_badrepeat = unspecified ;
        static constexpr error_type error_complexity = unspecified ;
        static constexpr error_type error_stack = unspecified ;
      }
    }
    

2054. time_point constructors need to be constexpr

Section: 20.11.6 [time.point] Status: Open Submitter: Anthony Williams Opened: 2011-05-13 Last modified: 2011-09-06

View all issues with Open status.

Discussion:

In 20.11.6 [time.point], time_point::min() and time_point::max() are listed as constexpr. However, time_point has no constexpr constructors, so is not a literal type, and so these functions cannot be constexpr without adding a constexpr constructor for implementation purposes.

Proposed resolution: Add constexpr to the constructors of time_point. The effects of the constructor template basically imply that the member function time_since_epoch() is intended to be constexpr as well.

Proposed resolution:

This wording is relative to the FDIS.

  1. Alter the class template definition in 20.11.6 [time.point] as follows:

    template <class Clock, class Duration = typename Clock::duration>
    class time_point {
      […]
    public:
      // 20.11.6.1, construct:
      constexpr time_point(); // has value epoch
      constexpr explicit time_point(const duration& d); // same as time_point() + d
      template <class Duration2>
        constexpr time_point(const time_point<clock, Duration2>& t);
    
      // 20.11.6.2, observer:
      constexpr duration time_since_epoch() const;
      […]
    };
    
  2. Alter the declarations in 20.11.6.1 [time.point.cons]:

    constexpr time_point();
    

    -1- Effects: Constructs an object of type time_point, initializing d_ with duration::zero(). Such a time_point object represents the epoch.

    constexpr explicit time_point(const duration& d);
    

    -2- Effects: Constructs an object of type time_point, initializing d_ with d. Such a time_point object represents the epoch + d.

    template <class Duration2>
      constexpr time_point(const time_point<clock, Duration2>& t);
    

    -3- Remarks: This constructor shall not participate in overload resolution unless Duration2 is implicitly convertible to duration.

    -4- Effects: Constructs an object of type time_point, initializing d_ with t.time_since_epoch().

  3. Alter the declaration in 20.11.6.2 [time.point.observer]:

    constexpr duration time_since_epoch() const;
    

    -1- Returns: d_.


2056. future_errc enums start with value 0 (invalid value for broken_promise)

Section: 30.6.1 [futures.overview] Status: Review Submitter: Nicolai Josuttis Opened: 2011-05-18 Last modified: 2011-09-06

View all issues with Review status.

Discussion:

In 30.6.1 [futures.overview] enum class future_errc is defined as follows:

enum class future_errc {
  broken_promise,
  future_already_retrieved,
  promise_already_satisfied,
  no_state
};

With this declaration broken_promise has value 0, which means that for a future_error f with this code

f.code().operator bool()

yields false, which makes no sense. 0 has to be reserved for "no error". So, the enums defined here have to start with 1.

Howard, Anthony, and Jonathan have no objections.

[Discussion in Bloomington 2011-08-16]

Previous resolution:

This wording is relative to the FDIS.

  1. In 30.6.1 [futures.overview], header <future> synopsis, fix the declaration of future_errc as follows:

    namespace std {
      enum class future_errc {
        broken_promise,
        future_already_retrieved = 1,
        promise_already_satisfied,
        no_state,
        broken_promise
      };
      […]
    }
    

Is this resolution overspecified? These seem to be all implementation-defined. How do users add new values and not conflict with established error codes?

PJP proxy says: over-specified. boo.

Other error codes: look for is_error_code_enum specializations. Only one exists io_errc

Peter: I don't see any other parts of the standard that specify error codes where we have to do something similar.

Suggest that for every place where we add an error code, the following:

  1. no zero values
  2. all implementation defined values, so future_already_retrieved = implementation_defined
  3. values are distinct

Proposed resolution:

This wording is relative to the FDIS.

In 30.6.1 [futures.overview], header <future> synopsis, fix the declaration of future_errc as follows:

namespace std {
  enum class future_errc {
    broken_promise = implementation defined,
    future_already_retrieved = implementation defined,
    promise_already_satisfied = implementation defined,
    no_state = implementation defined
  };
  […]
}

In 30.6.1 [futures.overview], header <future> synopsis, add a paragraph after paragraph 2 as follows:

The enum values of future_errc are distinct and not zero.

2057. time_point + duration semantics should be made constexpr conforming

Section: 20.11.6.5 [time.point.nonmember] Status: Open Submitter: Daniel Krügler Opened: 2011-05-21 Last modified: 2011-09-06

View all issues with Open status.

Discussion:

It has been observed by LWG 2054 that the specification of some time_point member functions already imply that time_point needs to be a literal type and suggests to specify the constructors and the member function time_since_epoch() as constexpr functions at the minimum necessary. Adding further constexpr specifier to other operations should clearly be allowed and should probably be done as well. But to allow for further constexpr functions in the future requires that their semantics is compatible to operations allowed in constexpr functions. This is already fine for all operations, except this binary plus operator:

template <class Clock, class Duration1, class Rep2, class Period2>
time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);

-1- Returns: CT(lhs) += rhs, where CT is the type of the return value.

for similar reasons as those mentioned in 2020. The semantics should be fixed to allow for making them constexpr. This issue should also be considered as a placeholder for a request to make the remaining time_point operations similarly constexpr as had been done for duration.

Proposed resolution:

This wording is relative to the FDIS.

  1. In 20.11.6.5 [time.point.nonmember], p.1 change the Returns element semantics as indicated:

    template <class Clock, class Duration1, class Rep2, class Period2>
    time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
    operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
    

    -1- Returns: CT(lhs) += rhsCT(lhs.time_since_epoch() + rhs), where CT is the type of the return value.


2058. valarray and begin/end

Section: 26.6 [numarray] Status: Review Submitter: Gabriel Dos Reis Opened: 2011-05-17 Last modified: 2011-09-06

View all other issues in [numarray].

View all issues with Review status.

Discussion:

It was just brought to my attention that the pair of functions begin/end were added to valarray component. Those additions strike me as counter to the long standing agreement that valarray<T> is not yet another container. Valarray values are in general supposed to be treated as a whole, and as such has a loose specification allowing expression template techniques.

The addition of these functions sound to me as making it much harder (or close to impossible) to effectively use expression templates as implementation techniques, for no clear benefits.

My recommendation would be to drop begin/end - or at least for the const valarray<T>& version. I strongly believe those are defects.

[This issue was discussed on the library reflector starting from c++std-lib-30761. Some of the key conclusions of this discussion were:]

  1. The begin/end members were added to allow valarray to participate in the new range-based for-loop by n2930 and not to make them container-like.
  2. It is currently underspecified when the iterator values returned from begin/end become invalidated. To fix this, these invalidation rules need at least to reflect the invalidation rules of the references returned by the operator[] overloads of valarray (26.6.2.4 [valarray.access]).
  3. A further problem is that the requirements expressed in 26.6.1 [valarray.syn] p.3-5 enforce an implementation to provide further overloads of begin/end, if the replacement type technique is used (which was clearly part of the design of valarray). Providing such additional overloads would also lead to life-time problems in examples like begin(x + y) where x and y are expressions involving valarray objects. To fix this, the begin/end overloads could be explicitly excluded from the general statements of 26.6.1 [valarray.syn] p.3-5. This would make it unspecified whether the expression begin(x + y) would be well-formed, portable code would need to write this as begin(std::valarray<T>(x + y)).

[ 2011 Bloomington ]

The intent of these overloads is entirely to support the new for syntax, and not to create new containers.

Stefanus provides suggested wording.

Proposed resolution:

In 26.6.1 [valarray.syn]/4, make the following insertion:

4 Implementations introducing such replacement types shall provide additional functions and operators as follows:

— for every function taking a const valarray<T>& other than begin and end (26.6.10 [valarray.range]), identical functions taking the replacement types shall be added;

— for every function taking two const valarray<T>& arguments, identical functions taking every combination of const valarray<T>& and replacement types shall be added.

In 26.6.10 [valarray.range], make the following insertion:

1 In the begin and end function templates that follow, unspecified1 is a type that meets the requirements of a mutable random access iterator (24.2.7) whose value_type is the template parameter T and whose reference type is T&. unspecified2 is a type that meets the requirements of a constant random access iterator (24.2.7) whose value_type is the template parameter T and whose reference type is const T&.

2 The iterators returned by begin and end for an array are guaranteed to be valid until the member function resize(size_t, T) (26.6.2.8 [valarray.members]) is called for that array or until the lifetime of that array ends, whichever happens first.


2059. C++0x ambiguity problem with map::erase

Section: 23.4.4 [map] Status: Review Submitter: Christopher Jefferson Opened: 2011-05-18 Last modified: 2011-09-06

View all other issues in [map].

View all issues with Review status.

Discussion:

map::erase (and several related methods) took an iterator in C++03, but take a const_iterator in C++0x. This breaks code where the map's key_type has a constructor which accepts an iterator (for example a template constructor), as the compiler cannot choose between erase(const key_type&) and erase(const_iterator).

#include <map>

struct X
{
  template<typename T>
  X(T&) {}
};

bool operator<(const X&, const X&) { return false; }

void erasor(std::map<X,int>& s, X x)
{
  std::map<X,int>::iterator it = s.find(x);
  if (it != s.end())
    s.erase(it);
}

[ 2011 Bloomington ]

This issue affects only associative container erase calls, and is not more general, as these are the only functions that are also overloaded on another single arguement that might cause confusion - the erase by key method. The complete resolution should simply restore the iterator overload in addition to the const_iterator overload for all eight associative containers.

Proposed wording supplied by Alan Talbot, and moved to Review.

Proposed resolution:

Editorial note: The following things are different between 23.2.4 [associative.reqmts] p.8 and 23.2.5 [unord.req] p.10. These should probably be reconciled.

  1. First uses the convention "denotes"; second uses the convention "is".
  2. First redundantly says: "If no such element exists, returns a.end()." in erase table entry, second does not.

23.2.4 [associative.reqmts] Associative containers

8 In Table 102, X denotes an associative container class, a denotes a value of X, a_uniq denotes a value of X when X supports unique keys, a_eq denotes a value of X when X supports multiple keys, u denotes an identifier, i and j satisfy input iterator requirements and refer to elements implicitly convertible to value_type, [i,j) denotes a valid range, p denotes a valid const iterator to a, q denotes a valid dereferenceable const iterator to a, r denotes a valid dereferenceable iterator to a, [q1, q2) denotes a valid range of const iterators in a, il designates an object of type initializer_list<value_type>, t denotes a value of X::value_type, k denotes a value of X::key_type and c denotes a value of type X::key_compare. A denotes the storage allocator used by X, if any, or std::allocator<X::value_type> otherwise, and m denotes an allocator of a type convertible to A.

23.2.4 [associative.reqmts] Associative containers Table 102

Add row:

a.erase(r) iterator erases the element pointed to by r. Returns an iterator pointing to the element immediately following r prior to the element being erased. If no such element exists, returns a.end(). amortized constant

23.2.5 [unord.req] Unordered associative containers

10 In table 103: X is an unordered associative container class, a is an object of type X, b is a possibly const object of type X, a_uniq is an object of type X when X supports unique keys, a_eq is an object of type X when X supports equivalent keys, i and j are input iterators that refer to value_type, [i, j) is a valid range, p and q2 are valid const iterators to a, q and q1 are valid dereferenceable const iterators to a, r is a valid dereferenceable iterator to a, [q1,q2) is a valid range in a, il designates an object of type initializer_list<value_type>, t is a value of type X::value_type, k is a value of type key_type, hf is a possibly const value of type hasher, eq is a possibly const value of type key_equal, n is a value of type size_type, and z is a value of type float.

23.2.5 [unord.req] Unordered associative containers Table 103

Add row:

a.erase(r) iterator Erases the element pointed to by r. Returns the iterator immediately following r prior to the erasure. Average case O(1), worst case O(a.size()).

23.4.4.1 [map.overview] Class template map overview p. 2

iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);

23.4.5.1 [multimap.overview] Class template multimap overview p. 2

iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);

23.4.6.1 [set.overview] Class template set overview p. 2

iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);

23.4.7.1 [multiset.overview] Class template multiset overview

iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);

23.5.4.1 [unord.map.overview] Class template unordered_map overview p. 3

iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);

23.5.5.1 [unord.multimap.overview] Class template unordered_multimap overview p. 3

iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);

23.5.6.1 [unord.set.overview] Class template unordered_set overview p. 3

iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);

23.5.7.1 [unord.multiset.overview] Class template unordered_multiset overview p. 3

iterator erase(iterator position);
iterator erase(const_iterator position);
size_type erase(const key_type& x);
iterator erase(const_iterator first, const_iterator last);

[diff.cpp03.containers] C.2.12 Clause 23: containers library

23.2.3, 23.2.4

Change: Signature changes: from iterator to const_iterator parameters

Rationale: Overspecification. Effects: The signatures of the following member functions changed from taking an iterator to taking a const_iterator:

Valid C++ 2003 code that uses these functions may fail to compile with this International Standard.


2061. make_move_iterator and arrays

Section: 24.3 [iterator.synopsis], 24.5.3 [move.iterators] Status: Ready Submitter: Marc Glisse Opened: 2011-05-28 Last modified: 2011-09-06

View all other issues in [iterator.synopsis].

View all issues with Ready status.

Discussion:

The standard library always passes template iterators by value and never by reference, which has the nice effect that an array decays to a pointer. There is one exception: make_move_iterator.

#include <iterator>
int main(){
  int a[]={1,2,3,4};
  std::make_move_iterator(a+4);
  std::make_move_iterator(a); // fails here
}

[ 2011 Bloomington. ]

Move to Ready.

Proposed resolution:

This wording is relative to the FDIS.

  1. Modify the header <iterator> synopsis in 24.3 [iterator.synopsis]:

    namespace std {
      […]
      template <class Iterator>
      move_iterator<Iterator> make_move_iterator(const Iterator&Iterator i);
    
      […]
    }
    
  2. Modify the class template move_iterator synopsis in 24.5.3.1 [move.iterator]:

    namespace std {
      […]
      template <class Iterator>
      move_iterator<Iterator> make_move_iterator(const Iterator&Iterator i);
    }
    
  3. Modify 24.5.3.3.14 [move.iter.nonmember]:

    template <class Iterator>
    move_iterator<Iterator> make_move_iterator(const Iterator&Iterator i);
    

    -3- Returns: move_iterator<Iterator>(i).


2062. Effect contradictions w/o no-throw guarantee of std::function swaps

Section: 20.8.11.2 [func.wrap.func], 20.8.11.2.2 [func.wrap.func.mod] Status: Open Submitter: Daniel Krügler Opened: 2011-05-28 Last modified: 2011-09-06

View all other issues in [func.wrap.func].

View all issues with Open status.

Discussion:

Howard Hinnant observed in reflector message c++std-lib-30841 that 20.8.11.2 [func.wrap.func] makes the member swap noexcept, even though the non-member swap is not noexcept.

The latter was an outcome of the discussions during the Batavia meeting and the Madrid meeting involving LWG 1349, which seems to indicate that the remaining noexcept specifier at the member swap is incorrect and should be removed.

But if we allow for a potentially throwing member swap of std::function, this causes another conflict with the exception specification for the following member function:

template<class F> function& operator=(reference_wrapper<F> f) noexcept;

Effects: function(f).swap(*this);

Note that in this example the sub-expression function(f) does not cause any problems, because of the nothrow-guarantee given in 20.8.11.2.1 [func.wrap.func.con] p. 10. The problem is located in the usage of the swap which could potentially throw given the general latitude.

So, either the Madrid meeting decision need to be revised (and both member and free swap of std::function should be noexcept), or this function needs to be adapted as well, e.g. by taking the exception-specification away or by changing the semantics.

One argument for "swap-may-throw" would be to allow for small-object optimization techniques where the copy of the target may throw. But given the fact that the swap function has been guaranteed to be "Throws: Nothing" from TR1 on, it seems to me that that there would still be opportunities to perform small-object optimizations just restricted to the set of target copies that cannot throw.

In my opinion member swap of std::function has always been intended to be no-throw, because otherwise there would be no good technical reason to specify the effects of several member functions in terms of the "construct-swap" idiom (There are three functions that are defined this way), which provides the strong exception safety in this case. I suggest to enforce that both member swap and non-member swap of std::function are nothrow functions as it had been guaranteed since TR1 on.

[ 2011 Bloomington ]

Dietmar: May not be swappable in the first place.

Alisdair: This is wide contact. Then we should be taking noexcept off instead of putting it on. This is preferred resolution.

Pablo: This is bigger issue. Specification of assignment in terms of swap is suspect to begin with. It is over specification. How this was applied to string is a better example to work from.

Pablo: Two problems: inconsistency that should be fixed (neither should have noexcept), the other issues is that assignment should not be specified in terms of swap. There are cases where assignment should succeed where swap would fail. This is easier with string as it should follow container rules.

Action Item (Alisdair): There are a few more issues found to file.

Dave: This is because of allocators? The allocator makes this not work.

Howard: There is a type erased allocator in shared_ptr. There is a noexcept allocator in shared_ptr.

Pablo: shared_ptr is a different case. There are shared semantics and the allocator does move around. A function does not have shared semantics.

Alisdair: Function objects think they have unique ownership.

Howard: In function we specify semantics with copy construction and swap.

Action Item (Pablo): Write this up better (why assignment should not be defined in terms of swap)

Howard: Not having trouble making function constructor no throw.

Dietmar: Function must allocate memory.

Howard: Does not put stuff that will throw on copy or swap in small object optimization. Put those on heap. Storing allocator, but has to be no throw copy constructable.

Pablo: Are you allowed to or required to swap or move allocators in case or swap or move.

Dave: An allocator that is type erased should be different...

Pablo: it is

Dave: Do you need to know something about allocator types? But only at construction time.

Pablo: You could have allocators that are different types.

Dave: Swap is two ended operation.

Pablo: Opinion is that both have to say propagate on swap for them to swap.

John: It is not arbitrary. If one person says no. No is no.

Howard: Find noexcept swap to be very useful. Would like to move in that direction and bring container design along.

Dave: If you have something were allocator must not propagate you can detect that at construction time.

...

Pablo: Need to leave this open and discuss in smaller group.

Alisdair: Tried to add boost::any as TR2 proposal and ran into this issue. Only the first place where we run into issues with type erased allocators. Suggest we move it to open.

Action Item: Move to open.

Action Item (Pablo works with Howard and Daniel): Address the more fundamental issue (which may be multiple issues) and write up findings.

[ Original resolution: ]

This wording is relative to the FDIS.

  1. Modify the header <functional> synopsis in 20.8 [function.objects] as indicated:

    namespace std {
      […]
    
      template<class R, class... ArgTypes>
      void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
    
      […]
    }
    
  2. Modify the class template function synopsis in 20.8.11.2 [func.wrap.func] as indicated:

    namespace std {
      […]
    
      // [func.wrap.func.alg], specialized algorithms:
      template<class R, class... ArgTypes>
      void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&) noexcept;
    
      […]
    }
    
  3. Modify 20.8.11.2.7 [func.wrap.func.alg] as indicated:

    template<class R, class... ArgTypes>
    void swap(function<R(ArgTypes...)>& f1, function<R(ArgTypes...)>& f2) noexcept;
    

    -1- Effects: f1.swap(f2);

Proposed resolution:


2063. Contradictory requirements for string move assignment

Section: 21.4 [basic.string] Status: Open Submitter: Howard Hinnant Opened: 2011-05-29 Last modified: 2011-09-06

View other active issues in [basic.string].

View all other issues in [basic.string].

View all issues with Open status.

Discussion:

21.4.1 [string.require]/p4 says that basic_string is an "allocator-aware" container and behaves as described in 23.2.1 [container.requirements.general].

23.2.1 [container.requirements.general] describes move assignment in p7 and Table 99.

If allocator_traits<allocator_type>::propagate_on_container_move_assignment::value is false, and if the allocators stored in the lhs and rhs sides are not equal, then move assigning a string has the same semantics as copy assigning a string as far as resources are concerned (resources can not be transferred). And in this event, the lhs may have to acquire resources to gain sufficient capacity to store a copy of the rhs.

However 21.4.2 [string.cons]/p22 says:

basic_string<charT,traits,Allocator>&
operator=(basic_string<charT,traits,Allocator>&& str) noexcept;

Effects: If *this and str are not the same object, modifies *this as shown in Table 71. [Note: A valid implementation is swap(str). — end note ]

These two specifications for basic_string::operator=(basic_string&&) are in conflict with each other. It is not possible to implement a basic_string which satisfies both requirements.

Additionally assign from an rvalue basic_string is defined as:

basic_string& assign(basic_string&& str) noexcept;

Effects: The function replaces the string controlled by *this with a string of length str.size() whose elements are a copy of the string controlled by str. [ Note: A valid implementation is swap(str). — end note ]

It seems contradictory that this member can be sensitive to propagate_on_container_swap instead of propagate_on_container_move_assignment. Indeed, there is a very subtle chance for undefined behavior here: If the implementation implements this in terms of swap, and if propagate_on_container_swap is false, and if the two allocators are unequal, the behavior is undefined, and will likely lead to memory corruption. That's a lot to go wrong under a member named "assign".

[ 2011 Bloomington ]

Alisdair: Can this be conditional noexcept?

Pablo: We said we were not going to put in many conditional noexcepts. Problem is not allocator, but non-normative definition. It says swap is a valid operation which it is not.

Dave: Move assignment is not a critical method.

Alisdair: Was confusing assignment and construction.

Dave: Move construction is critical for efficiency.

Kyle: Is it possible to test for noexcept.

Alisdair: Yes, query the noexcept operator.

Alisdair: Agreed there is a problem that we cannot unconditionally mark these operations as noexcpet.

Pablo: How come swap is not defined in alloc

Alisdair: It is in utility.

Pablo: Swap has a conditional noexcept. Is no throw move constructable, is no throw move assignable.

Pablo: Not critical for strings or containers.

Kyle: Why?

Pablo: They do not use the default swap.

Dave: Important for deduction in other types.

Alisdair: Would change the policy we adopted during FDIS mode.

Pablo: Keep it simple and get some vendor experience.

Alisdair: Is this wording correct? Concerned with bullet 2.

Pablo: Where does it reference containers section.

Alisdair: String is a container.

Alisdair: We should not remove redundancy piecemeal.

Pablo: I agree. This is a deviation from rest of string. Missing forward reference to containers section.

Pablo: To fix section 2. Only the note needs to be removed. The rest needs to be a forward reference to containers.

Alisdair: That is a new issue.

Pablo: Not really. Talking about adding one sentence, saying that basic string is a container.

Dave: That is not just a forward reference, it is a semantic change.

PJ: We intended to make it look like a container, but it did not satisfy all the requirements.

Pablo: Clause 1 is correct. Clause 2 is removing note and noexcept (do not remove the rest). Clause 3 is correct.

Alisdair: Not sure data() is correct (in clause 2).

Conclusion: Move to open, Alisdair and Pablo volunteered to provide wording

[ originally proposed wording: ]

This wording is relative to the FDIS.

  1. Modify the class template basic_string synopsis in 21.4 [basic.string]:

    namespace std {
      template<class charT, class traits = char_traits<charT>,
        class Allocator = allocator<charT> >
      class basic_string {
      public:
        […]
        basic_string& operator=(basic_string&& str) noexcept;
        […]
        basic_string& assign(basic_string&& str) noexcept;
        […]
      };
    }
    
  2. Remove the definition of the basic_string move assignment operator from 21.4.2 [string.cons] entirely, including Table 71 — operator=(const basic_string<charT, traits, Allocator>&&). This is consistent with how we define move assignment for the containers in Clause 23:

    basic_string<charT,traits,Allocator>&
    operator=(basic_string<charT,traits,Allocator>&& str) noexcept;
    

    -22- Effects: If *this and str are not the same object, modifies *this as shown in Table 71. [ Note: A valid implementation is swap(str). — end note ]

    -23- If *this and str are the same object, the member has no effect.

    -24- Returns: *this

    Table 71 — operator=(const basic_string<charT, traits, Allocator>&&)
    Element Value
    data() points at the array whose first element was pointed at by str.data()
    size() previous value of str.size()
    capacity() a value at least as large as size()
  3. Modify the paragraphs prior to 21.4.6.3 [string::assign] p.3 as indicated (The first insertion recommends a separate paragraph number for the indicated paragraph):

    basic_string& assign(basic_string&& str) noexcept;
    

    -?- Effects: Equivalent to *this = std::move(str). The function replaces the string controlled by *this with a string of length str.size() whose elements are a copy of the string controlled by str. [ Note: A valid implementation is swap(str). — end note ]

    -3- Returns: *this

Proposed resolution:


2064. More noexcept issues in basic_string

Section: 21.4 [basic.string] Status: Ready Submitter: Howard Hinnant Opened: 2011-05-29 Last modified: 2011-09-06

View other active issues in [basic.string].

View all other issues in [basic.string].

View all issues with Ready status.

Discussion:

The following inconsistencies regarding noexcept for basic_string are noted.

Member swap is not marked noexcept:

void swap(basic_string& str);

But the global swap is marked noexcept:

template<class charT, class traits, class Allocator>
void swap(basic_string<charT,traits,Allocator>& lhs,
          basic_string<charT,traits,Allocator>& rhs) noexcept;

But only in the definition, not in the synopsis.

All comparison operators are marked noexcept in their definitions, but not in the synopsis.

The compare function that takes a pointer:

int compare(const charT *s) const;

is not marked noexcept. But some of the comparison functions which are marked noexcept (only in their definition) are specified to call the throwing compare operator:

template<class charT, class traits, class Allocator>
bool operator==(const basic_string<charT,traits,Allocator>& lhs,
                const charT* rhs) noexcept;

Returns: lhs.compare(rhs) == 0.

All functions with a narrow contract should not be declared as noexcept according to the guidelines presented in n3279. Among these narrow contract functions are the swap functions (23.2.1 [container.requirements.general] p. 8) and functions with non-NULL const charT* parameters.

[2011-06-08 Daniel provides wording]

[Bloomington, 2011]

Move to Ready

Proposed resolution:

This wording is relative to the FDIS. Both move-assignment operator and the moving assign function are not touched by this issue, because they are handled separately by issue 2063.

  1. Modify the header <string> synopsis in 21.3 [string.classes] as indicated (Rationale: Adding noexcept to these specific overloads is in sync with applying the same rule to specific overloads of the member functions find, compare, etc. This approach deviates from that taken in n3279, but seems more consistent given similar application for comparable member functions):

    #include <initializer_list>
    
    namespace std {
    
      […]
      template<class charT, class traits, class Allocator>
        bool operator==(const basic_string<charT,traits,Allocator>& lhs,
                        const basic_string<charT,traits,Allocator>& rhs) noexcept;
      […]
      template<class charT, class traits, class Allocator>
        bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
                        const basic_string<charT,traits,Allocator>& rhs) noexcept;
      […]
    
      template<class charT, class traits, class Allocator>
        bool operator<(const basic_string<charT,traits,Allocator>& lhs,
                       const basic_string<charT,traits,Allocator>& rhs) noexcept;
      […]
      template<class charT, class traits, class Allocator>
        bool operator>(const basic_string<charT,traits,Allocator>& lhs,
                       const basic_string<charT,traits,Allocator>& rhs) noexcept;
      […]
    
      template<class charT, class traits, class Allocator>
        bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
                        const basic_string<charT,traits,Allocator>& rhs) noexcept;
      […]
      template<class charT, class traits, class Allocator>
        bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
                        const basic_string<charT,traits,Allocator>& rhs) noexcept;
      […]
    }
    
  2. Modify the class template basic_string synopsis in 21.4 [basic.string] as indicated (Remark 1: The noexcept at the move-constructor is fine, because even for a small-object optimization there is no problem here, because basic_string::value_type is required to be a non-array POD as of 21.1 [strings.general] p1, Remark 2: This proposal removes the noexcept at single character overloads of find, rfind, etc. because they are defined in terms of potentially allocating functions. It seems like an additional issue to me to change the semantics in terms of non-allocating functions and adding noexcept instead):

    namespace std {
      template<class charT, class traits = char_traits<charT>,
        class Allocator = allocator<charT> >
      class basic_string {
      public:
        […]
        // [string.ops], string operations:
        […]
        size_type find (charT c, size_type pos = 0) const noexcept;
        […]
        size_type rfind(charT c, size_type pos = npos) const noexcept;
        […]
        size_type find_first_of(charT c, size_type pos = 0) const noexcept;
        […]
        size_type find_last_of (charT c, size_type pos = npos) const noexcept;
        […]
        size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
        […]
        size_type find_last_not_of (charT c, size_type pos = npos) const noexcept;
        […]
      };
    }
    
  3. Modify 21.4.7.2 [string::find] before p5 and before p7 as indicated:

    size_type find(const charT* s, size_type pos = 0) const noexcept;
    […]
    size_type find(charT c, size_type pos = 0) const noexcept;
    

    -7- Returns: find(basic_string<charT,traits,Allocator>(1,c), pos).

  4. Modify 21.4.7.3 [string::rfind] before p7 as indicated:

    size_type rfind(charT c, size_type pos = npos) const noexcept;
    

    -7- Returns: rfind(basic_string<charT,traits,Allocator>(1,c),pos).

  5. Modify 21.4.7.4 [string::find.first.of] before p7 as indicated:

    size_type find_first_of(charT c, size_type pos = 0) const noexcept;
    

    -7- Returns: find_first_of(basic_string<charT,traits,Allocator>(1,c), pos).

  6. Modify 21.4.7.5 [string::find.last.of] before p7 as indicated:

    size_type find_last_of(charT c, size_type pos = npos) const noexcept;
    

    -7- Returns: find_last_of(basic_string<charT,traits,Allocator>(1,c),pos).

  7. Modify 21.4.7.6 [string::find.first.not.of] before p7 as indicated:

    size_type find_first_not_of(charT c, size_type pos = 0) const noexcept;
    

    -7- Returns: find_first_not_of(basic_string(1, c), pos).

  8. Modify 21.4.7.7 [string::find.last.not.of] before p7 as indicated:

    size_type find_last_not_of(charT c, size_type pos = npos) const noexcept;
    

    -7- Returns: find_last_not_of(basic_string(1, c), pos).

  9. Modify 21.4.8.2 [string::operator==] before p2+p3 as indicated:

    template<class charT, class traits, class Allocator>
    bool operator==(const charT* lhs,
                    const basic_string<charT,traits,Allocator>& rhs) noexcept;
    
    […]
    				
    template<class charT, class traits, class Allocator>
    bool operator==(const basic_string<charT,traits,Allocator>& lhs,
                    const charT* rhs) noexcept;
    
  10. Modify 21.4.8.3 [string::op!=] before p2+p3 as indicated:

    template<class charT, class traits, class Allocator>
    bool operator!=(const charT* lhs,
                    const basic_string<charT,traits,Allocator>& rhs) noexcept;
    
    […]
    				
    template<class charT, class traits, class Allocator>
    bool operator!=(const basic_string<charT,traits,Allocator>& lhs,
                    const charT* rhs) noexcept;
    
  11. Modify 21.4.8.4 [string::op<] before p2+p3 as indicated:

    template<class charT, class traits, class Allocator>
    bool operator<(const charT* lhs,
                   const basic_string<charT,traits,Allocator>& rhs) noexcept;
    
    […]
    				
    template<class charT, class traits, class Allocator>
    bool operator<(const basic_string<charT,traits,Allocator>& lhs,
                   const charT* rhs) noexcept;
    
  12. Modify 21.4.8.5 [string::op>] before p2+p3 as indicated:

    template<class charT, class traits, class Allocator>
    bool operator>(const charT* lhs,
                   const basic_string<charT,traits,Allocator>& rhs) noexcept;
    
    […]
    				
    template<class charT, class traits, class Allocator>
    bool operator>(const basic_string<charT,traits,Allocator>& lhs,
                   const charT* rhs) noexcept;
    
  13. Modify 21.4.8.6 [string::op<=] before p2+p3 as indicated:

    template<class charT, class traits, class Allocator>
    bool operator<=(const charT* lhs,
                    const basic_string<charT,traits,Allocator>& rhs) noexcept;
    
    […]
    				
    template<class charT, class traits, class Allocator>
    bool operator<=(const basic_string<charT,traits,Allocator>& lhs,
                    const charT* rhs) noexcept;
    
  14. Modify 21.4.8.7 [string::op>=] before p2+p3 as indicated:

    template<class charT, class traits, class Allocator>
    bool operator>=(const charT* lhs,
                    const basic_string<charT,traits,Allocator>& rhs) noexcept;
    
    […]
    				
    template<class charT, class traits, class Allocator>
    bool operator>=(const basic_string<charT,traits,Allocator>& lhs,
                    const charT* rhs) noexcept;
    
  15. Modify 21.4.8.8 [string.special] as indicated (Remark: The change of the semantics guarantees as of 17.5.1.4 [structure.specifications] p4 that the "Throws: Nothing" element of member swap is implied):

    template<class charT, class traits, class Allocator>
      void swap(basic_string<charT,traits,Allocator>& lhs,
        basic_string<charT,traits,Allocator>& rhs) noexcept;
    

    -1- Effects: Equivalent to lhs.swap(rhs);


2065. Minimal allocator interface

Section: 17.6.3.5 [allocator.requirements] Status: Ready Submitter: Jonathan Wakely Opened: 2011-06-06 Last modified: 2011-09-06

View other active issues in [allocator.requirements].

View all other issues in [allocator.requirements].

View all issues with Ready status.

Discussion:

The example in 17.6.3.5 [allocator.requirements] says SimpleAllocator satisfies the requirements of Table 28 — Allocator requirements, but it doesn't support comparison for equality/inequality.

[Bloomington, 2011]

Move to Ready

Proposed resolution:

This wording is relative to the FDIS.

  1. Modify the example in 17.6.3.5 [allocator.requirements] p5 as indicated:

    -5- […]

    [ Example: the following is an allocator class template supporting the minimal interface that satisfies the requirements of Table 28:

    template <class Tp>
    struct SimpleAllocator {
      typedef Tp value_type;
      SimpleAllocator(ctor args);
      template <class T> SimpleAllocator(const SimpleAllocator<T>& other);
      Tp *allocate(std::size_t n);
      void deallocate(Tp *p, std::size_t n);
    };
    
    template <class T, class U>
    bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
    template <class T, class U>
    bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
    

    end example ]


2066. Missing specification of vector::resize(size_type)

Section: 23.3.6.3 [vector.capacity] Status: Tentatively Resolved Submitter: Rani Sharoni Opened: 2011-03-29 Last modified: 2011-09-06

View other active issues in [vector.capacity].

View all other issues in [vector.capacity].

Discussion:

In C++1x (N3090) there are two version of vector::resize — 23.3.6.3 [vector.capacity]:

void resize(size_type sz);
void resize(size_type sz, const T& c);

The text in 23.3.6.3 [vector.capacity]/12 only mentions "no effects on throw" for the two args version of resize:

Requires: If an exception is thrown other than by the move constructor of a non-CopyConstructible T there are no effects.

This seems like unintentional oversight since resize(size) is semantically the same as resize(size, T()). Additionally, the C++03 standard only specify single version of resize with default for the second argument - 23.2.4:

void resize(size_type sz, T c = T());

Therefore not requiring same guarantees for both version of resize is in fact a regression.

[2011-06-12: Daniel comments]

The proposed resolution for issue 2033 should solve this issue as well.

[ 2011 Bloomington ]

This issue will be resolved by issue 2033, and closed when this issue is applied.

Proposed resolution:

Apply the proposed resolution of issue 2033


2067. packaged_task should have deleted copy c'tor with const parameter

Section: 30.6.9 [futures.task] Status: Ready Submitter: Daniel Krügler Opened: 2011-06-16 Last modified: 2011-09-06

View all other issues in [futures.task].

View all issues with Ready status.

Discussion:

Class template packaged_task is a move-only type with the following form of the deleted copy operations:

packaged_task(packaged_task&) = delete;
packaged_task& operator=(packaged_task&) = delete;

Note that the argument types are non-const. This does not look like a typo to me, this form seems to exist from the very first proposing paper on N2276. Using either of form of the copy-constructor did not make much difference before the introduction of defaulted special member functions, but it makes now an observable difference. This was brought to my attention by a question on a German C++ newsgroup where the question was raised why the following code does not compile on a recent gcc:

#include <utility>
#include <future>
#include <iostream>
#include <thread>

int main(){
  std::packaged_task<void()> someTask([]{ std::cout << std::this_thread::get_id() << std::endl; });
  std::thread someThread(std::move(someTask)); // Error here
  // Remainder omitted
}

It turned out that the error was produced by the instantiation of some return type of std::bind which used a defaulted copy-constructor, which leads to a const declaration conflict with [class.copy] p8.

Some aspects of this problem are possibly core-language related, but I consider it more than a service to programmers, if the library would declare the usual form of the copy operations (i.e. those with const first parameter type) as deleted for packaged_task to prevent such problems.

A similar problem exists for class template basic_ostream in 27.7.3.1 [ostream]:

namespace std {
  template <class charT, class traits = char_traits<charT> >
  class basic_ostream : virtual public basic_ios<charT,traits> {
    […]

    // 27.7.3.3 Assign/swap
    basic_ostream& operator=(basic_ostream& rhs) = delete;
    basic_ostream& operator=(const basic_ostream&& rhs);
    void swap(basic_ostream& rhs);
};

albeit this could be considered as an editorial swap of copy and move assignment operator, I suggest to fix this as part of this issue as well.

[ 2011 Bloomington. ]

Move to Ready.

Proposed resolution:

This wording is relative to the FDIS.

  1. Modify the class template basic_ostream synopsis in 27.7.3.1 [ostream] as indicated (Note: The prototype signature of the move assignment operator in 27.7.3.3 [ostream.assign] is fine):

    namespace std {
      template <class charT, class traits = char_traits<charT> >
      class basic_ostream : virtual public basic_ios<charT,traits> {
        […]
    
        // 27.7.3.3 Assign/swap
        basic_ostream& operator=(const basic_ostream& rhs) = delete;
        basic_ostream& operator=(const basic_ostream&& rhs);
        void swap(basic_ostream& rhs);
    };
    
  2. Modify the class template packaged_task synopsis in 30.6.9 [futures.task] p2 as indicated:

    namespace std {
      template<class> class packaged_task; // undefined
    
      template<class R, class... ArgTypes>
      class packaged_task<R(ArgTypes...)> {
      public:
        […]
      
        // no copy
        packaged_task(const packaged_task&) = delete;
        packaged_task& operator=(const packaged_task&) = delete;
        
        […]
      };
      […]
    }
    

2069. Inconsistent exception spec for basic_string move constructor

Section: 21.4.2 [string.cons] Status: Ready Submitter: Bo Persson Opened: 2011-07-01 Last modified: 2011-09-06

View all issues with Ready status.

Discussion:

Sub-clause 21.4.2 [string.cons] contains these constructors in paragraphs 2 and 3:

basic_string(const basic_string<charT,traits,Allocator>& str);
basic_string(basic_string<charT,traits,Allocator>&& str) noexcept;

[…]

-3- Throws: The second form throws nothing if the allocator's move constructor throws nothing.

How can it ever throw anything if it is marked noexcept?

[2011-07-11: Daniel comments and suggests wording changes]

Further, according to paragraph 18 of the same sub-clause:

basic_string(const basic_string& str, const Allocator& alloc);
basic_string(basic_string&& str, const Allocator& alloc);

[…]

-18- Throws: The second form throws nothing if alloc == str.get_allocator() unless the copy constructor for Allocator throws.

The constraint "unless the copy constructor for Allocator throws" is redundant, because according to Table 28 — Allocator requirements, the expressions

X a1(a);
X a(b);

impose the requirement: "Shall not exit via an exception".

[ 2011 Bloomington. ]

Move to Ready.

Proposed resolution:

This wording is relative to the FDIS.

  1. Change 21.4.2 [string.cons] p3 as indicated (This move constructor has a wide contract and is therefore safely marked as noexcept):

    basic_string(const basic_string<charT,traits,Allocator>& str);
    basic_string(basic_string<charT,traits,Allocator>&& str) noexcept;
    

    -2- Effects: Constructs an object of class basic_string as indicated in Table 64. In the second form, str is left in a valid state with an unspecified value.

    -3- Throws: The second form throws nothing if the allocator's move constructor throws nothing.

  2. Change 21.4.2 [string.cons] p18 as indicated (This move-like constructor may throw, if the allocators don't compare equal, but not because of a potentially throwing allocator copy constructor, only because the allocation attempt may fail and throw an exception):

    basic_string(const basic_string& str, const Allocator& alloc);
    basic_string(basic_string&& str, const Allocator& alloc);
    

    […]

    -18- Throws: The second form throws nothing if alloc == str.get_allocator() unless the copy constructor for Allocator throws.


2070. allocate_shared should use allocator_traits<A>::construct

Section: 20.7.2.2.6 [util.smartptr.shared.create] Status: Open Submitter: Jonathan Wakely Opened: 2011-07-11 Last modified: 2011-09-06

View all issues with Open status.

Discussion:

20.7.2.2.6 [util.smartptr.shared.create] says:

-2- Effects: Allocates memory suitable for an object of type T and constructs an object in that memory via the placement new expression ::new (pv) T(std::forward<Args>(args)...). The template allocate_shared uses a copy of a to allocate memory. If an exception is thrown, the functions have no effect.

This explicitly requires placement new rather than using allocator_traits<A>::construct(a, (T*)pv, std::forward<Args>(args)...) In most cases that would result in the same placement new expression, but would allow more control over how the object is constructed e.g. using scoped_allocator_adaptor to do uses-allocator construction, or using an allocator declared as a friend to construct objects with no public constructors.

[ 2011-08-16 Bloomington: ]

Agreed to fix in principle, but believe that make_shared and allocate_shared have now diverged enough that their descriptions should be separated. Pablo and Stefanus to provide revised wording.

Daniel's (old) proposed resolution

This wording is relative to the FDIS.

  1. Change the following paragraphs of 20.7.2.2.6 [util.smartptr.shared.create] as indicated (The suggested removal of the last sentence of p1 is not strictly required to resolve this issue, but is still recommended, because it does not say anything new but may give the impression that it says something new):
  2. template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
    template<class T, class A, class... Args>
      shared_ptr<T> allocate_shared(const A& a, Args&&... args);
    

    -1- Requires: For the template make_shared, tThe expression ::new (pv) T(std::forward<Args>(args)...), where pv has type void* and points to storage suitable to hold an object of type T, shall be well formed. For the template allocate_shared, the expression allocator_traits<A>::construct(a, pt, std::forward<Args>(args)...), where pt has type T* and points to storage suitable to hold an object of type T, shall be well formed. A shall be an allocator ([allocator.requirements]). The copy constructor and destructor of A shall not throw exceptions.

    -2- Effects: Allocates memory suitable for an object of type T and constructs an object in that memory. The template make_shared constructs the object via the placement new expression ::new (pv) T(std::forward<Args>(args)...). The template allocate_shared uses a copy of a to allocate memory and constructs the object by calling allocator_traits<A>::construct(a, pt, std::forward<Args>(args)...). If an exception is thrown, the functions have no effect.

    -3- Returns: A shared_ptr instance that stores and owns the address of the newly constructed object of type T.

    -4- Postconditions: get() != 0 && use_count() == 1

    -5- Throws: bad_alloc, or, for the template make_shared, an exception thrown from the constructor of T, or, for the template allocate_shared, an exception thrown from A::allocate or from allocator_traits<A>::constructfrom the constructor of T.

    -6- Remarks: Implementations are encouraged, but not required, to perform no more than one memory allocation. [ Note: This provides efficiency equivalent to an intrusive smart pointer. — end note ]

    -7- [ Note: These functions will typically allocate more memory than sizeof(T) to allow for internal bookkeeping structures such as the reference counts. — end note ]

Proposed resolution:

This wording is relative to the FDIS.

  1. Change the following paragraphs of 20.7.2.2.6 [util.smartptr.shared.create] as indicated (The suggested removal of the last sentence of p1 is not strictly required to resolve this issue, but is still recommended, because it does not say anything new but may give the impression that it says something new):
  2. template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args);
    template<class T, class A, class... Args>
    
      shared_ptr<T> allocate_shared(const A& a, Args&&... args);
    

    -1- Requires: The expression ::new (pv) T(std::forward<Args>(args)...), where pv has type void* and points to storage suitable to hold an object of type T, shall be well formed. A shall be an allocator ([allocator.requirements]). The copy constructor and destructor of A shall not throw exceptions.

    -2- Effects: Allocates memory suitable for an object of type T and constructs an object in that memory via the placement new expression ::new (pv) T(std::forward<Args>(args)...). The template allocate_shared uses a copy of a to allocate memory. If an exception is thrown, the functions have has no effect.

    -3- Returns: A shared_ptr instance that stores and owns the address of the newly constructed object of type T.

    -4- Postconditions: get() != 0 && use_count() == 1

    -5- Throws: bad_alloc, or an exception thrown from A::allocate or from the constructor of T>.

    -6- Remarks: Implementations are encouraged, but not required, to perform no more than one memory allocation. [ Note: ThisSuch an implementation provides efficiency equivalent to an intrusive smart pointer. — end note ]

    -7- [ Note: These functionsThis function will typically allocate more memory than sizeof(T) to allow for internal bookkeeping structures such as the reference counts. — end note ]

  3. Add the following new paragraph:
  4. template<class T, class A, class... Args>
      shared_ptr<T> allocate_shared(const A& a, Args&&... args);
    
    

    -1- Requires: The expression allocator_traits<A>::construct(a, pt, std::forward<Args>(args)...), shall be well formed, where pt has type T* and points to storage suitable to hold an object of type T. A shall be an allocator ([allocator.requirements]).

    -2- Effects: Allocates memory suitable for an object of type T and constructs an object in that memory. Using a suitably-rebound version A, A2, allocates memory from a copy of a by calling allocator_traits<A2>::allocate(a, 1) and constructs the object by calling allocator_traits<A2>::construct(a, pt, std::forward<Args>(args)...). If an exception is thrown, the function has no effect.

    -3- Returns: A shared_ptr instance that stores and owns the address of the newly constructed object of type T.

    -4- Postconditions: get() != 0 && use_count() == 1

    -5- Throws: nothing unless allocator_traits<A>::allocate or allocator_traits<A>::construct throws an exception.

    -6- Remarks: Implementations are encouraged, but not required, to perform no more than one memory allocation. [ Note: Such an implementation provides efficiency equivalent to an intrusive smart pointer. — end note ]

    -7- [ Note: These functions will typically allocate more memory than sizeof(T) to allow for internal bookkeeping structures such as the reference counts. — end note ]