|
Boost Users : |
From: Tim Robertson (timr_at_[hidden])
Date: 2006-09-06 21:03:36
On Sep 6, 2006, at 4:15 PM, David Abrahams wrote:
> The problem is that is_convertible<Foo,Foo>::value is not yet known,
> and (aside from the fact that there's an implicitly generated copy
> ctor that's a perfect match which the compiler seems to ignore at this
> stage, of course)
Consistently so, for both g++3.x and g++4.x.
(Am I missing something, or is this not sufficiently weird to register
as a problem?)
> without that ::value the compiler can't decide
> whether either of those constructors is a match for a Foo argument.
> In fact, we're only checking for that match because we want to know
> that very ::value!
Got it. The compiler can't instantiate is_convertible<Foo,Foo> if the
constructor(s) that enable the conversion (from Foo to Foo) themselves
have signatures that depend on is_convertible<Foo,Foo>.
>> Right. So again, it seems as though it isn't possible to do what I'm
>> trying to do.
>
> Sure it is. You could use
>
> enable_if< mpl::or_<is_same<T,Foo>, is_convertible<T,Foo> >, ... >
>
> Type sameness can be determined without looking at constructors or
> even knowing anything about the definition of the type.
I see...skip the is_convertible<> check when the types are actually the
same, thus avoiding the instantiation of is_convertible<Foo,Foo>. This
might work for my real problem. I'll give it a shot.
Thanks,
Tim
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net