Fix addressof for nullptr_t values. Fixes #5487.

This commit is contained in:
Peter Dimov
2013-12-11 01:57:20 +02:00
parent 8a1d121ef9
commit a25ab4d824
2 changed files with 106 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
// Copyright (C) 2002 Brad King (brad.king@kitware.com)
// Douglas Gregor (gregod@cs.rpi.edu)
//
// Copyright (C) 2002, 2008 Peter Dimov
// Copyright (C) 2002, 2008, 2013 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
@@ -14,6 +14,7 @@
# include <boost/config.hpp>
# include <boost/detail/workaround.hpp>
# include <cstddef>
namespace boost
{
@@ -46,6 +47,60 @@ template<class T> struct addressof_impl
}
};
#if !defined( BOOST_NO_CXX11_NULLPTR )
#if defined( __clang__ ) && !defined( _LIBCPP_VERSION ) && !defined( BOOST_NO_CXX11_DECLTYPE )
typedef decltype(nullptr) addr_nullptr_t;
#else
typedef std::nullptr_t addr_nullptr_t;
#endif
template<> struct addressof_impl< addr_nullptr_t >
{
typedef addr_nullptr_t T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
}
};
template<> struct addressof_impl< addr_nullptr_t const >
{
typedef addr_nullptr_t const T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
}
};
template<> struct addressof_impl< addr_nullptr_t volatile >
{
typedef addr_nullptr_t volatile T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
}
};
template<> struct addressof_impl< addr_nullptr_t const volatile >
{
typedef addr_nullptr_t const volatile T;
static BOOST_FORCEINLINE T * f( T & v, int )
{
return &v;
}
};
#endif
} // namespace detail
template<class T>