|
Boost : |
From: scleary_at_[hidden]
Date: 2000-10-16 07:36:15
> 1) I see nothing in sections 3.9.2 and 3.9.3 that make this sensible. The
> closest I can find is the bit at the start of 3.9.3 that says that the
> cv-qualified and cv-unqualified versions of a type are distinct types.
> So, char* and char* const are distinct types, but they're still both
> pointers.
char * is a pointer.
char * const is a cv-qualified pointer.
[3.9.2/1] gives the definition of a "pointer" as a compound type.
[3.9.3/1] first sentence says "A type mentioned in 3.9.1 and 3.9.2 is a
cv-unqualified type."
To check for a pointer type, use is_pointer<T>. To check for a possibly
cv-qualified pointer type, use is_pointer<remove_cv<T>::type>.
> 2) I expect that many people will be surprised to find that is_pointer
> returns false for const pointers. So, it's important that this be well
> documented (see below). It also wouldn't hurt to include a comment in the
> code.
This was discussed at length for is_integral<const int>. Yes, many people
will be surprised, but we decided to just stick to the "letter of the
Standard", which says that int is an integral, arithmetic, and scalar type,
but const int is just a scalar type.
> >BTW the docs
> >make it clear that is_pointer applies to cv-unqualified types,
>
> Where? The type_traits.htm file merely says "True if T is a regular
> pointer type - including function pointers - but excluding pointers to
> member functions (3.9.2 p1 and 8.3.1)."
You're right! I could've sworn it was in there, along with the other
surprising ones (is_integral/is_float). We need to update the docs.
-Steve
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk