From 6501d1c088bbb6151283fbe856610e7c31dbd010 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 20 Dec 2002 18:15:01 +0000 Subject: [PATCH 1/8] Factor out get_pointer, supply an overload for std::auto_ptr. [SVN r16672] --- include/boost/get_pointer.hpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 include/boost/get_pointer.hpp diff --git a/include/boost/get_pointer.hpp b/include/boost/get_pointer.hpp new file mode 100644 index 0000000..09091e4 --- /dev/null +++ b/include/boost/get_pointer.hpp @@ -0,0 +1,30 @@ +// Copyright Peter Dimov and David Abrahams 2002. Permission to copy, +// use, modify, sell and distribute this software is granted provided +// this copyright notice appears in all copies of the source. This +// software is provided "as is" without express or implied warranty, +// and with no claim as to its suitability for any purpose. +#ifndef GET_POINTER_DWA20021219_HPP +# define GET_POINTER_DWA20021219_HPP + +# include + +namespace boost { + +// get_pointer(p) extracts a ->* capable pointer from p + +template T * get_pointer(T * p) +{ + return p; +} + +// get_pointer(shared_ptr const & p) has been moved to shared_ptr.hpp + +template T * get_pointer(std::auto_ptr const& p) +{ + return p.get(); +} + + +} // namespace boost + +#endif // GET_POINTER_DWA20021219_HPP From 3a04ef69318a2e0a51932525566180da18f07198 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 26 Jul 2004 00:32:12 +0000 Subject: [PATCH 2/8] Converted to Boost Software License, Version 1.0 [SVN r24055] --- include/boost/get_pointer.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/boost/get_pointer.hpp b/include/boost/get_pointer.hpp index 09091e4..17d11b8 100644 --- a/include/boost/get_pointer.hpp +++ b/include/boost/get_pointer.hpp @@ -1,8 +1,7 @@ -// Copyright Peter Dimov and David Abrahams 2002. Permission to copy, -// use, modify, sell and distribute this software is granted provided -// this copyright notice appears in all copies of the source. This -// software is provided "as is" without express or implied warranty, -// and with no claim as to its suitability for any purpose. +// Copyright Peter Dimov and David Abrahams 2002. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) #ifndef GET_POINTER_DWA20021219_HPP # define GET_POINTER_DWA20021219_HPP From c47e07e344fbf32ca66bd854d3b34aac5f49f734 Mon Sep 17 00:00:00 2001 From: Beman Dawes Date: Fri, 23 Nov 2007 17:03:14 +0000 Subject: [PATCH 3/8] config, detail, filesystem, system, tools, at 41278. [SVN r41316] --- include/boost/detail/sp_typeinfo.hpp | 83 ++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 include/boost/detail/sp_typeinfo.hpp diff --git a/include/boost/detail/sp_typeinfo.hpp b/include/boost/detail/sp_typeinfo.hpp new file mode 100644 index 0000000..e78c943 --- /dev/null +++ b/include/boost/detail/sp_typeinfo.hpp @@ -0,0 +1,83 @@ +#ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED +#define BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED + +// MS compatible compilers support #pragma once + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + +// detail/sp_typeinfo.hpp +// +// Copyright 2007 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include + +#if defined( BOOST_NO_TYPEID ) + +namespace boost +{ + +namespace detail +{ + +typedef void* sp_typeinfo; + +template struct sp_typeid_ +{ + static char v_; +}; + +template char sp_typeid_< T >::v_; + +template struct sp_typeid_< T const >: sp_typeid_< T > +{ +}; + +template struct sp_typeid_< T volatile >: sp_typeid_< T > +{ +}; + +template struct sp_typeid_< T const volatile >: sp_typeid_< T > +{ +}; + +} // namespace detail + +} // namespace boost + +#define BOOST_SP_TYPEID(T) (&boost::detail::sp_typeid_::v_) + +#else + +#include + +namespace boost +{ + +namespace detail +{ + +#if defined( BOOST_NO_STD_TYPEINFO ) + +typedef ::type_info sp_typeinfo; + +#else + +typedef std::type_info sp_typeinfo; + +#endif + +} // namespace detail + +} // namespace boost + +#define BOOST_SP_TYPEID(T) typeid(T) + +#endif + +#endif // #ifndef BOOST_DETAIL_SP_TYPEINFO_HPP_INCLUDED From c6d5ee11604c9b65272f11e27e012fa916770f33 Mon Sep 17 00:00:00 2001 From: David Deakins Date: Mon, 6 Apr 2009 21:25:18 +0000 Subject: [PATCH 4/8] Have config/select_stdlib_config.hpp and config/stdlib/stlport.hpp use instead of to determine which standard library is in use. For std lib implementations that rely on Boost components like TypeTraits, Bind, Function, or SmartPtr, this helps to avoid circular header dependency issues, since is much less likely to pull in Boost libraries than . In get_pointer.hpp, switched to using instead of using directly. As above, this helps avoid circular header dependency issues in Boost-supplemented std libs (specifically it avoids issues when pulls in pieces of Boost.SmartPtr). These two changes were made in response to testing done with STLport 5.2.1 using the _STLP_USE_BOOST_SUPPORT option. [SVN r52221] --- include/boost/get_pointer.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/boost/get_pointer.hpp b/include/boost/get_pointer.hpp index 17d11b8..a0cd5c0 100644 --- a/include/boost/get_pointer.hpp +++ b/include/boost/get_pointer.hpp @@ -5,7 +5,11 @@ #ifndef GET_POINTER_DWA20021219_HPP # define GET_POINTER_DWA20021219_HPP -# include +// In order to avoid circular dependencies with Boost.TR1 +// we make sure that our include of doesn't try to +// pull in the TR1 headers: that's why we use this header +// rather than including directly: +# include // std::auto_ptr namespace boost { From 424dcdc197f9e53f9dc7ca63b46ec670cb5b6967 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sun, 6 Dec 2009 17:50:28 +0000 Subject: [PATCH 5/8] Merge [58123], [58127], [58128] to release. Fixes #3666. [SVN r58195] --- include/boost/detail/sp_typeinfo.hpp | 54 +++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/include/boost/detail/sp_typeinfo.hpp b/include/boost/detail/sp_typeinfo.hpp index e78c943..636fe27 100644 --- a/include/boost/detail/sp_typeinfo.hpp +++ b/include/boost/detail/sp_typeinfo.hpp @@ -19,20 +19,66 @@ #if defined( BOOST_NO_TYPEID ) +#include +#include + namespace boost { namespace detail { -typedef void* sp_typeinfo; +class sp_typeinfo +{ +private: + + sp_typeinfo( sp_typeinfo const& ); + sp_typeinfo& operator=( sp_typeinfo const& ); + + char const * name_; + +public: + + explicit sp_typeinfo( char const * name ): name_( name ) + { + } + + bool operator==( sp_typeinfo const& rhs ) const + { + return this == &rhs; + } + + bool operator!=( sp_typeinfo const& rhs ) const + { + return this != &rhs; + } + + bool before( sp_typeinfo const& rhs ) const + { + return std::less< sp_typeinfo const* >()( this, &rhs ); + } + + char const* name() const + { + return name_; + } +}; template struct sp_typeid_ { - static char v_; + static sp_typeinfo ti_; + + static char const * name() + { + return BOOST_CURRENT_FUNCTION; + } }; -template char sp_typeid_< T >::v_; +template sp_typeinfo sp_typeid_< T >::ti_( sp_typeid_< T >::name() ); + +template struct sp_typeid_< T & >: sp_typeid_< T > +{ +}; template struct sp_typeid_< T const >: sp_typeid_< T > { @@ -50,7 +96,7 @@ template struct sp_typeid_< T const volatile >: sp_typeid_< T > } // namespace boost -#define BOOST_SP_TYPEID(T) (&boost::detail::sp_typeid_::v_) +#define BOOST_SP_TYPEID(T) (boost::detail::sp_typeid_::ti_) #else From fa633633cd6d116ab2e81640262546e92567a9a8 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 10 Jul 2010 20:46:53 +0000 Subject: [PATCH 6/8] Merge [62245] to release. Fixes #4199. [SVN r63825] --- include/boost/detail/sp_typeinfo.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/detail/sp_typeinfo.hpp b/include/boost/detail/sp_typeinfo.hpp index 636fe27..3ee934f 100644 --- a/include/boost/detail/sp_typeinfo.hpp +++ b/include/boost/detail/sp_typeinfo.hpp @@ -74,7 +74,7 @@ template struct sp_typeid_ } }; -template sp_typeinfo sp_typeid_< T >::ti_( sp_typeid_< T >::name() ); +template sp_typeinfo sp_typeid_< T >::ti_ = sp_typeid_< T >::name(); template struct sp_typeid_< T & >: sp_typeid_< T > { From f6ec7809ad5138dc01d7aeed5698ddbf5a7ae5ea Mon Sep 17 00:00:00 2001 From: Hartmut Kaiser Date: Sun, 24 Oct 2010 22:24:54 +0000 Subject: [PATCH 7/8] Merging from trunk [SVN r66166] --- include/boost/detail/sp_typeinfo.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/boost/detail/sp_typeinfo.hpp b/include/boost/detail/sp_typeinfo.hpp index 3ee934f..43fae78 100644 --- a/include/boost/detail/sp_typeinfo.hpp +++ b/include/boost/detail/sp_typeinfo.hpp @@ -74,7 +74,13 @@ template struct sp_typeid_ } }; +#if defined(__SUNPRO_CC) +// see #4199, the Sun Studio compiler gets confused about static initialization +// constructor arguments. But an assignment works just fine. template sp_typeinfo sp_typeid_< T >::ti_ = sp_typeid_< T >::name(); +#else +template sp_typeinfo sp_typeid_< T >::ti_(sp_typeid_< T >::name()); +#endif template struct sp_typeid_< T & >: sp_typeid_< T > { From 1e4ef1085988173c680bf620285a166fdbd8e48f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Wed, 14 Nov 2012 11:20:29 +0000 Subject: [PATCH 8/8] Merged [81125] from trunk. Fixes #4185. [SVN r81329] --- include/boost/get_pointer.hpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/include/boost/get_pointer.hpp b/include/boost/get_pointer.hpp index a0cd5c0..b27b98a 100644 --- a/include/boost/get_pointer.hpp +++ b/include/boost/get_pointer.hpp @@ -3,13 +3,15 @@ // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef GET_POINTER_DWA20021219_HPP -# define GET_POINTER_DWA20021219_HPP +#define GET_POINTER_DWA20021219_HPP + +#include // In order to avoid circular dependencies with Boost.TR1 // we make sure that our include of doesn't try to // pull in the TR1 headers: that's why we use this header // rather than including directly: -# include // std::auto_ptr +#include // std::auto_ptr namespace boost { @@ -27,6 +29,19 @@ template T * get_pointer(std::auto_ptr const& p) return p.get(); } +#if !defined( BOOST_NO_CXX11_SMART_PTR ) + +template T * get_pointer( std::unique_ptr const& p ) +{ + return p.get(); +} + +template T * get_pointer( std::shared_ptr const& p ) +{ + return p.get(); +} + +#endif } // namespace boost