Skip to content

Commit c22522e

Browse files
fsb4000CaseyCarter
andcommitted
add Casey's suggestions
Co-authored-by: Casey Carter <[email protected]>
1 parent 12e6cfd commit c22522e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/cpp/codesnippet/CPP/how-to-create-and-use-shared-ptr-instances_5.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ void test() {
2020

2121
// Pass the underlying pointer or a reference to the underlying object.
2222
use_raw_pointer(sp.get());
23-
use_reference(*sp.get());
23+
use_reference(*sp);
24+
25+
// Pass the shared_ptr by value.
26+
// This invokes the move constructor, which doesn't increment the reference count
27+
// but in fact transfers ownership to the callee.
28+
use_shared_ptr_by_value(move(sp));
2429
}

0 commit comments

Comments
 (0)