Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-12-31 20:46:33


Aleksey Gurtovoy <agurtovoy_at_[hidden]> writes:

> David Abrahams wrote:
>> Lastly, I know that Aleksey will argue with me about this,
>
> Yep, I will :).
>
>> but I have a strong preference for "class" rather than "typename" in
> template
>> parameter lists. Aside from the fact that it's longer, "typename" is
>> visually confusable because it can mean other multiple things when it
>> appears between <...>:
>>
>> template <typename T, typename U = typename metafunction<T>::type>
>>
>> vs
>>
>> template <class T, class U = typename metafunction<T>::type>
>
> IMO it's more a problem with the layout of template parameters than with
> anything else:
>
> template<
> typename T
> , typename U = typename metafunction<T>::type
> >
> class her;

That doesn't do anything to reduce the confusability of the 'typename'
keyword for me, especially not in Jaap's example:

       template<
           typename T
         , typename T::X N
>
       class foo;

> In short, my motivation for using 'typename's here is that I perceive the
> 'class' keyword as rather high-weight, semantically loaded, and prefer to
> use it in its only original context - that is, for declaring/defining a
> user-defined type that is more than a POD. Using it in other places cheapens
> the word.

As I said (and no offense is intended) these seem to be pedantic
rather than practical reasons. I suppose you could say "aesthetic"
instead of "pedantic", but the practical consequences of those choices
outweigh the aesthetic ones for me, especially because in a
metaprogramming context we will commonly use "struct" instead of
"class"... once again because the practical consequences outweigh the
aesthetic ones ;-)

-Dave

-- 
                       David Abrahams
   dave_at_[hidden] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk