$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-01-31 06:32:51
On Thu, 30 Jan 2003 20:29:18 +0100, Terje Slettebø
<tslettebo_at_[hidden]> wrote:
>You don't need expressions (if by that you mean an object of the type to
>test, or pointer/reference to it) to check for convertibility, as it may be
>done with sizeof, so no object of any kind need to be created. However, you
>may need an object, or pointer/reference to it, to use function templates.
>Also, that won't make it a compile-time expression, so why use function
>templates for this?
The issue is not about creating objects or not but about what does it
mean for "a type" to be convertible to another. Personally I have no
idea what the meaning can be. Instead, the standard specifies what it
means for an "expression" to be implicitly convertible to another:
4/3: An expression e can be implicitly converted to a type T
if and only if the declaration ``T t=e;'' is wellformed,
for some invented temporary variable t (8.5).
[Incidentally: this is one of the few places in which the standard
uses "if and only if" where "if and only if" is intended; in other
places it just uses "if" :-( ]
I brought up this problem in reply to the initial post of the thread
"is_convertible corner case" thinking, however, that the documentation
of boost::is_convertible clarified that (the type_traits library is
one of the library I almost know nothing about). It turned out,
instead, that not only the documentation doesn't, but the ISO proposal
doesn't either. This one, together with the access-checking problem:
class X {
operator int(); // private
friend class Y;
};
class Y {
void f() {
is_convertible<X, int>::value; // true or false??
// or error?
}
};
are the two main issues. You can find more details in the above
mentioned thread.
Genny.