
Boost : 
From: Bronek Kozicki (brok_at_[hidden])
Date: 20060618 07:49:00
Janek Kozicki wrote:
>> BTW, this is where I'd really like to see templatized
>> typedefs in C++, allowing us to define:
>>
>> template< int N, type T >
>> typedef vector< N, T, false > fixed_vector;
>>
>> template< int N, type T >
>> typedef vector< N, T, true > resizable_vector;
>>
>> Thus we'd have:
>>
>> fixed_vector<N,T>
>> resizable_vector<N,T>
>>
>> while using the common vector template defined above.
>
>
> uh, wait. It's not possible currently? I'm not 100% sure but I think
> that I was using similar code some time in the past...
I think not. You probably meant feature described in
http://www.openstd.org/jtc1/sc22/wg21/docs/papers/2003/n1489.pdf , but it's
not in the C++0x draft, yet. There is simple way to emulate this,
unfortunatelly with different semantics that would make metaprograms much more
difficult to write:
template< int N, type T >
struct resizable_vector : vector< N, T, true > {};
The difficulty comes from the fact that:
some_useful_template<vector<10, int, true> >
and:
some_useful_template<resizable_vector<10, int> >
are two distinct types
B.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk