Switch to using boost::declval.

Change has_nothrow_copy to use is_copy_constructible as it has better broken-compiler workarounds than is_constructible.
This commit is contained in:
jzmaddock
2015-06-14 09:30:46 +01:00
parent e68fddd992
commit 2f2ca65e48
9 changed files with 24 additions and 20 deletions

View File

@@ -15,12 +15,13 @@
#if !defined(BOOST_HAS_NOTHROW_ASSIGN) || defined(BOOST_MSVC) || defined(BOOST_INTEL)
#include <boost/type_traits/has_trivial_assign.hpp>
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_SFINAE_EXPR) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <boost/declval.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/is_assignable.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/remove_reference.hpp>
#endif
#endif
#if defined(__GNUC__) || defined(__SUNPRO_CC)

View File

@@ -16,7 +16,7 @@
#if defined(BOOST_CLANG) || defined(__GNUC__) || defined(__ghs__) || defined(__CODEGEARC__)
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/is_constructible.hpp>
#include <boost/type_traits/is_copy_constructible.hpp>
#include <boost/type_traits/is_reference.hpp>
#ifdef BOOST_INTEL
#include <boost/type_traits/is_pod.hpp>
@@ -32,8 +32,8 @@ template <class T> struct has_nothrow_copy_constructor : public integral_constan
#elif !defined(BOOST_NO_CXX11_NOEXCEPT)
#include <boost/type_traits/detail/decl.hpp>
#include <boost/type_traits/is_constructible.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/type_traits/is_copy_constructible.hpp>
namespace boost{
@@ -42,11 +42,11 @@ namespace detail{
template <class T, bool b>
struct has_nothrow_copy_constructor_imp : public boost::integral_constant<bool, false>{};
template <class T>
struct has_nothrow_copy_constructor_imp<T, true> : public boost::integral_constant<bool, noexcept(T(tt_declval<const T&>()))>{};
struct has_nothrow_copy_constructor_imp<T, true> : public boost::integral_constant<bool, noexcept(T(boost::declval<const T&>()))>{};
}
template <class T> struct has_nothrow_copy_constructor : public detail::has_nothrow_copy_constructor_imp<T, boost::is_constructible<T, T const&>::value>{};
template <class T> struct has_nothrow_copy_constructor : public detail::has_nothrow_copy_constructor_imp<T, boost::is_copy_constructible<T>::value>{};
template <class T> struct has_nothrow_copy_constructor<T&> : public integral_constant<bool, false>{};
template <class T> struct has_nothrow_copy_constructor<T&&> : public integral_constant<bool, false>{};
template <class T> struct has_nothrow_copy_constructor<T volatile> : public integral_constant<bool, false>{};

View File

@@ -13,7 +13,7 @@
#if !defined(BOOST_NO_CXX11_NOEXCEPT)
#include <boost/type_traits/detail/decl.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/type_traits/is_destructible.hpp>
namespace boost{
@@ -23,7 +23,7 @@ namespace boost{
template <class T, bool b>
struct has_nothrow_destructor_imp : public boost::integral_constant<bool, false>{};
template <class T>
struct has_nothrow_destructor_imp<T, true> : public boost::integral_constant<bool, noexcept(tt_declval<T*&>()->~T())>{};
struct has_nothrow_destructor_imp<T, true> : public boost::integral_constant<bool, noexcept(boost::declval<T*&>()->~T())>{};
}

View File

@@ -244,7 +244,7 @@
# define BOOST_HAS_TRIVIAL_ASSIGN(T) ((__has_trivial_assign(T) BOOST_INTEL_TT_OPTS) && ! ::boost::is_volatile<T>::value && ! ::boost::is_const<T>::value && is_assignable<T&, const T&>::value)
# define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) (__has_trivial_destructor(T) BOOST_INTEL_TT_OPTS && is_destructible<T>::value)
# define BOOST_HAS_NOTHROW_CONSTRUCTOR(T) (__has_nothrow_constructor(T) && is_default_constructible<T>::value BOOST_INTEL_TT_OPTS)
# define BOOST_HAS_NOTHROW_COPY(T) ((__has_nothrow_copy(T) BOOST_INTEL_TT_OPTS) && !is_volatile<T>::value && !is_reference<T>::value && is_constructible<T, const T&>::value)
# define BOOST_HAS_NOTHROW_COPY(T) ((__has_nothrow_copy(T) BOOST_INTEL_TT_OPTS) && !is_volatile<T>::value && !is_reference<T>::value && is_copy_constructible<T>::value)
# define BOOST_HAS_NOTHROW_ASSIGN(T) ((__has_nothrow_assign(T) BOOST_INTEL_TT_OPTS) && !is_volatile<T>::value && !is_const<T>::value && is_assignable<T&, const T&>::value)
# define BOOST_HAS_VIRTUAL_DESTRUCTOR(T) __has_virtual_destructor(T)

View File

@@ -21,7 +21,7 @@ namespace boost{
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/type_traits/detail/decl.hpp>
#include <boost/type_traits/declval.hpp>
namespace boost{
@@ -29,7 +29,7 @@ namespace boost{
struct is_assignable_imp
{
template<typename T, typename U, typename = decltype(tt_declval<T>() = tt_declval<U>())>
template<typename T, typename U, typename = decltype(boost::declval<T>() = boost::declval<U>())>
static boost::type_traits::yes_type test(int);
template<typename, typename>

View File

@@ -17,7 +17,7 @@
#include <boost/type_traits/is_destructible.hpp>
#include <boost/type_traits/is_default_constructible.hpp>
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/type_traits/detail/decl.hpp>
#include <boost/type_traits/declval.hpp>
namespace boost{
@@ -25,12 +25,12 @@ namespace boost{
struct is_constructible_imp
{
template<typename T, typename ...TheArgs, typename = decltype(T(tt_declval<TheArgs>()...))>
template<typename T, typename ...TheArgs, typename = decltype(T(boost::declval<TheArgs>()...))>
static boost::type_traits::yes_type test(int);
template<typename, typename...>
static boost::type_traits::no_type test(...);
template<typename T, typename Arg, typename = decltype(::new T(tt_declval<Arg>()))>
template<typename T, typename Arg, typename = decltype(::new T(boost::declval<Arg>()))>
static boost::type_traits::yes_type test1(int);
template<typename, typename>
static boost::type_traits::no_type test1(...);
@@ -45,8 +45,8 @@ namespace boost{
template <class T, class ...Args> struct is_constructible : public integral_constant<bool, sizeof(detail::is_constructible_imp::test<T, Args...>(0)) == sizeof(boost::type_traits::yes_type)>{};
template <class T, class Arg> struct is_constructible<T, Arg> : public integral_constant<bool, is_destructible<T>::value && sizeof(detail::is_constructible_imp::test1<T, Arg>(0)) == sizeof(boost::type_traits::yes_type)>{};
template <class Ref, class Arg> struct is_constructible<Ref&, Arg> : public integral_constant<bool, sizeof(detail::is_constructible_imp::ref_test<Ref&>(detail::tt_declval<Arg>())) == sizeof(boost::type_traits::yes_type)>{};
template <class Ref, class Arg> struct is_constructible<Ref&&, Arg> : public integral_constant<bool, sizeof(detail::is_constructible_imp::ref_test<Ref&&>(detail::tt_declval<Arg>())) == sizeof(boost::type_traits::yes_type)>{};
template <class Ref, class Arg> struct is_constructible<Ref&, Arg> : public integral_constant<bool, sizeof(detail::is_constructible_imp::ref_test<Ref&>(boost::declval<Arg>())) == sizeof(boost::type_traits::yes_type)>{};
template <class Ref, class Arg> struct is_constructible<Ref&&, Arg> : public integral_constant<bool, sizeof(detail::is_constructible_imp::ref_test<Ref&&>(boost::declval<Arg>())) == sizeof(boost::type_traits::yes_type)>{};
template <> struct is_constructible<void> : public false_type{};
template <> struct is_constructible<void const> : public false_type{};

View File

@@ -69,7 +69,7 @@ namespace boost {
#include <boost/type_traits/is_rvalue_reference.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/detail/decl.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/noncopyable.hpp>
namespace boost {
@@ -137,7 +137,7 @@ namespace boost {
// };
BOOST_STATIC_CONSTANT(bool, value = (
sizeof(test(
tt_declval</*BOOST_DEDUCED_TYPENAME boost::add_reference<T const>::type*/ const T&>()
boost::declval</*BOOST_DEDUCED_TYPENAME boost::add_reference<T const>::type*/ const T&>()
)) == sizeof(boost::type_traits::yes_type)
&&
!boost::is_rvalue_reference<T>::value

View File

@@ -15,7 +15,7 @@
#if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, < 1800)
#include <boost/type_traits/detail/yes_no_type.hpp>
#include <boost/type_traits/detail/decl.hpp>
#include <boost/type_traits/declval.hpp>
namespace boost{
@@ -23,7 +23,7 @@ namespace boost{
struct is_destructible_imp
{
template<typename T, typename = decltype(tt_declval<T&>().~T())>
template<typename T, typename = decltype(boost::declval<T&>().~T())>
static boost::type_traits::yes_type test(int);
template<typename>
static boost::type_traits::no_type test(...);

View File

@@ -29,6 +29,9 @@ rule all-tests {
{
result += [ run $(source) ] ;
}
#
# These traits have both intrinsic support, and a std conforming version, test a version with intrinsics disabled for better code coverage:
#
for local source in has_nothrow_assign_test has_nothrow_constr_test has_nothrow_copy_test is_nothrow_move_assignable_test is_nothrow_move_constructible_test
{
result += [ run $(source).cpp : : : <define>BOOST_TT_DISABLE_INTRINSICS : $(source)_no_intrinsics ] ;