2 Copyright 1999 Greg Colvin and Beman Dawes
3 Copyright 2002 Darin Adler
4 Copyright 2017 Peter Dimov
6 Distributed under the Boost Software License, Version 1.0.
8 See accompanying file LICENSE_1_0.txt or copy at
9 http://www.boost.org/LICENSE_1_0.txt
14 # History and Acknowledgments
19 Greg Colvin http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1994/N0555.pdf[proposed]
20 to the {cpp} Standards Committee classes named `auto_ptr` and `counted_ptr` which were very
21 similar to what we now call `scoped_ptr` and `shared_ptr`. In one of the very few cases
22 where the Library Working Group's recommendations were not followed by the full committee,
23 `counted_ptr` was rejected and surprising transfer-of-ownership semantics were added to `auto_ptr`.
27 Beman Dawes proposed reviving the original semantics under the names `safe_ptr` and `counted_ptr`,
28 meeting of Per Andersson, Matt Austern, Greg Colvin, Sean Corfield, Pete Becker, Nico Josuttis,
29 Dietmar Kühl, Nathan Myers, Chichiang Wan and Judy Ward. During the discussion, the four new class
30 names were finalized, it was decided that there was no need to exactly follow the `std::auto_ptr`
31 interface, and various function signatures and semantics were finalized.
33 Over the next three months, several implementations were considered for `shared_ptr`, and discussed
34 on the http://www.boost.org/[boost.org] mailing list. The implementation questions revolved around
35 the reference count which must be kept, either attached to the pointed to object, or detached elsewhere.
36 Each of those variants have themselves two major variants:
38 * Direct detached: the `shared_ptr` contains a pointer to the object, and a pointer to the count.
39 * Indirect detached: the `shared_ptr` contains a pointer to a helper object, which in turn contains a pointer to the object and the count.
40 * Embedded attached: the count is a member of the object pointed to.
41 * Placement attached: the count is attached via operator new manipulations.
43 Each implementation technique has advantages and disadvantages. We went so far as to run various timings
44 of the direct and indirect approaches, and found that at least on Intel Pentium chips there was very little
45 measurable difference. Kevlin Henney provided a paper he wrote on "Counted Body Techniques." Dietmar Kühl
46 suggested an elegant partial template specialization technique to allow users to choose which implementation
47 they preferred, and that was also experimented with.
49 But Greg Colvin and Jerry Schwarz argued that "parameterization will discourage users", and in the end we choose
50 to supply only the direct implementation.
54 In April and May, 1999, Valentin Bonnard and David Abrahams made a number of suggestions resulting in numerous improvements.
58 Luis Coelho provided `shared_ptr::swap` and `shared_array::swap`.
62 Darin Adler provided `operator ==`, `operator !=`, and `std::swap` and `std::less` specializations for shared types.
66 Vladimir Prus suggested requiring a complete type on destruction. Refinement evolved in discussions including Dave Abrahams,
67 Greg Colvin, Beman Dawes, Rainer Deyke, Peter Dimov, John Maddock, Vladimir Prus, Shankar Sai, and others.
71 Peter Dimov reworked all four classes, adding features, fixing bugs, splitting them into four separate headers, and adding
76 Peter Dimov, Beman Dawes and Greg Colvin http://open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html[proposed] `shared_ptr`
77 and `weak_ptr` for inclusion in the Standard Library via the first Library Technical Report (known as TR1). The proposal was
78 accepted and eventually went on to become a part of the {cpp} standard in its 2011 iteration.
82 Peter Dimov and Beman Dawes http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2351.htm[proposed] a number of enhancements
83 to `shared_ptr` as it was entering the working paper that eventually became the {cpp}11 standard.
87 Glen Fernandes provided implementations of `make_shared` and `allocate_shared` for arrays. They achieve a single allocation
88 for an array that can be initialized with constructor arguments or initializer lists as well as overloads for default initialization
89 and no value initialization.
91 Peter Dimov aided this development by extending `shared_ptr` to support arrays via the syntax `shared_ptr<T[]>` and `shared_ptr<T[N]>`.
95 Peter Dimov http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3640.html[proposed] the extension of `shared_ptr` to support
96 arrays for inclusion into the standard, and it was accepted.
100 Glen Fernandes updated `make_shared` and `allocate_shared` to conform to the specification in {cpp} standard paper
101 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3870.html[N3870], and implemented `make_unique` for arrays and objects.
103 Peter Dimov and Glen Fernandes updated the scalar and array implementations, respectively, to resolve {cpp} standard library defect 2070.
107 Glen Fernandes rewrote `allocate_shared` and `make_shared` for arrays for a more optimal and more maintainable implementation.
111 Peter Dimov and Glen Fernandes rewrote the documentation in Asciidoc format.
113 Peter Dimov added `atomic_shared_ptr` and `local_shared_ptr`.
117 Glen Fernandes implemented `allocate_unique` for scalars and arrays.