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

2796. tuple should be a literal type

Section: 22.4.1 [tuple.general] Status: C++17 Submitter: Jonathan Wakely Opened: 2016-11-09 Last modified: 2017-07-30

Priority: 2

View all other issues in [tuple.general].

View all issues with C++17 status.

Discussion:

Addresses US 109

tuple should be a literal type if its elements are literal types; it fails because the destructor is not necessarily trivial. It should follow the form of optional and variant, and mandate a trivial destructor if all types in Types... have a trivial destructor. It is not clear if pair has the same issue, as pair specifies data members first and second, and appears to have an implicitly declared and defined destructor.

Suggested resolution:

Document the destructor for tuple, and mandate that it is trivial if each of the elements in the tuple has a trivial destructor. Consider whether the same specification is needed for pair.

[2016-11-09, Jonathan provides wording]

[Issues Telecon 16-Dec-2016]

Move to Review; we think this is right, but are awaiting implementation experience.

Proposed resolution:

This wording is relative to N4606.

  1. Add a new paragraph after 22.3.2 [pairs.pair] p2:

    -2- The defaulted move and copy constructor, respectively, of pair shall be a constexpr function if and only if all required element-wise initializations for copy and move, respectively, would satisfy the requirements for a constexpr function. The destructor of pair shall be a trivial destructor if (is_trivially_destructible_v<T1> && is_trivially_destructible_v<T2>) is true.

  2. Add a new paragraph after the class synopsis in 22.4.4 [tuple.tuple]:

    -?- The destructor of tuple shall be a trivial destructor if (is_trivially_destructible_v<Types> && ...) is true.