Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-08-17 13:20:04


I like it fine, but I'd like more review of this and other changes.

----- Original Message -----
From: "Darin Adler" <darin_at_[hidden]>
To: "Greg Colvin" <gcolvin_at_[hidden]>; "Beman Dawes" <bdawes_at_[hidden]>
Cc: <boost_at_[hidden]>
Sent: Friday, August 17, 2001 8:33 AM
Subject: smart ptr changes

> Greg, Beman, maybe one or both of you can OK this change to smart_ptr.hpp.
> If you do, I'll be happy to check it in.
>
> Index: boost/smart_ptr.hpp
> ===================================================================
> RCS file: /cvsroot/boost/boost/boost/smart_ptr.hpp,v
> retrieving revision 1.12
> diff -p -u -r1.12 smart_ptr.hpp
> --- boost/smart_ptr.hpp 2001/07/06 13:23:07 1.12
> +++ boost/smart_ptr.hpp 2001/08/17 15:30:54
> @@ -9,6 +9,9 @@
> // See http://www.boost.org for most recent version including
> documentation.
>
> // Revision History
> +// 17 Aug 01 added operator <, and got rid of std::swap and std::less
> since
> +// std::swap is already non-throwing for shared_ptr and
> operator <
> +// is better than specializing std::less (Darin Adler)
> // 6 Jul 01 Reorder shared_ptr code so VC++ 6 member templates work,
> allowing
> // polymorphic pointers to now work with that compiler (Gary
> Powell)
> // 21 May 01 Require complete type where incomplete type is unsafe.
> @@ -268,6 +271,12 @@ template<typename T, typename U>
> inline bool operator!=(const shared_ptr<T>& a, const shared_ptr<U>& b)
> { return a.get() != b.get(); }
>
> +template<typename T>
> + inline bool operator<(const shared_ptr<T>& a, const shared_ptr<T>& b)
> + { return std::less(a.get(), b.get()); }
> +
> +// Should we also supply <=, >, and >=?
> +
> //
> shared_array ------------------------------------------------------------/
> /
>
> // shared_array extends shared_ptr to arrays.
> @@ -345,53 +354,13 @@ template<typename T>
> inline bool operator!=(const shared_array<T>& a, const shared_array<T>&
> b)
> { return a.get() != b.get(); }
>
> -} // namespace boost
> -
> -// specializations for things in namespace
> std -----------------------------//
> -
> -#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
> -
> -namespace std {
> -
> -// Specialize std::swap to use the fast, non-throwing swap that's provided
> -// as a member function instead of using the default algorithm which
> creates
> -// a temporary and uses assignment.
> -
> template<typename T>
> - inline void swap(boost::shared_ptr<T>& a, boost::shared_ptr<T>& b)
> - { a.swap(b); }
> + inline bool operator<(const shared_array<T>& a, const shared_array<T>&
> b)
> + { return std::less(a.get(), b.get()); }
>
> -template<typename T>
> - inline void swap(boost::shared_array<T>& a, boost::shared_array<T>& b)
> - { a.swap(b); }
> -
> -// Specialize std::less so we can use shared pointers and arrays as keys
> in
> -// associative collections.
> -
> -// It's still a controversial question whether this is better than
> supplying
> -// a full range of comparison operators (<, >, <=, >=).
> -
> -template<typename T>
> - struct less< boost::shared_ptr<T> >
> - : binary_function<boost::shared_ptr<T>, boost::shared_ptr<T>, bool>
> - {
> - bool operator()(const boost::shared_ptr<T>& a,
> - const boost::shared_ptr<T>& b) const
> - { return less<T*>()(a.get(),b.get()); }
> - };
> +// Should we also supply <=, >, and >=?
>
> -template<typename T>
> - struct less< boost::shared_array<T> >
> - : binary_function<boost::shared_array<T>, boost::shared_array<T>,
> bool>
> - {
> - bool operator()(const boost::shared_array<T>& a,
> - const boost::shared_array<T>& b) const
> - { return less<T*>()(a.get(),b.get()); }
> - };
> -
> -} // namespace std
> -
> -#endif // ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
> +} // namespace boost
>
> #ifdef BOOST_MSVC
> # pragma warning(pop)
> ===================================================================
>
> -- Darin
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk