Skip to content

Commit 66988cc

Browse files
committed
Clarify the initial shared_ptr example text
Resolves #364
1 parent 06a85eb commit 66988cc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

books/RayTracingInOneWeekend.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -987,15 +987,15 @@
987987
Typically, a shared pointer is first initialized with a newly-allocated object, something like this:
988988

989989
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
990-
shared_ptr<thing> thing_ptr = make_shared<thing>(1, true);
991-
auto thing2_ptr = make_shared<thing2>(2, false);
990+
shared_ptr<thing> thing_ptr = make_shared<thing>(thing_constructor_params ...);
991+
auto thing2_ptr = make_shared<thing2>(thing2_constructor_params ...);
992992
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
993993
[Listing [shared-ptr]: An example allocation using `shared_ptr`]
994994

995-
`make_shared<thing>(1, true)` allocates a new instance of type `thing`, using the constructor
996-
arguments `(1, true)`. It returns a `shared_ptr<thing>`. This can be simplified as in the second
997-
line with the `auto` type declaration, because the type is sufficiently defined by the return type
998-
of `make_shared<thing2>`.
995+
`make_shared<thing>(thing_constructor_params ...)` allocates a new instance of type `thing`, using
996+
the constructor parameters. It returns a `shared_ptr<thing>`. The second line shows a simpler form
997+
using the `auto` type declaration (the type can be automatically deduced by the return type of
998+
`make_shared<thing2>(...)`.
999999
</div>
10001000

10011001
We'll use shared pointers in our code, because it allows multiple objects to use a common object

0 commit comments

Comments
 (0)