Boost logo

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?


----- 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
> > compilers.
> >
> > I /really/ can't understand why you'd want to throw out the array
> > 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
> Info: Send unsubscribe requests to:
> Your use of Yahoo! Groups is subject to

Boost list run by bdawes at, gregod at, cpdaniel at, john at