Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #70338

Re: issues with std::variant

From Manfred <noname@add.invalid>
Newsgroups comp.lang.c++
Subject Re: issues with std::variant
Date 2019-12-07 18:17 +0100
Organization Aioe.org NNTP Server
Message-ID <qsgmrm$v4a$1@gioia.aioe.org> (permalink)
References (12 earlier) <5564a179-764c-4a4a-b198-9edafbdd0478@googlegroups.com> <49ea7ae6-dbf4-4e28-9999-c3b55cfcde79@googlegroups.com> <80fc26b8-6d33-4b32-b181-16877b6f8673@googlegroups.com> <3c8fb318-d406-43a1-864a-ed18d2d05272@googlegroups.com> <845cc1d7-3a6e-40fc-959c-7e987fee8d8f@googlegroups.com>

Show all headers | View raw


On 12/7/2019 1:43 PM, Öö Tiib wrote:
> On Friday, 6 December 2019 19:44:14 UTC+2, Taylor  wrote:
>> On Thursday, December 5, 2019 at 3:41:38 PM UTC-8, Öö Tiib wrote:
>>>
>>> Scrolled a bit into that video. First he pushed
>>> rawly newed pointer to document then said that it is wrong and used
>>> the most dork tool std::make_shared! I stopped right there.
>>
>> You should continue watching. He's just using shared_ptr in his example.
> 
> Huh? Each shared_ptr usage is dynamic allocation of sole object plus
> complicating your data from tree to directed acyclic or may be even
> introducing directed cycles into your data. Additionally it is rather
> expensive (in both performance and storage usage) smart pointer.
The point about shared_ptr in the video is that the speaker starts 
presenting a use of shared_ptr, then he shows how bad it is and replaces 
it for a while with unique_ptr. However, in the end he resumes the use 
of shared_ptr, but only as pointer to const, as a mean to reduce copies. 
So it is less stupid than you posed it.

That said, I don't like shared_ptr either.

  It
> has usages but rare or else you turn your program into as error prone
> and inefficient mess as typical Java or C# programs are.
Totally agree on this.

> So video where you are casting it into code without apparently no
> thought applied is not worth watching. It proves that you are either
> snake oil salesman or noob.
> 
>> A production implementation would use a small-object optimization. In fact, central to his type erasure scheme is reducing the amount of dynamic allocation.
> 
> Blah blah blah blah? If something can't be written as document then
> it is *never* worth watching as video either. I have already posted link
> to document and open source implementation of one way how to reduce
> dynamic allocations:
> <https://www.boost.org/doc/libs/1_71_0/doc/html/poly_collection.html>
> C++ is powerful so there are several other ways and each can be
> used and discussed in separation or in combination.
> 

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

issues with std::variant wtholliday@gmail.com - 2019-12-04 08:37 -0800
  Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-04 10:26 -0800
    Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-04 11:07 -0800
      Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-04 12:31 -0800
        Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-04 13:09 -0800
          Re: issues with std::variant "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-04 22:39 +0100
            Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-04 16:18 -0800
              Re: issues with std::variant "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-05 05:13 +0100
                Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-05 09:59 -0800
                Re: issues with std::variant Christian Gollwitzer <auriocus@gmx.de> - 2019-12-06 09:39 +0100
                Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-06 09:12 -0800
          Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-04 14:46 -0800
            Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-04 16:28 -0800
              Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-05 00:00 -0800
                Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-05 00:48 -0800
                Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-05 08:17 -0800
                Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-05 09:44 -0800
                Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-05 11:14 -0800
                Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-05 12:37 -0800
                Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-05 13:20 -0800
                Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-05 13:42 -0800
                Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-05 15:41 -0800
                Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-06 09:44 -0800
                Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-07 04:43 -0800
                Re: issues with std::variant Manfred <noname@add.invalid> - 2019-12-07 18:17 +0100
                Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-07 11:45 -0800
                Re: issues with std::variant Christian Gollwitzer <auriocus@gmx.de> - 2019-12-06 09:58 +0100
                Re: issues with std::variant Öö Tiib <ootiib@hot.ee> - 2019-12-06 06:06 -0800
  Re: issues with std::variant David Brown <david.brown@hesbynett.no> - 2019-12-04 22:34 +0100
    Re: issues with std::variant Vir Campestris <vir.campestris@invalid.invalid> - 2019-12-05 15:07 +0000
      Re: issues with std::variant Taylor <wtholliday@gmail.com> - 2019-12-05 10:01 -0800
      Re: issues with std::variant David Brown <david.brown@hesbynett.no> - 2019-12-05 22:15 +0100

csiph-web