|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-03-17 13:22:40
I can understand why the behavior would be useful for references, but I
still can't understand it for arrays. A pointer-to-an-array is a
well-defined concept, but maybe there's something I'm missing here:
template <class T>
struct holder
{
typedef T type;
T held;
};
template <class T>
std::type_info const& f(T const& x)
{
typename add_pointer<typename T::type>::type held_ptr p = &x.held;
return typeid(*p);
}
std::type_info id = f(holder<int[10]>());
So, does this program compile? If so, what does id contain? typeid(int)?
typeid(int[10])? Something else?
-Dave
----- Original Message -----
From: "John Maddock" <John_Maddock_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, March 17, 2002 7:32 AM
Subject: Re: [boost] type_traits: add_pointer behavior?
> > On conforming compilers, add_pointer<int&> is int*.
> >
> > I'm not sure that's desirable (perhaps int& would be better).
> >
> > Also, add_pointer<int[5]> is int* rather than int(*)[5] on
conforming
> > compilers.
> >
> > I /really/ can't understand why you'd want to throw out the array
part.
> > It seems to me that any type_traits metafunction called "add_xxx"
> > shouldn't strip any features of its argument.
> >
> > Thoughts?
>
> The aim is that add_pointer<T>::type is the same as the type of &t, if
t is
> an instance of T.
>
> John Maddock
> http://ourworld.compuserve.com/homepages/john_maddock/index.htm
>
>
> Info: http://www.boost.org Send unsubscribe requests to:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk