Movatterモバイル変換


[0]ホーム

URL:



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

2861.basic_string should require thatcharT matchtraits::char_type

Section: 27.4.3.2[string.require]Status:C++17Submitter: United StatesOpened: 2017-02-02Last modified: 2020-09-06

Priority:Not Prioritized

View all otherissues in [string.require].

View all issues withC++17 status.

Discussion:

Addresses US 145

There is no requirement thattraits::char_type ischarT, although there is a requirement thatallocator::value_type ischarT. This means that it might be difficult to honour both methods returning reference (such asoperator[]) andcharT& (likefront/back) when traits has a surprisingchar_type. It seems that the allocator shouldnot rebind in such cases, making the reference-returning signatures the problematic ones.

Suggested resolution: Add a requirement thatis_same_v<typename traits::char_type, charT> is true, and simplify so that value_type is just an alias forcharT.

[2017-02-02 Marshall adds]

In [string.require]/3, there's already a note that the types shall be the same. In [string.view.template]/1, it says "In every specializationbasic_string_view<charT, traits, Allocator>, the typetraits shall satisfy the character traits requirements (21.2), and the typetraits::char_type shall name the same type ascharT".

[Kona 2017-02-28]

Accepted as Immediate to resolve NB comment.

Proposed resolution:

Changes are based off ofN4618

  1. Modify [basic.string] as indicated (in the synopsis):

    class basic_string {public://types:  using traits_type      = traits;  using value_type       =charTtypename traits::char_type;  using allocator_type   = Allocator
  2. Change [string.require]/3 as indicated:

    -3- In every specializationbasic_string<charT, traits, Allocator>, the typeallocator_traits<Allocator>::value_type shall name the same type ascharT. Every object of typebasic_string<charT, traits, Allocator> shall use an object of typeAllocator to allocate and free storage for the containedcharT objects as needed. TheAllocator object used shall be obtained as described in 23.2.1.[ Note:In every specializationbasic_string<charT, traits, Allocator>,the typetraits shall satisfy the character traits requirements (21.2), and the typetraits::char_type shallnamebe the same type ascharT; see 21.2. — end note ]


[8]ページ先頭

©2009-2026 Movatter.jp