Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72863 - in sandbox/conversion/boost/conversion: . boost std type_traits
From: vicente.botet_at_[hidden]
Date: 2011-07-02 17:00:55


Author: viboes
Date: 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
New Revision: 72863
URL: http://svn.boost.org/trac/boost/changeset/72863

Log:
Conversion: workarround on compilers that don't support is_assignable, is_convertible, ...
Text files modified:
   sandbox/conversion/boost/conversion/assign_to.hpp | 13 +++--
   sandbox/conversion/boost/conversion/boost/array.hpp | 12 +++++
   sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp | 31 ++++++++++++++
   sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp | 31 ++++++++++++++
   sandbox/conversion/boost/conversion/boost/optional.hpp | 12 +++++
   sandbox/conversion/boost/conversion/boost/tuple.hpp | 16 +++++++
   sandbox/conversion/boost/conversion/config.hpp | 2
   sandbox/conversion/boost/conversion/std/pair.hpp | 12 +++++
   sandbox/conversion/boost/conversion/std/string.hpp | 14 ++++++
   sandbox/conversion/boost/conversion/std/vector.hpp | 13 ++++++
   sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp | 86 +++++++++++++++++++++++++++++++++++++++
   sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp | 8 +++
   12 files changed, 242 insertions(+), 8 deletions(-)

Modified: sandbox/conversion/boost/conversion/assign_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/assign_to.hpp (original)
+++ sandbox/conversion/boost/conversion/assign_to.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -33,6 +33,7 @@
 
 
 #include <cstddef> //for std::size_t
+#include <boost/conversion/config.hpp>
 #include <boost/conversion/convert_to.hpp>
 #include <boost/utility/enable_if.hpp>
 #include <boost/conversion/type_traits/is_copy_assignable.hpp>
@@ -102,16 +103,17 @@
      *
      * @Requires @c Target must be Assinable from Source.
      */
+
     template < typename Target, typename Source>
     struct assigner<Target,Source
 #if defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
     , requires(Assignable<Target,Source>)
 #else
- , typename enable_if_c<
- is_assignable<Target, Source>::value
- >::type
+ , typename enable_if_c<
+ is_assignable<Target, Source>::value
+ >::type
 #endif
- > : true_type
+ > : true_type
     {
       //! @Effects Assigns the @c from parameter to the @c to parameter.
       //! @Throws Whatever the underlying assignment operator of the @c Target class throws.
@@ -121,7 +123,8 @@
         return to;
       }
     };
