Use std::shared_ptr and std::weak_ptr when available.

This commit is contained in:
Christopher Kohlhoff 2011-03-18 15:28:07 +11:00
parent 85b58394d7
commit 272435f775
3 changed files with 28 additions and 13 deletions

View File

@ -96,6 +96,22 @@
# endif // defined(BOOST_MSVC)
#endif // !defined(ASIO_DISABLE_STD_ARRAY)
// Standard library support for shared_ptr and weak_ptr.
#if !defined(ASIO_DISABLE_STD_SHARED_PTR)
# if defined(__GNUC__)
# if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# if defined(__GXX_EXPERIMENTAL_CXX0X__)
# define ASIO_HAS_STD_SHARED_PTR
# endif // defined(__GXX_EXPERIMENTAL_CXX0X__)
# endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 4)
# endif // defined(__GNUC__)
# if defined(BOOST_MSVC)
# if (_MSC_VER >= 1600)
# define ASIO_HAS_STD_SHARED_PTR
# endif // (_MSC_VER >= 1600)
# endif // defined(BOOST_MSVC)
#endif // !defined(ASIO_DISABLE_STD_SHARED_PTR)
// Windows: target OS version.
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
# if !defined(_WIN32_WINNT) && !defined(_WIN32_WINDOWS)

View File

@ -17,20 +17,20 @@
#include "asio/detail/config.hpp"
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
#if defined(ASIO_HAS_STD_SHARED_PTR)
# include <memory>
#else
#else // defined(ASIO_HAS_STD_SHARED_PTR)
# include <boost/shared_ptr.hpp>
#endif
#endif // defined(ASIO_HAS_STD_SHARED_PTR)
namespace asio {
namespace detail {
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
#if defined(ASIO_HAS_STD_SHARED_PTR)
using std::shared_ptr;
#else
#else // defined(ASIO_HAS_STD_SHARED_PTR)
using boost::shared_ptr;
#endif
#endif // defined(ASIO_HAS_STD_SHARED_PTR)
} // namespace detail
} // namespace asio

View File

@ -16,22 +16,21 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
#include <boost/version.hpp>
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
#if defined(ASIO_HAS_STD_SHARED_PTR)
# include <memory>
#else
#else // defined(ASIO_HAS_STD_SHARED_PTR)
# include <boost/weak_ptr.hpp>
#endif
#endif // defined(ASIO_HAS_STD_SHARED_PTR)
namespace asio {
namespace detail {
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
#if defined(ASIO_HAS_STD_SHARED_PTR)
using std::weak_ptr;
#else
#else // defined(ASIO_HAS_STD_SHARED_PTR)
using boost::weak_ptr;
#endif
#endif // defined(ASIO_HAS_STD_SHARED_PTR)
} // namespace detail
} // namespace asio