From 862dc0001fb6baa0dad292986a7b6369b1fc3564 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 15 Feb 2002 14:46:53 +0000 Subject: [PATCH] Documented the bool conversion. [SVN r12817] --- shared_ptr.htm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/shared_ptr.htm b/shared_ptr.htm index ff3e5aa..8dbd3a1 100644 --- a/shared_ptr.htm +++ b/shared_ptr.htm @@ -74,6 +74,8 @@ bool unique() const; // never throws long use_count() const; // never throws + operator implementation-defined-type () const; // never throws + void swap(shared_ptr<T> & b); // never throws }; @@ -255,6 +257,17 @@ q = p; be a complete type. See the smart pointer common requirements.

+

conversions

+
operator implementation-defined-type () const; // never throws
+
+

Returns: an implementation defined value that, when used in boolean + contexts, is equivalent to get() != 0.

+

Throws: nothing.

+

Notes: This conversion operator allows shared_ptr objects to be + used in boolean contexts, like if (p && p->valid()) {}. The + actual target type is typically a pointer to a member function, avloiding many + of the implicit conversion pitfalls.

+

swap

void swap(shared_ptr & b); // never throws
@@ -284,7 +297,7 @@ q = p;
template<typename T>
   bool operator<(shared_ptr<T> const & a, shared_ptr<T> const & b); // never throws
-

Returns: An implementation-defined value such that operator< +

Returns: an implementation-defined value such that operator< is a strict weak ordering as described in section 25.3 [lib.alg.sorting] of the C++ standard.

Throws: nothing.

@@ -347,7 +360,8 @@ q = p;

Returns: A shared_ptr<T> object that stores a copy of polymorphic_cast<T*>(r.get()) and shares ownership with r.

-

Throws: std::bad_cast when the pointer cannot be converted.

+

Throws: std::bad_cast when the pointer cannot be + converted.

Exception safety: If an exception is thrown, the function has no effect.

shared_polymorphic_downcast