Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Converting constructors

23 views
Skip to first unread message

Bonita Montero

unread,
Nov 25, 2016, 5:31:47 AM11/25/16
to
Am 25.11.2016 um 11:09 schrieb Stefan Ram:
> - one argument
> but
> - no "explicit".

It is one arguemnt *and* no explicit.

--
http://facebook.com/bonita.montero/

Alf P. Steinbach

unread,
Nov 25, 2016, 11:17:35 AM11/25/16
to
On 25.11.2016 11:09, Stefan Ram wrote:
> IIRC, the C++ primer says that a converting constructor is a
> constructor that accepts exactly one argument. It says that
> constructors with more arguments can not possibly be considered
> for conversions, because a conversion situation only is given
> in the case of a single value.
>
> However, we all know 12.3.1p1 (now not from the primer,
> but from a recent draft of the standard):
>
> »A constructor declared without the function-specifier
> explicit specifies a conversion from the types of its
> parameters (if any) to the type of its class. Such a
> constructor is called a converting constructor.« .
>
> So, today's definition of »converting constructor« is not
>
> - one argument
>
> but
>
> - no "explicit".
>
> But after the C++ primer has so convincingly explained why a
> converting constructor is a constructor that accepts a single
> argument, why has the standard dropped this requirement?
>

[code]
struct A
{
A( int, int ) {}
};

struct B
{
explicit B( int, int ) {}
};

auto main() -> int
{
A a = {1, 2};
B b = {1, 2}; //! Nyet, constructor is explicit.
}
[/code]


Cheers & hth.,

- Alf

Alf P. Steinbach

unread,
Nov 25, 2016, 11:19:40 AM11/25/16
to
But regarding the practical utility I have no idea.

I think it's just some committee member's wet dream, to be able to
answer questions like this.

Possibly.


Cheers!,

- Alf


Bonita Montero

unread,
Nov 25, 2016, 12:06:39 PM11/25/16
to
Am 25.11.2016 um 17:14 schrieb Alf P. Steinbach:

> B b = {1, 2}; //! Nyet, constructor is explicit.

This is not converting operation.

--
http://facebook.com/bonita.montero/

Alf P. Steinbach

unread,
Nov 25, 2016, 12:09:05 PM11/25/16
to
On 25.11.2016 18:06, Bonita Montero wrote:
> Am 25.11.2016 um 17:14 schrieb Alf P. Steinbach:
>
>> B b = {1, 2}; //! Nyet, constructor is explicit.
>
> This is not converting operation.

Well, you're entitled to your opinion about what labels fit, but I for
one am not very interested in that.

So, I suggest you refrain from entirely meaningless commentary, a.k.a.
babble, in this group, unless it concerns swearing or sausages.

Thank you.


Cheers!

- Alf

Bonita Montero

unread,
Nov 25, 2016, 12:20:36 PM11/25/16
to
Am 25.11.2016 um 18:06 schrieb Alf P. Steinbach:
>>> B b = {1, 2}; //! Nyet, constructor is explicit.

>> This is not converting operation.

> ... refrain from entirely meaningless commentary, ...

This is not meaningless.
The code you show doesn't show any comversion.

--
http://facebook.com/bonita.montero/

Alf P. Steinbach

unread,
Nov 25, 2016, 12:30:50 PM11/25/16
to
On 25.11.2016 18:20, Bonita Montero wrote:
> Am 25.11.2016 um 18:06 schrieb Alf P. Steinbach:
>>>> B b = {1, 2}; //! Nyet, constructor is explicit.
>
>>> This is not converting operation.
>
>> ... refrain from entirely meaningless commentary, ...
>
> This is not meaningless.
> The code you show doesn't show any comversion.

Apart from your opinion about labels, which I'll not contest (any person
is free to choose his or her own terminology, no matter how impractical
it may be, no matter how undefined or meaningless),

do you think it's relevant to the OP's question that the `explicit`
constructor prevents that line from compiling?


Cheers!,

- Alf

Bonita Montero

unread,
Nov 25, 2016, 12:34:14 PM11/25/16
to
Am 25.11.2016 um 18:27 schrieb Alf P. Steinbach:

> do you think it's relevant to the OP's question that the
> `explicit` constructor prevents that line from compiling?

The code you postet is absoltuely useless for the question
Stefan Ram asked because it doesn't show any conversion
-operation.


--
http://facebook.com/bonita.montero/

Alf P. Steinbach

unread,
Nov 25, 2016, 2:13:36 PM11/25/16
to
On 25.11.2016 18:34, Bonita Montero wrote:
> Am 25.11.2016 um 18:27 schrieb Alf P. Steinbach:
>
>> do you think it's relevant to the OP's question that the
>> `explicit` constructor prevents that line from compiling?
>
> The code you postet is absoltuely useless for the question
> Stefan Ram asked because it doesn't show any conversion
> -operation.

Well, that's just idiocy.

- Alf


Bonita Montero

unread,
Nov 25, 2016, 2:28:36 PM11/25/16
to
Am 25.11.2016 um 20:10 schrieb Alf P. Steinbach:

