|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72809 - in sandbox/conversion/boost/conversion: . type_traits
From: vicente.botet_at_[hidden]
Date: 2011-06-30 01:20:24
Author: viboes
Date: 2011-06-30 01:20:22 EDT (Thu, 30 Jun 2011)
New Revision: 72809
URL: http://svn.boost.org/trac/boost/changeset/72809
Log:
Conversion: workarround on compilers that don't support is_assignable, is_convertible, ...
Text files modified:
sandbox/conversion/boost/conversion/config.hpp | 7 ++
sandbox/conversion/boost/conversion/convertible_from.hpp | 6 +
sandbox/conversion/boost/conversion/implicit_convert_to.hpp | 3
sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp | 86 +++++++++++++++++++++++----------------
sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp | 75 ++++++++++++++++++++++------------
sandbox/conversion/boost/conversion/type_traits/is_explicitly_convertible.hpp | 4
6 files changed, 111 insertions(+), 70 deletions(-)
Modified: sandbox/conversion/boost/conversion/config.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/config.hpp (original)
+++ sandbox/conversion/boost/conversion/config.hpp 2011-06-30 01:20:22 EDT (Thu, 30 Jun 2011)
@@ -29,7 +29,6 @@
#define BOOST_CONVERSION_NO_IS_ASSIGNABLE
#elif defined __clang__
#define BOOST_CONVERSION_ENABLE_CND
- //#define BOOST_CONVERSION_NO_IS_ASSIGNABLE
#elif defined __GNUC__
#if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 )
#define BOOST_CONVERSION_NO_IS_ASSIGNABLE
@@ -43,10 +42,11 @@
#if defined _MSC_VER
#define BOOST_CONVERSION_NO_IS_ASSIGNABLE
#elif defined __clang__
- //#define BOOST_CONVERSION_ENABLE_CND
+ #define BOOST_CONVERSION_ENABLE_CND
//#define BOOST_CONVERSION_NO_IS_ASSIGNABLE
#elif defined __GNUC__
#if __GNUC__ < 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ < 4 )
+ //#define BOOST_CONVERSION_ENABLE_CND
#define BOOST_CONVERSION_NO_IS_ASSIGNABLE
#endif
#else
@@ -55,6 +55,9 @@
#endif
#endif
+#if defined(BOOST_CONVERSION_ENABLE_CND) && !defined(BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS)
+#define BOOST_CONVERSION_MCF_ENABLED
+#endif
#endif
Modified: sandbox/conversion/boost/conversion/convertible_from.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convertible_from.hpp (original)
+++ sandbox/conversion/boost/conversion/convertible_from.hpp 2011-06-30 01:20:22 EDT (Thu, 30 Jun 2011)
@@ -17,6 +17,9 @@
#ifndef BOOST_CONVERSION_CONVERTIBLE_FROM_HPP
#define BOOST_CONVERSION_CONVERTIBLE_FROM_HPP
+#include <boost/conversion/config.hpp>
+#if defined(BOOST_CONVERSION_MCF_ENABLED)
+
#include <boost/conversion/implicit_convert_to.hpp>
#include <boost/conversion/assign_to.hpp>
#include <boost/conversion/type_traits/is_extrinsic_convertible.hpp>
@@ -43,9 +46,7 @@
//! @Remark On compilers that supports C++0x default arguments for function template parameters,
//! this constructor doesn't participates on overload resolution if @c Source is not extrinsic convertible to @c Target.
template <typename Target
-#if (defined(BOOST_CONVERSION_ENABLE_CND) && !defined(BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS))
, typename boost::enable_if< boost::is_extrinsic_convertible<Source,Target>, int >::type = 0
-#endif
>
operator Target() const
{
@@ -64,6 +65,7 @@
}
}
}
+#endif
#endif
Modified: sandbox/conversion/boost/conversion/implicit_convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/implicit_convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/implicit_convert_to.hpp 2011-06-30 01:20:22 EDT (Thu, 30 Jun 2011)
@@ -35,6 +35,7 @@
#include <boost/conversion/config.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/conversion/type_traits/is_convertible.hpp>
+#include <boost/type_traits/add_reference.hpp>
namespace boost {
namespace conversion {
@@ -93,7 +94,7 @@
{
//! @Effects Converts the @c from parameter to an instance of the @c Target type, using the conversion operator or copy constructor.
//! @Throws Whatever the underlying conversion @c Target operator of the @c Source class throws.
- Target operator()(const Source& val)
+ Target operator()(typename add_reference<const Source>::type val)
{
return val;
}
Modified: sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp (original)
+++ sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp 2011-06-30 01:20:22 EDT (Thu, 30 Jun 2011)
@@ -14,7 +14,13 @@
#ifndef BOOST_CONVERSION_TT_IS_ASSIGNABLE_HPP
#define BOOST_CONVERSION_TT_IS_ASSIGNABLE_HPP
+
#include <boost/conversion/config.hpp>
+#include <utility>
+#include <boost/array.hpp>
+#include <complex>
+#include <string>
+#include <boost/fusion/tuple.hpp>
#if !defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
@@ -23,12 +29,6 @@
#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/common_type.hpp>
#include <boost/utility/declval.hpp>
-#include <boost/config.hpp>
-#include <utility>
-#include <boost/array.hpp>
-#include <complex>
-#include <string>
-#include <boost/fusion/tuple.hpp>
#if defined(BOOST_NO_DECLTYPE)
#include <boost/typeof/typeof.hpp>
#endif // defined(BOOST_NO_DECLTYPE)
@@ -105,36 +105,6 @@
#endif
- template <class A1, class A2, class B1, class B2>
- struct is_assignable< std::pair<A1,A2>, std::pair<B1,B2> >
- : integral_constant<bool, is_assignable<A1,B1>::value && is_assignable<A2,B2>::value >
- {};
- template <class T1, class T2, std::size_t N>
- struct is_assignable< boost::array<T1,N>, boost::array<T2,N> >
- : integral_constant<bool, is_assignable<T1,T2>::value >
- {};
- template < class Target, class Source>
- struct is_assignable< std::complex<Target>, std::complex<Source> >
- : integral_constant<bool, is_assignable<Target,Source>::value >
- {};
- template<typename T, typename CharT, typename Traits, typename Alloc>
- struct is_assignable< std::basic_string<CharT,Traits,Alloc>, T >
- : false_type
- {};
-
- template < class T1, class A1, class T2, class A2>
- struct is_assignable< std::vector<T1,A1>, std::vector<T2,A2> >
- : integral_constant<bool, is_assignable<T1,T2>::value >
- {};
- template <class A1, class A2, class B1, class B2>
- struct is_assignable< fusion::tuple<A1,A2>, fusion::tuple<B1,B2> >
- : integral_constant<bool, is_assignable<A1,B1>::value && is_assignable<A2,B2>::value >
- {};
-
- template <class A1, class A2, class A3, class B1, class B2, class B3>
- struct is_assignable< fusion::tuple<A1,A2,A3>, fusion::tuple<B1,B2,B3> >
- : integral_constant<bool, is_assignable<A1,B1>::value && is_assignable<A2,B2>::value&& is_assignable<A3,B3>::value >
- {};
}
@@ -147,7 +117,51 @@
template < class Target, class Source>
struct is_assignable : false_type
{};
+
+ // these specialization are needed because the compiler doesn't support SFINAE on expression
+
+ template <> struct is_assignable< int&, int > : true_type {};
+ template <> struct is_assignable< int&, int& > : true_type {};
+ template <> struct is_assignable< int&, int const& > : true_type {};
+ template <> struct is_assignable< int&, double > : true_type {};
}
+
#endif
+
+
+// These specializations are needed because the std library implementation is not using SFINAE
+namespace boost {
+template <class A1, class A2, class B1, class B2>
+struct is_assignable< std::pair<A1,A2>, std::pair<B1,B2> >
+ : integral_constant<bool, is_assignable<A1,B1>::value && is_assignable<A2,B2>::value >
+ {};
+template <class T1, class T2, std::size_t N>
+struct is_assignable< boost::array<T1,N>, boost::array<T2,N> >
+ : integral_constant<bool, is_assignable<T1,T2>::value >
+ {};
+template < class Target, class Source>
+struct is_assignable< std::complex<Target>, std::complex<Source> >
+ : integral_constant<bool, is_assignable<Target,Source>::value >
+ {};
+template<typename T, typename CharT, typename Traits, typename Alloc>
+struct is_assignable< std::basic_string<CharT,Traits,Alloc>, T >
+ : false_type
+ {};
+
+template < class T1, class A1, class T2, class A2>
+struct is_assignable< std::vector<T1,A1>, std::vector<T2,A2> >
+ : integral_constant<bool, is_assignable<T1,T2>::value >
+ {};
+template <class A1, class A2, class B1, class B2>
+struct is_assignable< fusion::tuple<A1,A2>, fusion::tuple<B1,B2> >
+ : integral_constant<bool, is_assignable<A1,B1>::value && is_assignable<A2,B2>::value >
+ {};
+
+template <class A1, class A2, class A3, class B1, class B2, class B3>
+struct is_assignable< fusion::tuple<A1,A2,A3>, fusion::tuple<B1,B2,B3> >
+ : integral_constant<bool, is_assignable<A1,B1>::value && is_assignable<A2,B2>::value&& is_assignable<A3,B3>::value >
+ {};
+}
+
#endif
Modified: sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp (original)
+++ sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp 2011-06-30 01:20:22 EDT (Thu, 30 Jun 2011)
@@ -54,7 +54,7 @@
struct dummy;
}
- template<class T, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_IS_CONSTRUCTIBLE_ARITY_MAX, class A, = void BOOST_PP_INTERCEPT)>
+ template<class T, class A=void, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_IS_CONSTRUCTIBLE_ARITY_MAX, class A, = void BOOST_PP_INTERCEPT)>
struct is_constructible;
#ifndef BOOST_NO_SFINAE_EXPR
@@ -62,13 +62,13 @@
#define M1(z,n,t) type_traits_detail::declval<A##n>()
#define M0(z,n,t) \
- template<class T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
- struct is_constructible<T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, A)> \
+ template<class T, class A BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
+ struct is_constructible<T,A BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, A)> \
{ \
template<class X> \
static type_traits_detail::true_type \
- test(type_traits_detail::dummy<sizeof(X(BOOST_PP_ENUM(n, M1, ~)))>*); \
- \
+ test(type_traits_detail::dummy<sizeof(X(type_traits_detail::declval<A>() BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM(n, M1, ~)))>*); \
+ \
template<class X> \
static type_traits_detail::false_type \
test(...); \
@@ -81,11 +81,24 @@
#undef M0
#undef M1
+ #define M0(z,n,t) \
+ template<class A BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
+ struct is_constructible<void, A BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, A)> \
+ : boost::false_type \
+ { \
+ };
+
+ BOOST_PP_REPEAT(BOOST_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
+ #undef M0
+
+
+ #define BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE
+
#else
#define M0(z,n,t) \
- template<class T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
- struct is_constructible<T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, A)> \
+ template<class T, class A BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
+ struct is_constructible<T, A BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, A)> \
: boost::false_type \
{ \
};
@@ -93,40 +106,48 @@
BOOST_PP_REPEAT(BOOST_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
#undef M0
+ #define BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE
+ #define BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE
+ // these specializations are needed when BOOST_NO_SFINAE_EXPR is defined
+
+
#endif
- template <>
- struct is_constructible< void> : false_type {};
- //template <typename A1, typename A2, typename A3>
- //struct is_constructible< void, A1, A2,A3> : false_type {};
- template <class A1, class A2, class B1, class B2>
- struct is_constructible< std::pair<A1,A2>, std::pair<B1,B2> >
+#ifdef BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE
+ // default constructor
+ template <> struct is_constructible< int > : true_type {};
+#endif
+#ifdef BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE
+ template <class T> struct is_constructible< T*, T* const & > : true_type {};
+ template <> struct is_constructible< int, const int > : true_type {};
+ template <> struct is_constructible< int, int const& > : true_type {};
+ template <> struct is_constructible< double, const double > : true_type {};
+ template <> struct is_constructible< double, double const& > : true_type {};
+#endif
+
+ // these specializations are needed because the libraries define the assignment operator without using SFINAE
+ template <class A1, class A2, class B1, class B2>
+ struct is_constructible< std::pair<A1,A2>, std::pair<B1,B2> >
: integral_constant<bool, is_constructible<A1,B1>::value && is_constructible<A2,B2>::value >
{};
-#if 0
- template <class T1, class T2, std::size_t N>
- struct is_constructible< boost::array<T1,N>, boost::array<T2,N> >
- : integral_constant<bool, is_constructible<T1,T2>::value >
- {};
-#endif
- template < class Target, class Source>
- struct is_constructible< std::complex<Target>, std::complex<Source> >
+ template < class Target, class Source>
+ struct is_constructible< std::complex<Target>, std::complex<Source> >
: integral_constant<bool, is_constructible<Target,Source>::value >
{};
- template < class T1, class A1, class T2, class A2>
- struct is_constructible< std::vector<T1,A1>, std::vector<T2,A2> >
+ template < class T1, class A1, class T2, class A2>
+ struct is_constructible< std::vector<T1,A1>, std::vector<T2,A2> >
: integral_constant<bool, is_constructible<T1,T2>::value >
{};
- template <class A1, class A2, class B1, class B2>
- struct is_constructible< fusion::tuple<A1,A2>, fusion::tuple<B1,B2> >
+ template <class A1, class A2, class B1, class B2>
+ struct is_constructible< fusion::tuple<A1,A2>, fusion::tuple<B1,B2> >
: integral_constant<bool, is_constructible<A1,B1>::value && is_constructible<A2,B2>::value >
{};
- template <class A1, class A2, class A3, class B1, class B2, class B3>
- struct is_constructible< fusion::tuple<A1,A2,A3>, fusion::tuple<B1,B2,B3> >
+ template <class A1, class A2, class A3, class B1, class B2, class B3>
+ struct is_constructible< fusion::tuple<A1,A2,A3>, fusion::tuple<B1,B2,B3> >
: integral_constant<bool, is_constructible<A1,B1>::value && is_constructible<A2,B2>::value&& is_constructible<A3,B3>::value >
{};
}
Modified: sandbox/conversion/boost/conversion/type_traits/is_explicitly_convertible.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/type_traits/is_explicitly_convertible.hpp (original)
+++ sandbox/conversion/boost/conversion/type_traits/is_explicitly_convertible.hpp 2011-06-30 01:20:22 EDT (Thu, 30 Jun 2011)
@@ -22,9 +22,9 @@
template <class Source, class Target>
struct is_explicitly_convertible : is_constructible<Target, Source> {};
+ template <class Target>
+ struct is_explicitly_convertible<void,Target> : false_type {};
- template <class Source, class Target>
- struct is_explicitly_convertible2 : true_type {};
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk