From: Fernando Cacciola (fcacciola_at_[hidden])
Date: 2002-06-12 15:28:24
----- Original Message -----
From: "Douglas Gregor" <gregod_at_[hidden]>
Sent: Wednesday, June 12, 2002 4:45 PM
Subject: Re: [boost] Proposal --- A type-safe union
> On Wednesday 12 June 2002 03:18 pm, Fernando Cacciola wrote:
> > > The important part is the 'using derived::check', which ties together
> > > the overloads. I don't know how (practically) portable this is: GCC
> > > handles it fine, but GCC 2.95.x does not.
> > >
> > Interesting: I tried it and it didn't work with BCB5. It ICEs right in
> > using declaration.
> What a pain.
> > But, fortunately, it is not required! As long as the inheritance is
> > there is no need to bring each 'check' up-front.
> > It works fine if the 'using' declaration is removed.
> Without the using declaration, the 'check' functions should name-hide the
> check functions from the base class. The example doesn't show the problem
> (because char is convertible to int), but it won't work if another type is
> used (e.g., replace 'char' with 'std::string' and change 'c' to "c").
AFAIK, a using-declaration is useful only when resolving 'conflicting'
Unless I'm too sleepy already, if 'check' is not a virtual function, its
complete signature (argument types including) is what matters here.
In this case, since it is assumed that all the types in the list are
different, each checker sub-class would have its own version of check() with
a different signature than any other check() on the hierarchy. There
shouldn't be any name-hiding to resolve.
I tried with string and it gives an error (cannot convert string to int) as
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk