Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72414 - in sandbox/conversion/boost/conversion: . boost std type_traits
From: vicente.botet_at_[hidden]
Date: 2011-06-05 12:48:17


Author: viboes
Date: 2011-06-05 12:48:16 EDT (Sun, 05 Jun 2011)
New Revision: 72414
URL: http://svn.boost.org/trac/boost/changeset/72414

Log:
Conversion: fix some bugs when enable is used
Text files modified:
   sandbox/conversion/boost/conversion/boost/array.hpp | 14 +++++++++-----
   sandbox/conversion/boost/conversion/convert_to.hpp | 2 ++
   sandbox/conversion/boost/conversion/std/string.hpp | 8 ++++++--
   sandbox/conversion/boost/conversion/std/vector.hpp | 34 ++++++++++++++++++++++------------
   sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp | 24 ++++++++++++++++++++++++
   sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp | 23 +++++++++++++++++++++++
   sandbox/conversion/boost/conversion/type_traits/is_extrinsic_assignable.hpp | 2 +-
   sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp | 3 +++
   8 files changed, 90 insertions(+), 20 deletions(-)

Modified: sandbox/conversion/boost/conversion/boost/array.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/array.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/array.hpp 2011-06-05 12:48:16 EDT (Sun, 05 Jun 2011)
@@ -40,7 +40,8 @@
     struct converter< array<Target,N>, array<Source,N>
 #if defined(BOOST_CONVERSION_ENABLE_CND)
     , typename enable_if_c<
- is_extrinsic_assignable<array<Source,N>,array<Target,N> >::value
+ //is_extrinsic_assignable<array<Target,N>, array<Source,N> >::value
+ is_extrinsic_assignable<Target,Source>::value
             && ! default_converter_condition<array<Target,N>, array<Source,N> >::value
>::type
 #endif
@@ -50,7 +51,11 @@
       inline array<Target,N> operator()(array<Source,N> const & from)
       {
         array<Target,N> to;
- boost::conversion::assign_to(to, from);
+ //boost::conversion::assign_to(to, from);
+ for (unsigned int i =0; i<N; ++i)
+ {
+ boost::conversion::assign_to(to[i], from[i]);
+ }
         return to;
       }
     };
@@ -61,9 +66,8 @@
     struct assigner< array<Target,N>, array<Source,N>
 #if defined(BOOST_CONVERSION_ENABLE_CND)
     , typename enable_if_c<
- is_copy_assignable<Target>::value
- && is_extrinsic_assignable<Source,Target>::value
- && ! is_assignable<Source,Target>::value
+ is_extrinsic_assignable<Target,Source>::value
+ && ! is_assignable<Target, Source>::value
             && ! default_assigner_condition<array<Target,N>, array<Source,N> >::value
>::type
 #endif

Modified: sandbox/conversion/boost/conversion/convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/convert_to.hpp 2011-06-05 12:48:16 EDT (Sun, 05 Jun 2011)
@@ -34,7 +34,9 @@
 #ifndef BOOST_CONVERSION_CONVERT_TO_HPP
 #define BOOST_CONVERSION_CONVERT_TO_HPP
 
+#if ! defined(BOOST_NO_DECLTYPE)
 #define BOOST_CONVERSION_ENABLE_CND
+#endif
 
 #include <boost/utility/enable_if.hpp>
 #include <boost/type_traits/integral_constant.hpp>

Modified: sandbox/conversion/boost/conversion/std/string.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/string.hpp (original)
+++ sandbox/conversion/boost/conversion/std/string.hpp 2011-06-05 12:48:16 EDT (Sun, 05 Jun 2011)
@@ -29,7 +29,7 @@
   namespace conversion {
 
     // std namespace can not be overloaded
-
+
     template<typename T, typename CharT, typename Traits, typename Alloc>
     struct converter< std::basic_string<CharT,Traits,Alloc>, T
 #if defined(BOOST_CONVERSION_ENABLE_CND)
@@ -79,7 +79,11 @@
       std::basic_string<CharT,Traits,Alloc>&
       operator()(std::basic_string<CharT,Traits,Alloc>& to, const T& from)
       {
+ std::cout << __FILE__ << from << std::endl;
+
         to = boost::conversion::convert_to<std::basic_string<CharT,Traits,Alloc> >(from);
+ std::cout << __FILE__ << to << std::endl;
+
         return to;
       }
     };
@@ -98,7 +102,7 @@
         return to;
       }
     };
-
+
   }
 }
 

Modified: sandbox/conversion/boost/conversion/std/vector.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/vector.hpp (original)
+++ sandbox/conversion/boost/conversion/std/vector.hpp 2011-06-05 12:48:16 EDT (Sun, 05 Jun 2011)
@@ -21,30 +21,37 @@
 #include <vector>
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/assign_to.hpp>
-#include <boost/conversion/pack.hpp>
-
+//#include <boost/conversion/pack.hpp>
+#include <boost/conversion/type_traits/is_extrinsic_assignable.hpp>
 
 namespace boost {
   namespace conversion {
 
     // std namespace can not be overloaded
+
     template < class T1, class A1, class T2, class A2>
     struct converter< std::vector<T1,A1>, std::vector<T2,A2>
 #if defined(BOOST_CONVERSION_ENABLE_CND)
     , typename enable_if_c<
- is_extrinsic_assignable< std::vector<T2,A2>,std::vector<T1,A1> >::value
- && ! default_converter_condition< std::vector<T2,A2>,std::vector<T1,A1> >::value
+ is_extrinsic_assignable<T1,T2>::value
+ //is_extrinsic_assignable< std::vector<T1,A1>, std::vector<T2,A2> >::value
+ && ! default_converter_condition< std::vector<T1,A1>, std::vector<T2,A2>>::value
>::type
 #endif
> : true_type
     {
         std::vector<T1,A1> operator()(std::vector<T2,A2> const & from)
         {
- std::vector<T1,A1> res;
- boost::conversion::assign_to(res, from);
- return res;
+ std::vector<T1,A1> to;
+ //boost::conversion::assign_to(to, from);
+ to.resize(from.size());
+ for (unsigned int i=0; i<from.size(); ++i) {
+ boost::conversion::assign_to(to[i], from[i]);
+ }
+ return to;
         }
     };
+#if 0
 
     template < class T1, class A1, class T2, class A2>
     struct converter< std::vector<T1,A1>,
@@ -56,10 +63,11 @@
>
 #if defined(BOOST_CONVERSION_ENABLE_CND)
     , typename enable_if_c<
- is_extrinsic_assignable<std::pair<
- boost::reference_wrapper<std::vector<T2,A2> const>,
- boost::reference_wrapper<A1 const>
- >, std::vector<T1,A1> >::value
+ is_extrinsic_assignable<std::vector<T1,A1> >::value,
+ std::pair<
+ boost::reference_wrapper<std::vector<T2,A2> const>,
+ boost::reference_wrapper<A1 const>
+ >
 
         && ! default_converter_condition< std::vector<T1,A1>,
                                           std::pair<
@@ -82,12 +90,13 @@
             return res;
         }
     };
+#endif
 
     template < class T1, class A1, class T2, class A2>
     struct assigner< std::vector<T1,A1>, std::vector<T2,A2>
 #if defined(BOOST_CONVERSION_ENABLE_CND)
     , typename enable_if_c<
- is_extrinsic_assignable<T2,T1>::value
+ is_extrinsic_assignable<T1,T2>::value
             && ! default_assigner_condition< std::vector<T1,A1>, std::vector<T2,A2> >::value
>::type
 #endif
@@ -104,6 +113,7 @@
             return to;
         }
     };
+
   }
 }
 

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-05 12:48:16 EDT (Sun, 05 Jun 2011)
@@ -24,6 +24,9 @@
 #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>
@@ -72,7 +75,28 @@
   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 >
+ {};
 #else
 
   BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_assignable,To,From,BOOST_IS_ASSIGNABLE(To,From))

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-05 12:48:16 EDT (Sun, 05 Jun 2011)
@@ -33,6 +33,9 @@
 #endif // defined(BOOST_NO_DECLTYPE)
 #include <utility>
 #include <boost/array.hpp>
+#include <complex>
+#include <vector>
+#include <boost/fusion/tuple.hpp>
 
 namespace boost {
 
@@ -207,11 +210,31 @@
       : 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> , detail::is_constructible::nat>
       : integral_constant<bool, is_constructible<T1,T2>::value >
         {};
+#endif
+ template < class Target, class Source>
+ struct is_constructible< std::complex<Target>, std::complex<Source>, detail::is_constructible::nat >
+ : 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> , detail::is_constructible::nat>
+ : 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> >
+ : 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> >
+ : integral_constant<bool, is_constructible<A1,B1>::value && is_constructible<A2,B2>::value&& is_constructible<A3,B3>::value >
+ {};
 
   namespace detail {
     namespace is_constructible {

Modified: sandbox/conversion/boost/conversion/type_traits/is_extrinsic_assignable.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/type_traits/is_extrinsic_assignable.hpp (original)
+++ sandbox/conversion/boost/conversion/type_traits/is_extrinsic_assignable.hpp 2011-06-05 12:48:16 EDT (Sun, 05 Jun 2011)
@@ -20,7 +20,7 @@
 
 namespace boost {
 
- template <class Source, class Target>
+ template <class Target, class Source>
   struct is_extrinsic_assignable : conversion::assigner<Target, Source> {};
 
 }

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-06-05 12:48:16 EDT (Sun, 05 Jun 2011)
@@ -17,11 +17,14 @@
 #define BOOST_CONVERSION_TT_IS_EXTRINSIC_CONVERTIBLE_HPP
 
 #include <boost/conversion/convert_to.hpp>
+#include <boost/fusion/tuple.hpp>
 
 namespace boost {
 
   template <class Source, class Target>
   struct is_extrinsic_convertible : conversion::converter<Target, Source> {};
+ 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