>> The code you postet is absoltuely useless for the question
>> Stefan Ram asked because it doesn't show any conversion
>> -operation.

> Well, that's just idiocy.

Stefan asked why the standad doesn't make a clear statement about
what a converting constructor is except specifying that it might
not be explicit. For that question you don't give any clarification
with your code because it doesn't show any conversion.

--
http://facebook.com/bonita.montero/

Alf P. Steinbach

unread,
Nov 25, 2016, 2:39:21 PM11/25/16
to
Repeating the idiocy doesn't make it meaningful.

Cheers!,

- Alf

Bonita Montero

unread,
Nov 25, 2016, 2:53:41 PM11/25/16
to
Am 25.11.2016 um 20:36 schrieb Alf P. Steinbach:
>> Stefan asked why the standad doesn't make a clear statement about
>> what a converting constructor is except specifying that it might
>> not be explicit. For that question you don't give any clarification
>> with your code because it doesn't show any conversion.

> Repeating the idiocy doesn't make it meaningful.

My objection isn't idiocy, but yours. Because the code you supplied
doesn't clarify the question Stefan asked for. It simply has nothing
to do with the question.

--
http://facebook.com/bonita.montero/

Alf P. Steinbach

unread,
Nov 25, 2016, 3:26:19 PM11/25/16
to
It seems that by repeating these meaningless assertions, this technical
idiocy, you're trolling, waiting for someone else to join in and then
accept their explanation as if I hadn't been clear enough.

In the posting I'm replying you changed newsgroups to
`de.alt.gruppenkasper`, and that's also typical trolling behavior.

Plonk.

Or if you don't get that, please do fuck off.


- Alf

Louis Krupp

unread,
Nov 25, 2016, 3:30:06 PM11/25/16
to
On 25 Nov 2016 10:09:48 GMT, r...@zedat.fu-berlin.de (Stefan Ram)
wrote:

> IIRC, the C++ primer says that a converting constructor is a
> constructor that accepts exactly one argument. It says that
> constructors with more arguments can not possibly be considered
> for conversions, because a conversion situation only is given
> in the case of a single value.
>
> However, we all know 12.3.1p1 (now not from the primer,
> but from a recent draft of the standard):
>
> »A constructor declared without the function-specifier
> explicit specifies a conversion from the types of its
> parameters (if any) to the type of its class. Such a
> constructor is called a converting constructor.« .
>
> So, today's definition of »converting constructor« is not
>
> - one argument
>
> but
>
> - no "explicit".
>
> But after the C++ primer has so convincingly explained why a
> converting constructor is a constructor that accepts a single
> argument, why has the standard dropped this requirement?

According to this page, the single-argument requirement went away with
C++11:

http://en.cppreference.com/w/cpp/language/converting_constructor

Louis

Alf P. Steinbach

unread,
Nov 25, 2016, 3:35:22 PM11/25/16
to
Stefan is aware of that and explained that as you've quoted above. He
asked why, literally, as the last you quoted, "why has the standard
dropped this [single argument] requirement". I.e. what impact does it have.

As far as I know the only impact is for copy initialization syntax with
curly braces initializer, as I've already exemplified.

Mr Flibble

unread,
Nov 25, 2016, 3:40:07 PM11/25/16
to
Mate, you are making a tit of yourself. Alf is correct: the conversion
is from an initializer list.

/Flibble


Bonita Montero

unread,
Nov 25, 2016, 3:50:45 PM11/25/16
to
Am 25.11.2016 um 21:39 schrieb Mr Flibble:

> Mate, you are making a tit of yourself.
> Alf is correct: the conversion is from an initializer list.

Construction via initializer-list isnt a conversion.

--
http://facebook.com/bonita.montero/

Bonita Montero

unread,
Nov 25, 2016, 3:58:51 PM11/25/16
to
Am 25.11.2016 um 21:50 schrieb Bonita Montero:

> Construction via initializer-list isnt a conversion.

Or to be more pecise: conversion is when there is a new object generated
through a constructor or a type-conversion operator from from another
object. That's not the case with Alf's code. There isnt a second object.


--
http://facebook.com/bonita.montero/

Mr Flibble

unread,
Nov 25, 2016, 3:58:55 PM11/25/16
to
On 25/11/2016 20:50, Bonita Montero wrote:
> Am 25.11.2016 um 21:39 schrieb Mr Flibble:
>
>> Mate, you are making a tit of yourself.
>> Alf is correct: the conversion is from an initializer list.
>
> Construction via initializer-list isnt a conversion.

Yes, in this case it is.

/Flibble


Mr Flibble

unread,
Nov 25, 2016, 4:00:26 PM11/25/16
to
On 25/11/2016 20:58, Bonita Montero wrote:
> Am 25.11.2016 um 21:50 schrieb Bonita Montero:
>
>> Construction via initializer-list isnt a conversion.
>
> Or to be more pecise: conversion is when there is a new object generated
> through a constructor or a type-conversion operator from from another
> object. That's not the case with Alf's code. There isnt a second object.

Mate, have you ever heard the phrase "digging yourself into a hole"?

/Flibble


0 new messages