Title
integer_sequence should have a self-typedef ::type
Status
nad
Section
[intseq.intseq]
Submitter
Stephan T. Lavavej

Created on 2013-11-01.00:00:00 last changed 132 months ago

Messages

Date: 2014-02-14.07:07:05

Proposed resolution:

This wording is relative to N3797.

  1. Edit [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); }
      };
    }
    
Date: 2014-02-13.00:00:00

[ 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.

Date: 2013-11-01.00:00:00

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

[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.

History
Date User Action Args
2014-02-14 07:07:05adminsetmessages: + msg6857
2014-02-14 07:07:05adminsetstatus: new -> nad
2014-01-12 13:15:54adminsetmessages: + msg6776
2013-11-01 00:00:00admincreate