-
+
+
     /**
      * Partial specialization for c-array types.
      *

Modified: sandbox/conversion/boost/conversion/boost/array.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/array.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/array.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -28,6 +28,18 @@
 #include <boost/conversion/type_traits/is_extrinsic_convertible.hpp>
 #include <boost/conversion/type_traits/is_explicitly_convertible.hpp>
 
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+namespace boost
+{
+ template < class T, std::size_t N>
+ struct is_constructible< array<T,N> > : true_type {};
+ template < class T, std::size_t N>
+ struct is_constructible< array<T,N>, array<T,N> > : true_type {};
+ template < class T, std::size_t N>
+ struct is_assignable< array<T,N>&, array<T,N> const& > : true_type {};
+}
+#endif
+
 namespace boost {
   namespace conversion {
 #if defined(BOOST_CONVERSION_DOXYGEN_INVOKED2)

Modified: sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -24,6 +24,37 @@
 #include <boost/conversion/assign_to.hpp>
 #include <boost/config.hpp>
 
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+#define BOOST_CONVERSION_DCL_DEFAULTS3(X) \
+namespace boost \
+{ \
+template <> struct is_constructible< X > : true_type {}; \
+template <> struct is_constructible< X, X const& > : true_type {}; \
+template <> struct is_assignable< X&, X const& > : true_type {}; \
+template <> struct is_assignable< X, X > : true_type {}; \
+}
+#else
+#define BOOST_CONVERSION_DCL_DEFAULTS3(X)
+#endif
+
+BOOST_CONVERSION_DCL_DEFAULTS3(boost::posix_time::time_duration)
+
+
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+namespace boost
+{
+ template < class Rep, class Period>
+ struct is_constructible< chrono::duration<Rep, Period> > : true_type {};
+ template < class Rep, class Period>
+ struct is_constructible< chrono::duration<Rep, Period>, chrono::duration<Rep, Period> > : true_type {};
+ template < class Rep, class Period>
+ struct is_assignable< chrono::duration<Rep, Period>&, chrono::duration<Rep, Period> const& > : true_type {};
+ template < class Rep, class Period>
+ struct is_assignable< chrono::duration<Rep, Period>, chrono::duration<Rep, Period> > : true_type {};
+}
+#endif
+
+
 namespace boost {
   namespace conversion {
 #if defined(BOOST_CONVERSION_DOXYGEN_INVOKED2)

Modified: sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -26,6 +26,37 @@
 #include <boost/conversion/assign_to.hpp>
 #include <boost/config.hpp>
 
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+#define BOOST_CONVERSION_DCL_DEFAULTS2(X) \
+namespace boost \
+{ \
+template <> struct is_constructible< X > : true_type {}; \
+template <> struct is_constructible< X, X const& > : true_type {}; \
+template <> struct is_assignable< X&, X const& > : true_type {}; \
+template <> struct is_assignable< X, X > : true_type {}; \
+}
+#else
+#define BOOST_CONVERSION_DCL_DEFAULTS2(X)
+#endif
+
+BOOST_CONVERSION_DCL_DEFAULTS2(boost::posix_time::ptime)
+
+
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+namespace boost
+{
+ template < class Clock, class Duration>
+ struct is_constructible< chrono::time_point<Clock, Duration> > : true_type {};
+ template < class Clock, class Duration>
+ struct is_constructible< chrono::time_point<Clock, Duration>, chrono::time_point<Clock, Duration> > : true_type {};
+ template < class Clock, class Duration>
+ struct is_assignable< chrono::time_point<Clock, Duration>&, chrono::time_point<Clock, Duration> const& > : true_type {};
+ template < class Clock, class Duration>
+ struct is_assignable< chrono::time_point<Clock, Duration>, chrono::time_point<Clock, Duration> > : true_type {};
+}
+#endif
+
+
 namespace boost {
   namespace conversion {
 #if defined(BOOST_CONVERSION_DOXYGEN_INVOKED2)

Modified: sandbox/conversion/boost/conversion/boost/optional.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/optional.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/optional.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -27,6 +27,18 @@
 #include <boost/mpl/bool.hpp>
 #include <boost/utility/enable_if.hpp>
 
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+namespace boost
+{
+ template < class T>
+ struct is_constructible< optional<T> > : true_type {};
+ template < class T>
+ struct is_constructible< optional<T>, optional<T> > : true_type {};
+ template < class T>
+ struct is_assignable< optional<T>&, optional<T> const& > : true_type {};
+}
+#endif
+
 namespace boost {
   namespace conversion {
 

Modified: sandbox/conversion/boost/conversion/boost/tuple.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/tuple.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/tuple.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -21,6 +21,22 @@
 #include <boost/conversion/assign_to.hpp>
 #include <boost/config.hpp>
 
+//#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE)
+namespace boost
+{
+ template < class T1, class T2, class T3 >
+ struct is_constructible< fusion::tuple<T1,T2,T3> > : true_type {};
+}
+#endif
+#if defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE)
+namespace boost
+{
+ template < class T1, class T2, class T3 >
+ struct is_constructible< fusion::tuple<T1,T2,T3>, fusion::tuple<T1,T2,T3> > : true_type {};
+}
+#endif
+
 
 namespace boost {
   namespace conversion {

Modified: sandbox/conversion/boost/conversion/config.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/config.hpp (original)
+++ sandbox/conversion/boost/conversion/config.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -46,7 +46,7 @@
          //#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_ENABLE_CND
          #define BOOST_CONVERSION_NO_IS_ASSIGNABLE
        #endif
     #else

Modified: sandbox/conversion/boost/conversion/std/pair.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/pair.hpp (original)
+++ sandbox/conversion/boost/conversion/std/pair.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -23,6 +23,18 @@
 #include <boost/conversion/convert_to.hpp>
 #include <utility>
 
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+namespace boost
+{
+// template < class T, class U>
+// struct is_constructible< std::pair<T,U> > : true_type {};
+ template < class T, class U>
+ struct is_constructible< std::pair<T,U>, std::pair<T,U> const& > : true_type {};
+ template < class T, class U>
+ struct is_assignable< std::pair<T,U>&, std::pair<T,U> const& > : true_type {};
+}
+#endif
+
 namespace boost {
   namespace conversion {
 

Modified: sandbox/conversion/boost/conversion/std/string.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/string.hpp (original)
+++ sandbox/conversion/boost/conversion/std/string.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -26,6 +26,19 @@
 #else
 #include <boost/convert/convert.hpp>
 #endif
+
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+namespace boost
+{
+ template<typename CharT, typename Traits, typename Alloc>
+ struct is_constructible< std::basic_string<CharT,Traits,Alloc> > : true_type {};
+ template<typename CharT, typename Traits, typename Alloc>
+ struct is_constructible< std::basic_string<CharT,Traits,Alloc>, std::basic_string<CharT,Traits,Alloc> const& > : true_type {};
+ template<typename CharT, typename Traits, typename Alloc>
+ struct is_assignable< std::basic_string<CharT,Traits,Alloc>&, std::basic_string<CharT,Traits,Alloc> const& > : true_type {};
+}
+#endif
+
 namespace boost {
   namespace conversion {
 
@@ -66,6 +79,7 @@
     };
 
 #if !defined(BOOST_CONVERSION_ENABLE_CND)
+#error
     /**
      * Partial specialization of @c assigner_cp for convertibles to std::string.
      */

