26

Re: shared_ptr Against all

Hello, Masterspline, you wrote: _NN>> Help with examples with what case ubiquitous usage shared_ptr will be to the detriment? M> all is good moderately. To all the place and time. shared_ptr it is necessary to use, there, where it approaches, instead of is ubiquitous. The question is set somehow is more common. The reality is necessary. What task dares? The task in convincing people not to use shared_ptr anywhere. The good argumentation for this purpose is necessary to me.

27

Re: shared_ptr Against all

Hello, uzhas, you wrote: U> circular references are a main trouble. Cut cycles with the help weak_ptr or crude not owning pointers, but it is the most difficult to find cycles, rather than them to tear. Sometimes after implementation weak_ptr there is a problem "object too early died, anybody does not hold it" U> often there are bookmarks on the order of destruction of objects, here shared_ptr will hinder is a second trouble more likely. Sometimes it would be desirable to make reset and to be assured that here  and fulfills. Sometimes saw through methods Stop (), Close () in objects for these purposes, but to trace usage of object after Close () heavily, here so appear difficultly caught bugs reset which not  works, it yes can be a problem. It is applicable not only to shared_ptr, the same unique_ptr.reset releases object, and the code easily can use it then. U> sometimes in deleter push objects which upon do not delete object. It too can lead to problems since there is a misunderstanding as the code works (deleter hides because of type erasure) There also  is. If it is a real problem it is possible to get the shared_ptr_with_deleter <T, D>

28

Re: shared_ptr Against all

29

Re: shared_ptr Against all

Hello, Qbit86, you wrote: Q> In comparison with shared_ptr, usage unique_ptr in signatures gives some warranties (how much "warranties" generally it is applicable concerning a C ++). Though any  it is better, than any. At least for code perception. Here we are met by counter argument that it is easier to explain and use for beginners.

30

Re: shared_ptr Against all

Hello, _NN _, you wrote: _NN> the Task in convincing people not to use shared_ptr anywhere. _NN> the good argumentation for this purpose is necessary to me. I think, the main thing that should constrain from usage shared_ptr - not the problems which have arisen immediately at its usage, and problems which arise then, during time reverse-inzhinrirnga of the code with shared_ptr. Try to understand then after months, whether it is used shared_ptr really for divided possession, or not who under what circumstances whom owns, where what semantics at deleter and so on. On the other hand, in languages with garbage collection without this all knowledge of semantics of possession somehow live. Well and why performance not argument. Normal  the counter of links it is not simple i ++, atomic operations are rather expensive. And in shared_ptr now not so simply atomic counter, and at all two atomic counters, and two counters under . Here in such code, turn out, four atomic operations on iteration: vector <shared_ptr <T>> v; for (auto p: v) {p-> Do ();}

31

Re: shared_ptr Against all

Hello, Ops, you wrote: Ops> Hello, XuMuK, you wrote: XMK>> not to supervise object lifetime manually, for example here: http://www.boost.org/doc/libs/1_53_0/do … server.cpp (sm chat_session) - while it will be live connection to live and the output agent (copies shared_ptr in ). Naturally nobody does  , but  a copy shared_ptr in any functor and to forget it to clean completely not difficult. Ops> instead of it is necessary in such cases  shared, for this purpose is weak. weak it is impossible to use together with boost:: bind, unlike shared.

32

Re: shared_ptr Against all

Hello, _NN _, you wrote: _NN> the Task in convincing people not to use shared_ptr anywhere. Mission is impracticable. Usage shared_ptr anywhere - a question of level of designing. The problem that the people do not want to reflect on lifetime, possession and control of storage BEFORE the program starts to be fulfilled and hopes for "automatic" resolution of these questions. I for myself solved so - I use shared_ptr only when I cannot really predict object lifetime before the program started to be fulfilled. In its all remaining cases simply not to use. No listing of problems shared_ptr rescues . The beginner also forgets about half enumerated in this branch, if to it about it  as itself on this rake did not come.

33

Re: shared_ptr Against all

Hello, XuMuK, you wrote: XMK> weak it is impossible to use together with boost:: bind, unlike shared. Unless? I already forgot. And what for it is now necessary ?

34

Re: shared_ptr Against all

Hello, andyp, you wrote: A> Hello, _NN _, you wrote: _NN>> the Task in convincing people not to use shared_ptr anywhere. A> mission is impracticable. Usage shared_ptr anywhere - a question of level of designing. The problem that the people do not want to reflect on lifetime, possession and control of storage BEFORE the program starts to be fulfilled and hopes for "automatic" resolution of these questions. Something something like that. A> I for myself solved so - I use shared_ptr only when I cannot really predict object lifetime before the program started to be fulfilled. In its all remaining cases simply not to use. A> no listing of problems shared_ptr rescues . The beginner also forgets about half enumerated in this branch, if to it about it  as itself on this rake did not come. On the other hand to explain possession, lifetime, dependence in between the hard task and there is even easier to be mistaken.

35

Re: shared_ptr Against all

Hello, Ops, you wrote: Ops> And what for it is now necessary ? As before, to do the typified functors

36

Re: shared_ptr Against all

Hello, XuMuK, you wrote: XMK> As before to do the typified functors And than lambdas do not arrange?

37

Re: shared_ptr Against all

Hello, _NN _, you wrote: _NN> we Suppose and with storage there are no problems. The Problem with storage suffices all begin while someone says that "suffices all"