Boost logo

Boost :

Subject: Re: [boost] [BOOST CORE C++ Feature] the super or base keyword for C++
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-05-02 18:15:20


> Message du 03/05/11 00:00
> De : "Thorsten Ottosen"
> A : boost_at_[hidden]
> Copie à :
> Objet : Re: [boost] [BOOST CORE C++ Feature] the super or base keyword for C++
>
> Den 02-05-2011 23:20, Vicente BOTET skrev:
> >
> >
> >
> >> Message du 02/05/11 22:50 De : "Thorsten Ottosen" A :
> >> boost_at_[hidden] Copie à : Objet : Re: [boost] [BOOST CORE C++
> >> Feature] the super or base keyword for C++
> >>
> >> Den 01-05-2011 07:54, tymofey skrev:
> >>>
> >>>>> 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.
> >>>
> >>
> >> Please see
> >>
> >> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2881.html
> >
> >
> > It will be great if this technique could be used to emulate single
> > inheritance base class aliases, so instead of duplicating the base
> > type
>
> > The single remaining problem is the forward constructor.
> >
> [snip]
> > We could add a macro that generates base like classes with specific
> > names and have
> >
> >
> > template class bitset : PRIVATE_BASE_ALIAS(_Base, (_Base_bitset <
> > ((_Nb)< 1 ? 0 : ((_Nb) + numeric_limits::digits - 1) /
> > numeric_limits::digits)
> >>
> > )) { // private_base introduce _Base type in scope here };
> >
> > Of course macros are ugly and needs to double braquets.
>
> Can you elaborate more on what you mean?

Sorry. I realized that we need yet another macro to declare the specific template class which make it much less attractive.

If we have just a base class template private_base, protected_base and public_base seems to avoid the duplication.

template
class public_base : public T
{
public:
typedef public_base base_type;
using T::T;
};

--
Vicente

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk