|
Boost : |
From: Daryle Walker (darylew_at_[hidden])
Date: 2004-01-26 15:12:04
On 1/24/04 8:19 PM, "Jonathan Turkanis" <technews_at_[hidden]> wrote:
> "Daryle Walker" <darylew_at_[hidden]> wrote in message
> news:BC3875FB.576B%darylew_at_hotmail.com...
>> On 1/21/04 5:25 PM, "Howard Hinnant" <hinnant_at_[hidden]> wrote:
>>
>> [SNIP]
>>> With move_ptr<T[]> you (or at least I) immediately think: Ok, a smart
>>> pointer to an array.
>> [TRUNCATE]
>>
>> I forgot; will "T[]" resolve to an array type? In function parameters, it
>> reduces to "T*", which is something unsuitable here if the same thing
>> happens.
> Are you thinking of something like this:
>
> template<typename T>
> void f(T t)
> {
> BOOST_STATIC_ASSERT((boost::is_same<T, int* >::value));
> }
>
> int main()
> {
> int a[100];
> f(a);
> }
>
> ?
No, I'm not.
> Here 'a' is converted to int* before template argument deduction, so T
> is deduced to be int*. This applies only to function templates, and
> doesn't happen at all if the template argument is explicitly
> specified.
I meant the template and function resolutions of "T[]" to be separate and
parallel analogies, not merged together. For functions:
whatever function1( T[] t );
whatever function2( T* t );
these are considered the same. What about:
template < typename U > class my_template;
//...
template < typename T > class my_template<T[]> { /*...*/ };
template < typename T > class my_template<T*> { /*...*/ };
Are those last two entries considered the same? If so, then we can't use
this technique.
-- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk