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

2345. integer_sequence should have a self-typedef ::type

Section: 23.3.2 [intseq.intseq] Status: NAD Submitter: Stephan T. Lavavej Opened: 2013-11-01 Last modified: 2017-02-03

Priority: 2

View all issues with NAD status.


23.15.3 [] says that integral_constant<T, v> provides ::value_type (for T) and ::type (for itself).

23.3.2 [intseq.intseq] says that integer_sequence<T, I...> provides ::value_type (for T), but nothing for itself.

Self-typedefs can be useful when users create chains of derived classes, then want to get the Standard base type. This is especially relevant to integer_sequence, as variadic templates encourage recursive inheritance.

[2014-02-13 Issaquah: Close as NAD]

AJM: My own implementation used a different alias for types representing parameter packs, and specifically did not define type. I tried it both ways, and found bugs more quickly when type was not defined.

Proposed resolution:

This wording is relative to N3797.

  1. Edit 23.3.2 [intseq.intseq] as indicated:

    namespace std {
      template<class T, T... I>
      struct integer_sequence {
        typedef T value_type;
        typedef integer_sequence<T, I...> type;
        static constexpr size_t size() noexcept { return sizeof...(I); }