This commit is contained in:
hsutter 2016-01-01 10:48:34 -08:00
parent 2bea1b9d30
commit 46f38a7917

View File

@ -1795,7 +1795,7 @@ Function definition rules:
* [F.4: If a function may have to be evaluated at compile time, declare it `constexpr`](#Rf-constexpr)
* [F.5: If a function is very small and time critical, declare it inline](#Rf-inline)
* [F.6: If your function may not throw, declare it `noexcept`](#Rf-noexcept)
* [F.7: For general use, take `T*` arguments rather than smart pointers](#Rf-smart)
* [F.7: For general use, take `T*` or `T&` arguments rather than smart pointers](#Rf-smart)
* [F.8: Prefer pure functions](#Rf-pure)
Parameter passing expression rules:
@ -2184,11 +2184,11 @@ Destructors, `swap` functions, move operations, and default constructors should
* Flag functions that are not `noexcept`, yet cannot throw.
* Flag throwing `swap`, `move`, destructors, and default constructors.
### <a name="Rf-smart"></a>F.7: For general use, take `T*` arguments rather than smart pointers
### <a name="Rf-smart"></a>F.7: For general use, take `T*` or `T&` arguments rather than smart pointers
##### Reason
Passing a smart pointer transfers or shares ownership.
Passing a smart pointer transfers or shares ownership and should only be used when ownership semantics are intended (see [R.30](#Rr-smartptrparam)).
Passing by smart pointer restricts the use of a function to callers that use smart pointers.
Passing a shared smart pointer (e.g., `std::shared_ptr`) implies a run-time cost.