4040. Contradictory specification of std::tuple_size

Section: 22.4.7 [tuple.helper] Status: New Submitter: Jiang An Opened: 2024-01-20 Last modified: 2024-01-21 06:57:55 UTC

Priority: Not Prioritized

View all other issues in [tuple.helper].

View all issues with New status.


22.4.7 [tuple.helper]/1 currently says:

All specializations of tuple_size meet the Cpp17UnaryTypeTrait requirements (21.3.2 [meta.rqmts]) with a base characteristic of integral_constant<size_t, N> for some N.

which is probably wrong for std::tuple_size<int> and std::tuple_size<std::vector<int>> whose definitions are not provided, and contradicts with 22.4.7 [tuple.helper]/4

[…] Otherwise, it has no member value.

Also, there's currently implementation divergence on whether std::tuple_size<cv T> is a complete type when std::tuple_size<T>::value is absent (related to LWG 2770). Some implementations (e.g. libc++ and libstdc++) treat 22.4.7 [tuple.helper]/4 and D.17 [depr.tuple]/2 as "std::tuple_size<cv T> is generated from partial specializations only if std::tuple_size<T> meets the aforementioned conditions", while others (e.g. MSVC STL) always consider std::tuple_size<cv T> needs to be defined. The latter reading seems to be justified by [contents]/1 and 22.4.2 [tuple.syn].

Proposed resolution: