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++20 status.

3158.tuple(allocator_arg_t, const Alloc&) should be conditionally explicit

Section: 22.4.4.2[tuple.cnstr]Status:C++20Submitter: Jonathan WakelyOpened: 2018-08-21Last modified: 2021-02-25

Priority:3

View otheractive issues in [tuple.cnstr].

View all otherissues in [tuple.cnstr].

View all issues withC++20 status.

Discussion:

std::tuple's allocator-extended constructors say "Effects: Equivalent to the preceding constructors except that each element is constructed with uses-allocator construction". That's not true for the first one, as shown by:

#include <tuple>struct X { explicit X() { } };std::tuple<X> f() { return {}; }std::tuple<X> g() { return { std::allocator_arg, std::allocator<int>{} }; }

The functionf() doesn't compile because of the explicit constructor, butg() does, despite using the same constructor forX. The conditional explicit-ness is not equivalent.

Also, the editor requested that we change "implicitly default-constructible" to use words that mean something. He suggested "copy-list-initializable from an empty list".

[2018-09 Reflector prioritization]

Set Priority to 3

[2019-02; Kona Wednesday night issue processing]

Status to Ready

Proposed resolution:

This wording is relative toN4762.

  1. Modify 22.4.4[tuple.tuple], class templatetuple synopsis, as indicated:

    […]// allocator-extended constructorstemplate<class Alloc>explicit(see below) tuple(allocator_arg_t, const Alloc& a);template<class Alloc>  explicit(see below) tuple(allocator_arg_t, const Alloc& a, const Types&...);[…]
  2. Modify 22.4.4.2[tuple.cnstr], as indicated:

    explicit(see below) constexpr tuple();

    -5-Effects: Value-initializes each element.

    -6-Remarks: This constructor shall not participate in overload resolution unlessis_default_constructible_v<Ti> istrue for alli. [Note: This behavior can be implemented by a constructor template with default template arguments. —end note] The expression insideexplicit evaluates totrue ifand only ifTi is notimplicitly default-constructiblecopy-list-initializable from an empty list for at least onei. [Note: This behavior can be implemented with a trait that checks whether aconst Ti& can be initialized with{}. —end note]

    […]

    template<class Alloc>explicit(see below) tuple(allocator_arg_t, const Alloc& a);template<class Alloc>  explicit(see below) tuple(allocator_arg_t, const Alloc& a, const Types&...);[…]template<class Alloc, class U1, class U2>  explicit(see below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);

    -25-Requires:Alloc shall satisfy theCpp17Allocator requirements (Table 33).

    […]


[8]ページ先頭

©2009-2025 Movatter.jp