Modified: sandbox/conversion/boost/conversion/std/vector.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/vector.hpp (original)
+++ sandbox/conversion/boost/conversion/std/vector.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -25,6 +25,19 @@
 //#include <boost/conversion/pack.hpp>
 #include <boost/conversion/type_traits/is_extrinsic_assignable.hpp>
 
+#if defined(BOOST_CONVERSION_NO_IS_DEFAULT_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_CONSTRUCTIBLE) || defined(BOOST_CONVERSION_NO_IS_ASSIGNABLE)
+namespace boost
+{
+ template < class T, class A>
+ struct is_constructible< std::vector<T,A> > : true_type {};
+ template < class T, class A>
+ struct is_constructible< std::vector<T,A>, std::vector<T,A> > : true_type {};
+ template < class T, class A>
+ struct is_assignable< std::vector<T,A>&, std::vector<T,A> const& > : true_type {};
+}
+#endif
+
+
 namespace boost {
   namespace conversion {
 

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-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -120,10 +120,89 @@
 
   // these specialization are needed because the compiler doesn't support SFINAE on expression
 
+ template <> struct is_assignable< bool&, bool const& > : true_type {};
+
   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 {};
+ template <> struct is_assignable< int&, short const& > : true_type {};
+ template <> struct is_assignable< short&, int const& > : true_type {};
+ template <> struct is_assignable< float, int > : true_type {};
+ template <> struct is_assignable< int, float > : true_type {};
+
+ template <> struct is_assignable< char, char > : true_type {};
+ template <> struct is_assignable< char, unsigned char > : true_type {};
+ template <> struct is_assignable< char, short > : true_type {};
+ template <> struct is_assignable< char, unsigned short > : true_type {};
+ template <> struct is_assignable< char, int > : true_type {};
+ template <> struct is_assignable< char, unsigned int > : true_type {};
+ template <> struct is_assignable< char, long > : true_type {};
+ template <> struct is_assignable< char, unsigned long > : true_type {};
+
+ template <> struct is_assignable< char, char const& > : true_type {};
+ template <> struct is_assignable< char, short const& > : true_type {};
+ template <> struct is_assignable< char, int const& > : true_type {};
+ template <> struct is_assignable< char, long const& > : true_type {};
+ template <> struct is_assignable< char, unsigned char const& > : true_type {};
+ template <> struct is_assignable< char, unsigned short const& > : true_type {};
+ template <> struct is_assignable< char, unsigned int const& > : true_type {};
+ template <> struct is_assignable< char, unsigned long const& > : true_type {};
+
+ template <> struct is_assignable< short, char > : true_type {};
+ template <> struct is_assignable< short, unsigned char > : true_type {};
+ template <> struct is_assignable< short, short > : true_type {};
+ template <> struct is_assignable< short, unsigned short > : true_type {};
+ template <> struct is_assignable< short, int > : true_type {};
+ template <> struct is_assignable< short, unsigned int > : true_type {};
+ template <> struct is_assignable< short, long > : true_type {};
+ template <> struct is_assignable< short, unsigned long > : true_type {};
+
+ template <> struct is_assignable< short, char const& > : true_type {};
+ template <> struct is_assignable< short, short const& > : true_type {};
+ template <> struct is_assignable< short, int const& > : true_type {};
+ template <> struct is_assignable< short, long const& > : true_type {};
+ template <> struct is_assignable< short, unsigned char const& > : true_type {};
+ template <> struct is_assignable< short, unsigned short const& > : true_type {};
+ template <> struct is_assignable< short, unsigned int const& > : true_type {};
+ template <> struct is_assignable< short, unsigned long const& > : true_type {};
+
+ template <> struct is_assignable< int, char > : true_type {};
+ template <> struct is_assignable< int, unsigned char > : true_type {};
+ template <> struct is_assignable< int, short > : true_type {};
+ template <> struct is_assignable< int, unsigned short > : true_type {};
+ template <> struct is_assignable< int, int > : true_type {};
+ template <> struct is_assignable< int, unsigned int > : true_type {};
+ template <> struct is_assignable< int, long > : true_type {};
+ template <> struct is_assignable< int, unsigned long > : true_type {};
+
+ template <> struct is_assignable< int, char const& > : true_type {};
+ template <> struct is_assignable< int, short const& > : true_type {};
+ template <> struct is_assignable< int, int const& > : true_type {};
+ template <> struct is_assignable< int, long const& > : true_type {};
+ template <> struct is_assignable< int, unsigned char const& > : true_type {};
+ template <> struct is_assignable< int, unsigned short const& > : true_type {};
+ template <> struct is_assignable< int, unsigned int const& > : true_type {};
+ template <> struct is_assignable< int, unsigned long const& > : true_type {};
+
+ template <> struct is_assignable< long, char > : true_type {};
+ template <> struct is_assignable< long, unsigned char > : true_type {};
+ template <> struct is_assignable< long, short > : true_type {};
+ template <> struct is_assignable< long, unsigned short > : true_type {};
+ template <> struct is_assignable< long, int > : true_type {};
+ template <> struct is_assignable< long, unsigned int > : true_type {};
+ template <> struct is_assignable< long, long > : true_type {};
+ template <> struct is_assignable< long, unsigned long > : true_type {};
+
+ template <> struct is_assignable< long, char const& > : true_type {};
+ template <> struct is_assignable< long, short const& > : true_type {};
+ template <> struct is_assignable< long, int const& > : true_type {};
+ template <> struct is_assignable< long, long const& > : true_type {};
+ template <> struct is_assignable< long, unsigned char const& > : true_type {};
+ template <> struct is_assignable< long, unsigned short const& > : true_type {};
+ template <> struct is_assignable< long, unsigned int const& > : true_type {};
+ template <> struct is_assignable< long, unsigned long const& > : true_type {};
+
 }
 
 #endif
@@ -157,7 +236,12 @@
     : 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>
+ template <class A1, class A2, class B1, class B2>
+ struct is_assignable< fusion::tuple<A1,A2>&, fusion::tuple<B1,B2> const&>
+ : 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 >
       {};

Modified: sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp (original)
+++ sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp 2011-07-02 17:00:53 EDT (Sat, 02 Jul 2011)
@@ -16,6 +16,8 @@
 #define BOOST_CONVERSION_TT_IS_EXTRINSIC_CONVERTIBLE_HPP
 
 #include <boost/conversion/implicit_convert_to.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/remove_cv.hpp>
 #include <boost/fusion/tuple.hpp>
 
 namespace boost {
@@ -24,7 +26,11 @@
    * trait-type that is @c true_type when @c Source is extrinsic implicit convertible to @c Target.
    */
   template <class Source, class Target>
- struct is_extrinsic_convertible : conversion::converter<Target, Source> {};
+ struct is_extrinsic_convertible : conversion::converter<
+ Target, Source
+ //typename remove_reference<typename remove_cv<Target>::type>::type,
+ //typename remove_reference<typename remove_cv<Source>::type>::type
+ > {};
 #if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
   template <class T>
   struct is_extrinsic_convertible<fusion::void_,T> : false_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