Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #83987
| From | Manfred <noname@add.invalid> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Virtual base constructor arguments and constructor delegation |
| Date | 2022-05-08 18:56 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <t58soq$eas$1@gioia.aioe.org> (permalink) |
| References | <t55kt8$qn8s$1@gwaiyur.mb-net.net> <t55oga$uou$1@dont-email.me> <t583g2$12vfl$1@gwaiyur.mb-net.net> |
On 5/8/2022 11:45 AM, Marcel Mueller wrote:
> Am 07.05.22 um 14:25 schrieb Alf P. Steinbach:
<snip>
>> While the details you sketch may be impossible the general idea is not
>> impossible.
>>
>> Just the idea you sketched of dummy initialization, but with slightly
>> different details:
>>
>>
>> #include <tuple>
>> using std::ignore;
>>
>> using C_str = const char*;
>>
>> class Interpolation
>> {
>> protected:
>> struct Dummy_init {};
>> Interpolation( Dummy_init ) { throw 666; }
>
> Hmm, this at least prevents accidental default initialization.
> I think the additional classes of your example are not really required
> for this to work. Although I dislike functions that should never be called.
>
>
> I did not need virtual inheritance very often and probably never with a
> non default constructor so far. But since a virtual base can only be
> initialized by the deepest class I expected some syntax to declare
> "incomplete" constructors that can only be used for derived classes.
> Something like
>
> class PolarInterpolation : public virtual Interpolation
> {protected:
> PolarInterpolation() = 0 {}
>
What's wrong with:
class Interpolation
{
protected:
// struct Dummy_init {};
Interpolation( ); // decl only
public:
Interpolation( const int count ) { ignore = count; }
};
and get rid of all
// Interpolation( Dummy_init() )
and replace with:
: Interpolation( )
This wouldn't work if you need to have a Interpolation( ) constructor
that needs to be legitimately called somewhere else, however the obvious
idea is to use a constructor that is declared but not defined.
>
> Marcel
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Virtual base constructor arguments and constructor delegation Marcel Mueller <news.5.maazl@spamgourmet.org> - 2022-05-07 13:24 +0200
Re: Virtual base constructor arguments and constructor delegation "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-05-07 14:25 +0200
Re: Virtual base constructor arguments and constructor delegation Marcel Mueller <news.5.maazl@spamgourmet.org> - 2022-05-08 11:45 +0200
Re: Virtual base constructor arguments and constructor delegation Manfred <noname@add.invalid> - 2022-05-08 18:56 +0200
Re: Virtual base constructor arguments and constructor delegation "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2022-05-09 00:18 +0200
Re: Virtual base constructor arguments and constructor delegation Manfred <noname@add.invalid> - 2022-05-09 14:56 +0200
Re: Virtual base constructor arguments and constructor delegation Sam <sam@email-scan.com> - 2022-05-08 09:34 -0400
csiph-web