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

Re: The unobtrusive initialization in C++17

78 views
Skip to first unread message

Victor Bazarov

unread,
Apr 10, 2016, 1:07:48 PM4/10/16
to
On 4/9/2016 10:30 PM, Stefan Ram wrote:
> I wrote:
>
> auto p { ::std::make_pair( 0, 0 ) };
>
> for C++17. But then I remembered that I often saw:
>
> auto p = ::std::make_pair( 0, 0 );
>
> with an »equals« sign.
>
> So is there anything wrong with:
>
> auto p { ::std::make_pair( 0, 0 ) };
>
> ?

There is nothing "wrong" with it. And if some old dog (whom you are
trying to teach this new trick) says that it's unusual or ugly or odd or
..., you'll just need to find an explanation to demonstrate the
*advantage* of using the new syntax over the old one. So start looking
for it.

Keep in mind that changing something for the sake if changing it is *not
constructive*.

V
--
I do not respond to top-posted replies, please don't ask

Daniel

unread,
Apr 10, 2016, 2:11:10 PM4/10/16
to
> On 4/9/2016 10:30 PM, Stefan Ram wrote:
>
> But then I remembered that I often saw:
>
> auto p = ::std::make_pair( 0, 0 );
>
Somehow I doubt if you ever saw that, outside of your own code.

Daniel

Öö Tiib

unread,
Apr 10, 2016, 2:41:50 PM4/10/16
to
It is possible he saw it somewhere. The 'std::pair<int,int> p(0, 0);'
is both less to type and easier to read. The people who love to be
verbose and incomprehensible also like to write a lot and to blog
about it and so it is likely to see their odd writings often
somewhere.

Paavo Helde

unread,
Apr 10, 2016, 4:49:36 PM4/10/16
to
I'm sure Daniel meant the colon noise overdose in ::std, that seems to
be pretty unique to OP.

Cheers
Paavo


Öö Tiib

unread,
Apr 10, 2016, 5:15:41 PM4/10/16
to
Oh. AFAIK also woodbrian is devoted follower of :: before std.
He claims that it protects his middlewriter's code from some sort of
evil and stupid users.

Paavo Helde

unread,
Apr 10, 2016, 5:41:28 PM4/10/16
to
Oh, I see. It seems I should clear my killfile to have better overview
of bad coding style habits. On a second thought, that might not be so
great idea ;-)

Cheers
Paavo

woodb...@gmail.com

unread,
Apr 10, 2016, 11:30:52 PM4/10/16
to
I use ::std to prevent surprises for users. We discussed this
several times now.

Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net

Daniel

unread,
Apr 11, 2016, 12:22:50 AM4/11/16
to
On Sunday, April 10, 2016 at 11:30:52 PM UTC-4, woodb...@gmail.com wrote:
>
> I use ::std to prevent surprises for users.

Interesting point, you might also want to consider using ::god, to avoid other surprises

Daniel

Juha Nieminen

unread,
Apr 11, 2016, 3:14:13 AM4/11/16
to
Victor Bazarov <v.ba...@comcast.invalid> wrote:
> On 4/9/2016 10:30 PM, Stefan Ram wrote:
>> I wrote:
>>
>> auto p { ::std::make_pair( 0, 0 ) };
>>
>> for C++17. But then I remembered that I often saw:
>>
>> auto p = ::std::make_pair( 0, 0 );
>>
>> with an »equals« sign.
>>
>> So is there anything wrong with:
>>
>> auto p { ::std::make_pair( 0, 0 ) };
>>
>> ?
>
> There is nothing "wrong" with it.

Wasn't it so that the = initialization requires for the type to have a
callable copy constructor (even if the compiler never produces the call)?

Thus the two types of initialization are not completely identical.

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Victor Bazarov

unread,
Apr 11, 2016, 8:28:24 AM4/11/16
to
On 4/11/2016 3:14 AM, Juha Nieminen wrote:
> Victor Bazarov <v.ba...@comcast.invalid> wrote:
>> On 4/9/2016 10:30 PM, Stefan Ram wrote:
>>> I wrote:
>>>
>>> auto p { ::std::make_pair( 0, 0 ) };
>>>
>>> for C++17. But then I remembered that I often saw:
>>>
>>> auto p = ::std::make_pair( 0, 0 );
>>>
>>> with an »equals« sign.
>>>
>>> So is there anything wrong with:
>>>
>>> auto p { ::std::make_pair( 0, 0 ) };
>>>
>>> ?
>>
>> There is nothing "wrong" with it.
>
> Wasn't it so that the = initialization requires for the type to have a
> callable copy constructor (even if the compiler never produces the call)?
>
> Thus the two types of initialization are not completely identical.

Yes. Does it make it "wrong"? Or is it so for 'std::pair'?
0 new messages