Fixes msvc-11 compile failures.
This commit is contained in:
jzmaddock
2014-04-22 09:22:35 +01:00
parent 6100ef9bac
commit 7c2d5eb2a6
6 changed files with 105 additions and 8 deletions

View File

@ -11,6 +11,7 @@
#ifndef BOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED
#define BOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED
#include <cstddef>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
@ -21,6 +22,82 @@
namespace boost {
namespace detail {
#if BOOST_WORKAROUND(BOOST_MSVC, == 1700)
#define BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(X) X
template <typename T>
struct cv_traits_imp
{
BOOST_STATIC_CONSTANT(bool, is_const = false);
BOOST_STATIC_CONSTANT(bool, is_volatile = false);
typedef T unqualified_type;
};
template <typename T>
struct cv_traits_imp<T[]>
{
BOOST_STATIC_CONSTANT(bool, is_const = false);
BOOST_STATIC_CONSTANT(bool, is_volatile = false);
typedef T unqualified_type[];
};
template <typename T>
struct cv_traits_imp<const T[]>
{
BOOST_STATIC_CONSTANT(bool, is_const = true);
BOOST_STATIC_CONSTANT(bool, is_volatile = false);
typedef T unqualified_type[];
};
template <typename T>
struct cv_traits_imp<volatile T[]>
{
BOOST_STATIC_CONSTANT(bool, is_const = false);
BOOST_STATIC_CONSTANT(bool, is_volatile = true);
typedef T unqualified_type[];
};
template <typename T>
struct cv_traits_imp<const volatile T[]>
{
BOOST_STATIC_CONSTANT(bool, is_const = true);
BOOST_STATIC_CONSTANT(bool, is_volatile = true);
typedef T unqualified_type[];
};
template <typename T, std::size_t N>
struct cv_traits_imp<T[N]>
{
BOOST_STATIC_CONSTANT(bool, is_const = false);
BOOST_STATIC_CONSTANT(bool, is_volatile = false);
typedef T unqualified_type[N];
};
template <typename T, std::size_t N>
struct cv_traits_imp<const T[N]>
{
BOOST_STATIC_CONSTANT(bool, is_const = true);
BOOST_STATIC_CONSTANT(bool, is_volatile = false);
typedef T unqualified_type[N];
};
template <typename T, std::size_t N>
struct cv_traits_imp<volatile T[N]>
{
BOOST_STATIC_CONSTANT(bool, is_const = false);
BOOST_STATIC_CONSTANT(bool, is_volatile = true);
typedef T unqualified_type[N];
};
template <typename T, std::size_t N>
struct cv_traits_imp<const volatile T[N]>
{
BOOST_STATIC_CONSTANT(bool, is_const = true);
BOOST_STATIC_CONSTANT(bool, is_volatile = true);
typedef T unqualified_type[N];
};
#else
#define BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(X) X *
template <typename T> struct cv_traits_imp {};
template <typename T>
@ -30,9 +107,10 @@ struct cv_traits_imp<T*>
BOOST_STATIC_CONSTANT(bool, is_volatile = false);
typedef T unqualified_type;
};
#endif
template <typename T>
struct cv_traits_imp<const T*>
struct cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(const T)>
{
BOOST_STATIC_CONSTANT(bool, is_const = true);
BOOST_STATIC_CONSTANT(bool, is_volatile = false);
@ -40,7 +118,7 @@ struct cv_traits_imp<const T*>
};
template <typename T>
struct cv_traits_imp<volatile T*>
struct cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(volatile T)>
{
BOOST_STATIC_CONSTANT(bool, is_const = false);
BOOST_STATIC_CONSTANT(bool, is_volatile = true);
@ -48,7 +126,7 @@ struct cv_traits_imp<volatile T*>
};
template <typename T>
struct cv_traits_imp<const volatile T*>
struct cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(const volatile T)>
{
BOOST_STATIC_CONSTANT(bool, is_const = true);
BOOST_STATIC_CONSTANT(bool, is_volatile = true);

View File

@ -54,7 +54,7 @@ struct is_const_rvalue_filter
#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::cv_traits_imp<typename boost::remove_bounds<T>::type*>::is_const);
#else
BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::cv_traits_imp<T*>::is_const);
BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(T)>::is_const);
#endif
};
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

View File

@ -41,7 +41,7 @@ struct is_volatile_rval_filter
#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::cv_traits_imp<typename boost::remove_bounds<T>::type*>::is_volatile);
#else
BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::cv_traits_imp<T*>::is_volatile);
BOOST_STATIC_CONSTANT(bool, value = ::boost::detail::cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(T)>::is_volatile);
#endif
};
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES

View File

@ -43,7 +43,7 @@ template <typename T>
struct remove_const_impl
{
typedef typename remove_const_helper<
typename cv_traits_imp<T*>::unqualified_type
typename cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(T)>::unqualified_type
, ::boost::is_volatile<T>::value
>::type type;
};

View File

@ -42,7 +42,7 @@ template <typename T>
struct remove_volatile_impl
{
typedef typename remove_volatile_helper<
typename cv_traits_imp<T*>::unqualified_type
typename cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(T)>::unqualified_type
, ::boost::is_const<T>::value
>::type type;
};

View File

@ -27,10 +27,27 @@ BOOST_DECL_TRANSFORM_TEST(remove_const_test_14, ::tt::remove_const, const volati
BOOST_DECL_TRANSFORM_TEST(remove_const_test_15, ::tt::remove_const, [2], [2])
BOOST_DECL_TRANSFORM_TEST(remove_const_test_16, ::tt::remove_const, const*, const*)
BOOST_DECL_TRANSFORM_TEST(remove_const_test_17, ::tt::remove_const, const*const, const*)
BOOST_DECL_TRANSFORM_TEST(remove_const_test_18, ::tt::remove_const, (*), (*))
BOOST_DECL_TRANSFORM_TEST(remove_const_test_19, ::tt::remove_const, (*const), (*))
struct S
{
template<typename T>
typename boost::remove_const<T>::type *operator=(T const &) const { return 0; }
};
void bar() {}
void bug_case_7317()
{
S s;
s = bar;
(void)s;
}
TT_TEST_BEGIN(remove_const)
BOOST_CHECK_TYPE(int, int);
BOOST_CHECK_TYPE(int, int);
remove_const_test_1();
remove_const_test_2();
@ -47,6 +64,8 @@ BOOST_CHECK_TYPE(int, int);
remove_const_test_15();
remove_const_test_16();
remove_const_test_17();
remove_const_test_18();
remove_const_test_19();
TT_TEST_END