cplusplus / nbballot

Handling of NB comments in response to ballots
14 stars 4 forks source link

GB-101 24.3.9.5p12,15,20,21 [forward.list.modifiers] Missing preconditions on forward_list modifiers #456

Closed wg21bot closed 1 year ago

wg21bot commented 1 year ago

Some of the modifiers to forward_list are special to that container and accordingly are not described in [container.requirements] ff. Specifically, insert_after (iterator overload), insert_range_after and emplace_after do not verify that the value_type is Cpp17EmplaceConstructible from the appropriate argument(s). Instead, emplace_after specifies that the inserted object is constructed as if by value_type(std::forward<Args>(args)...), but this has a wider meaning (a C-style cast) if sizeof...(Args) == 1: std::forward_list<int*> l;

l.emplace_after(l.before_begin(), 99); libstdc++, libc++ and MS-STL reject this already (they use std::construct_at), so adding a precondition should be editorial.

To P12, prepend: T is Cpp17EmplaceConstructible into this from first. To P15, prepend: T is Cpp17EmplaceConstructible into this from ranges::begin(rg). To P20, prepend: T is Cpp17EmplaceConstructible into *this from args. To P21, replace value_type(std::forward<Args>(args)...) with std::forward<Args>(args)... (cf. sequence.reqmts/22)

JeffGarland commented 1 year ago

LWG discussed 2022-10-26 will open and LWG issue for resolution

JeffGarland commented 1 year ago

LWG3817

jensmaurer commented 1 year ago

Accepted with modification. See LWG3817 for details.