stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek" <>
Subject RE: [VOTE] naming convention for variadic template arguments (was: Re: svn commit: r668318 - in /stdcxx/branches/4.3.x: include/rw/_tuple.h include/rw/_tuple_traits.h include/tuple tests/utilities/20.tuple.cnstr.cpp)
Date Sat, 28 Jun 2008 05:53:18 GMT

>Eric Lemings wrote:
>> Martin Sebor 
>> This thread kind of fizzled out so let me resurrect it and reiterate
>> the proposed naming convention to follow unless more specific names
>> are appropriate:
>>      template <class _TypeT, class... _Types>     # 1
>> This is in contrast to other styles, including:
>>      template <class _Type, class... _Types>      # 2
>>      template <class _HeadT, class... _TailT>     # 3
>>      template <class _TType, class... _UTypes>    # 4
>> The rationale for the proposed convention (#1) is that:
>>    A) unlike the alternatives, the first name (_TypeT) follows
>>       a well-established and entrenched convention for template
>>       parameters used throughout the library
>>    B) also unlike the alternatives, it is being used in the
>>       implementation of <type_traits>
>>    C) unlike (#2) (although not as well as #3) it more clearly
>>       distinguishes between the name of the first parameter and
>>       the parameter pack


>In this case, it depends on whether the two parameters are actually part
>of the same type list.  If _TypesT and _Types are actually part of the
>same type list then they should be named either _TypeT and _TypesT
>respectively (or _Type and _Types as shown in #2).  If they are not part
>of the same type list, then they should be named _TypeT and _TypesU
>(similar to #4).
>In any case, a plural name should implicitly denote a template parameter
>pack (which actually should rule out #3 even though I've already been
>using it).  :P

I'm with Brad

> Check the box below to vote:
>    [ ] In favor
>    [x] Opposed (suggest an improvement and rationale)

I think the names really depend on the intent and where it is being used. If you have a parameter
pack that is essentially a single typelist, like so...

  template <class... _TTypes> struct S;

I'd expect the first template parameter and the parameter pack to have similar names. The
above will likely break down to the following recursive template declaration...

  template <class _TypeT> struct S;
  template <class _TypeT, class... _TTypes> struct S;

If, on the other hand, the first argument stands alone and the parameter pack is a typelist,
then I'd expect something more like the following...

  template <class _TypeT, class... _UTypes>  struct S;

  template <class _TypeT, class _TypeU> struct S;
  template <class _TypeT, class _TypeU, class... _UTypes> struct S;


  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message