|
Boost : |
Subject: Re: [boost] [BOOST CORE C++ Feature] the super or base keyword for C++
From: Max Hölzer (max.hoelzer_at_[hidden])
Date: 2011-05-03 13:21:51
It seems that just writing the name of the base class is far easier than doing
macro stuff.
________________________________
Von: Mathias Gaunard <mathias.gaunard_at_[hidden]>
An: boost_at_[hidden]
Gesendet: Sonntag, den 1. Mai 2011, 19:25:53 Uhr
Betreff: Re: [boost] [BOOST CORE C++ Feature] the super or base keyword for C++
On 01/05/2011 18:38, Marsh Ray wrote:
> On 05/01/2011 12:54 AM, tymofey wrote:
>>
>> >>I was wondering if it makes sense to add the well known super
>> or base keyword to the C++ language in a generic way.
>>
>> C++ has multiple inheritance, while java and C# do not, so super would
>> be ambigous.
>
> class B1 { int i; float f; };
> class B2 { int j; float f; };
>
> class D : B1, B2
> {
> int i, j;
> float f;
>
> void fn()
> {
> ...
> int v = super::i; // refers to B1::i
> int w = super::j; // refers to B2::j
> float x = super::f; // error: ambiguous
> float y = super<B1>::f; // refers to B1::f
> float z = super<B2>::f; // refers to B2::f
> ...
> }
> };
>
> How ugly would the macros have to get to implement something like this
> with the current standards?
You'd have to use SFINAE to tell whether B1::j exists and use B2::j
otherwise.
Should be doable.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk