blob: 914928dd2f595e7a8200f7bd4bbd36aca068a115 [file] [log] [blame]
Brian Silverman355f11d2018-08-04 23:57:00 -07001////
2Copyright 1999 Greg Colvin and Beman Dawes
3Copyright 2002 Darin Adler
4Copyright 2017 Peter Dimov
5
6Distributed under the Boost Software License, Version 1.0.
7
8See accompanying file LICENSE_1_0.txt or copy at
9http://www.boost.org/LICENSE_1_0.txt
10////
11
12[[history]]
13[appendix]
14# History and Acknowledgments
15:idprefix: history_
16
17## Summer 1994
18
19Greg Colvin http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1994/N0555.pdf[proposed]
20to the {cpp} Standards Committee classes named `auto_ptr` and `counted_ptr` which were very
21similar to what we now call `scoped_ptr` and `shared_ptr`. In one of the very few cases
22where 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`.
24
25## October 1998
26
27Beman Dawes proposed reviving the original semantics under the names `safe_ptr` and `counted_ptr`,
28meeting of Per Andersson, Matt Austern, Greg Colvin, Sean Corfield, Pete Becker, Nico Josuttis,
29Dietmar Kühl, Nathan Myers, Chichiang Wan and Judy Ward. During the discussion, the four new class
30names were finalized, it was decided that there was no need to exactly follow the `std::auto_ptr`
31interface, and various function signatures and semantics were finalized.
32
33Over the next three months, several implementations were considered for `shared_ptr`, and discussed
34on the http://www.boost.org/[boost.org] mailing list. The implementation questions revolved around
35the reference count which must be kept, either attached to the pointed to object, or detached elsewhere.
36Each of those variants have themselves two major variants:
37
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.
42
43Each implementation technique has advantages and disadvantages. We went so far as to run various timings
44of the direct and indirect approaches, and found that at least on Intel Pentium chips there was very little
45measurable difference. Kevlin Henney provided a paper he wrote on "Counted Body Techniques." Dietmar Kühl
46suggested an elegant partial template specialization technique to allow users to choose which implementation
47they preferred, and that was also experimented with.
48
49But Greg Colvin and Jerry Schwarz argued that "parameterization will discourage users", and in the end we choose
50to supply only the direct implementation.
51
52## May 1999
53
54In April and May, 1999, Valentin Bonnard and David Abrahams made a number of suggestions resulting in numerous improvements.
55
56## September 1999
57
58Luis Coelho provided `shared_ptr::swap` and `shared_array::swap`.
59
60## November 1999
61
62Darin Adler provided `operator ==`, `operator !=`, and `std::swap` and `std::less` specializations for shared types.
63
64## May 2001
65
66Vladimir Prus suggested requiring a complete type on destruction. Refinement evolved in discussions including Dave Abrahams,
67Greg Colvin, Beman Dawes, Rainer Deyke, Peter Dimov, John Maddock, Vladimir Prus, Shankar Sai, and others.
68
69## January 2002
70
71Peter Dimov reworked all four classes, adding features, fixing bugs, splitting them into four separate headers, and adding
72`weak_ptr`.
73
74## March 2003
75
76Peter Dimov, Beman Dawes and Greg Colvin http://open-std.org/jtc1/sc22/wg21/docs/papers/2003/n1450.html[proposed] `shared_ptr`
77and `weak_ptr` for inclusion in the Standard Library via the first Library Technical Report (known as TR1). The proposal was
78accepted and eventually went on to become a part of the {cpp} standard in its 2011 iteration.
79
80## July 2007
81
82Peter Dimov and Beman Dawes http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2351.htm[proposed] a number of enhancements
83to `shared_ptr` as it was entering the working paper that eventually became the {cpp}11 standard.
84
85## November 2012
86
87Glen Fernandes provided implementations of `make_shared` and `allocate_shared` for arrays. They achieve a single allocation
88for an array that can be initialized with constructor arguments or initializer lists as well as overloads for default initialization
89and no value initialization.
90
91Peter Dimov aided this development by extending `shared_ptr` to support arrays via the syntax `shared_ptr<T[]>` and `shared_ptr<T[N]>`.
92
93## April 2013
94
95Peter Dimov http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3640.html[proposed] the extension of `shared_ptr` to support
96arrays for inclusion into the standard, and it was accepted.
97
98## February 2014
99
100Glen Fernandes updated `make_shared` and `allocate_shared` to conform to the specification in {cpp} standard paper
101http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3870.html[N3870], and implemented `make_unique` for arrays and objects.
102
103Peter Dimov and Glen Fernandes updated the scalar and array implementations, respectively, to resolve {cpp} standard library defect 2070.
104
105## February 2017
106
107Glen Fernandes rewrote `allocate_shared` and `make_shared` for arrays for a more optimal and more maintainable implementation.
108
109## June 2017
110
111Peter Dimov and Glen Fernandes rewrote the documentation in Asciidoc format.
112
113Peter Dimov added `atomic_shared_ptr` and `local_shared_ptr`.