diff options
Diffstat (limited to 'absl/memory')
-rw-r--r-- | absl/memory/memory.h | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/absl/memory/memory.h b/absl/memory/memory.h index a0d0714fabe3..5a4a1a1dfe25 100644 --- a/absl/memory/memory.h +++ b/absl/memory/memory.h @@ -47,19 +47,14 @@ namespace absl { // X* NewX(int, int); // auto x = WrapUnique(NewX(1, 2)); // 'x' is std::unique_ptr<X>. // -// The purpose of WrapUnique is to automatically deduce the pointer type. If you -// wish to make the type explicit, for readability reasons or because you prefer -// to use a base-class pointer rather than a derived one, just use +// Do not call WrapUnique with an explicit type, as in +// `WrapUnique<X>(NewX(1, 2))`. The purpose of WrapUnique is to automatically +// deduce the pointer type. If you wish to make the type explicit, just use // `std::unique_ptr` directly. // -// Example: -// X* Factory(int, int); -// auto x = std::unique_ptr<X>(Factory(1, 2)); +// auto x = std::unique_ptr<X>(NewX(1, 2)); // - or - -// std::unique_ptr<X> x(Factory(1, 2)); -// -// This has the added advantage of working whether Factory returns a raw -// pointer or a `std::unique_ptr`. +// std::unique_ptr<X> x(NewX(1, 2)); // // While `absl::WrapUnique` is useful for capturing the output of a raw // pointer factory, prefer 'absl::make_unique<T>(args...)' over |