|
Boost : |
From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-01-21 11:18:23
On Mon, 20 Jan 2003 15:04:30 -0800, "Eric Niebler" <neric_at_[hidden]>
wrote:
>It seems to me that the current implementation of is_convertible will
>conclude that int* is convertible to int[10]. That's because when a
>function parameter is of array type, it is treated just like a pointer. But
>according to 4/3 of the standard:
>
>"An expression e can be _implicitly converted_ to a type T if an only if the
>declaration "T t=e;" is well-formed for some invented variable t (8.5)."
>
>By this definition, int* is not implicitly convertible to int[10]. So it
>seems is_convertible is broken in this regard. IMO, is_convertible<A,B>
>should always return false when B is an array type.
I don't want to be involved in another war here, also because I'm
totally ignorant about boost's implementation of is_convertible and
because I don't know what is its purpose (i.e.: I haven't read the
documentation and I can just have an idea from its name). I want
simply to point out that saying a type is or isn't convertible to
another has a very vague meaning. Note that the definition you quote
from the standard concerns conversion of an *expression*, not of a
type. Also it just concerns *implicit* conversion. So, off the top of
my head, "is convertible" means nothing to me (though I can imagine
how it is implemented). NOTE: I'm not saying there's an error in
boost. It's likely that the documentation explains what its meaning
is, but I don't have time to check now. Note anyway that e.g. (1-1) is
an expression of type int and that it is implicitly convertible to
void*, to void (*) int, or to char (A::*)(int) but I doubt that
is_convertible would yield true on the corresponding types. The exact
meaning of is_convertible is likely to be understood only if you look
at the implementation I think, unless there's a very good, and
technical, explanation in the docs.
Genny.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk