|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72388 - in sandbox/conversion/boost/conversion: . boost std type_traits
From: vicente.botet_at_[hidden]
Date: 2011-06-04 12:11:49
Author: viboes
Date: 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
New Revision: 72388
URL: http://svn.boost.org/trac/boost/changeset/72388
Log:
Conversion: Continue adding enabling condition SFINAE
Added:
sandbox/conversion/boost/conversion/type_traits/
sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp (contents, props changed)
sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp (contents, props changed)
sandbox/conversion/boost/conversion/type_traits/is_copy_assignable.hpp (contents, props changed)
sandbox/conversion/boost/conversion/type_traits/is_copy_constructible.hpp (contents, props changed)
sandbox/conversion/boost/conversion/type_traits/is_explicitly_convertible.hpp (contents, props changed)
sandbox/conversion/boost/conversion/type_traits/is_extrinsic_assignable.hpp (contents, props changed)
sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp (contents, props changed)
Text files modified:
sandbox/conversion/boost/conversion/assign_to.hpp | 62 +++++++++++++++++++++++++++++++++------
sandbox/conversion/boost/conversion/boost/array.hpp | 24 +++++++++++++-
sandbox/conversion/boost/conversion/boost/chrono_duration_to_posix_time_duration.hpp | 4 +-
sandbox/conversion/boost/conversion/boost/chrono_time_point_to_posix_time_ptime.hpp | 4 +-
sandbox/conversion/boost/conversion/boost/interval.hpp | 16 +++++++++-
sandbox/conversion/boost/conversion/boost/optional.hpp | 20 ++++++++++--
sandbox/conversion/boost/conversion/boost/rational.hpp | 16 +++++++++-
sandbox/conversion/boost/conversion/boost/tuple.hpp | 4 +-
sandbox/conversion/boost/conversion/convert_to.hpp | 19 +++++------
sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp | 2
sandbox/conversion/boost/conversion/std/complex.hpp | 16 +++++++++-
sandbox/conversion/boost/conversion/std/pair.hpp | 18 ++++++++++-
sandbox/conversion/boost/conversion/std/string.hpp | 8 ++--
sandbox/conversion/boost/conversion/std/vector.hpp | 26 ++++++++++++++-
14 files changed, 190 insertions(+), 49 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-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -34,12 +34,22 @@
#include <cstddef> //for std::size_t
#include <boost/conversion/convert_to.hpp>
#include <boost/utility/enable_if.hpp>
-//#include <boost/conversion/tt/is_copy_constructible.hpp>
-//#include <boost/conversion/tt/is_copy_constructible.hpp>
-//#include <boost/conversion/tt/is_extrinsic_convertible.hpp>
+#include <boost/conversion/type_traits/is_copy_assignable.hpp>
+#include <boost/conversion/type_traits/is_assignable.hpp>
+#include <boost/conversion/type_traits/is_extrinsic_convertible.hpp>
namespace boost {
namespace conversion {
+
+
+ template < typename Target, typename Source>
+ struct assigner_specialized
+ : integral_constant<bool,
+ is_copy_assignable<Target>::value
+ && is_extrinsic_convertible<Source,Target>::value
+ >
+ {};
+
//! Customization point for @assign_to.
//! @tparam Target target type of the conversion.
//! @tparam Source source type of the conversion.
@@ -47,15 +57,15 @@
#if defined(BOOST_CONVERSION_ENABLE_CND)
template < typename Target, typename Source, class Enable = void>
- struct assigner;
+ struct assigner : false_type {};
template < typename Target, typename Source>
struct assigner<Target, Source
, typename enable_if_c<
- is_copy_constructible<Target>::value
+ is_copy_assignable<Target>::value
&& is_extrinsic_convertible<Source,Target>::value
- && ! is_assignable<Source,Target>::value
+ && ! is_assignable<Source&,Target const&>::value
>::type
- >
+ > : true_type
#else
template < typename Target, typename Source, class Enable = void>
struct assigner
@@ -73,8 +83,8 @@
#if defined(BOOST_CONVERSION_ENABLE_CND)
template < typename Target, typename Source>
struct assigner<Target,Source
- , typename enable_if<is_assignable<Target, Source> >::type
- >
+ , typename enable_if<is_assignable<Target&, Source const&> >::type
+ > : true_type
{
//! @Requires @c Target must be Assinable from Source.
//! @Effects Assigns the @c from parameter to the @c to parameter.
@@ -88,7 +98,15 @@
#endif
//! partial specialization for c-array types.
template < typename Target, typename Source, std::size_t N >
- struct assigner<Target[N],Source[N],void>
+ struct assigner<Target[N],Source[N]
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_copy_assignable<Target>::value
+ && is_extrinsic_convertible<Source,Target>::value
+ && ! is_assignable<Source&,Target const&>::value
+ >::type
+#endif
+ > : true_type
{
//! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator on each one of the array elements.
//! @Throws Whatever the underlying assignment operator of the @c Target class throws.
@@ -102,6 +120,30 @@
return to;
}
};
+
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ //! partial specialization for c-array types.
+ template < typename Target, typename Source, std::size_t N >
+ struct assigner<Target[N],Source[N]
+ , typename enable_if_c<
+ is_assignable<Source&,Target const&>::value
+ >::type
+ > : true_type
+ {
+ //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator on each one of the array elements.
+ //! @Throws Whatever the underlying assignment operator of the @c Target class throws.
+ //! @Basic
+ Target*& operator()(Target(&to)[N], const Source(& from)[N])
+ {
+ for (std::size_t i = 0; i < N; ++i)
+ {
+ to[i] = from[i];
+ }
+ return to;
+ }
+ };
+#endif
+
}
#if defined(BOOST_CONVERSION_DOUBLE_CP)
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-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -22,6 +22,10 @@
#include <boost/conversion/assign_to.hpp>
#include <algorithm>
#include <boost/config.hpp>
+//#include <boost/conversion/type_traits/is_extrinsic_assignable.hpp>
+//#include <boost/conversion/type_traits/is_copy_assignable.hpp>
+//#include <boost/conversion/type_traits/is_assignable.hpp>
+//#include <boost/conversion/type_traits/is_extrinsic_convertible.hpp>
namespace boost {
namespace conversion {
@@ -30,7 +34,13 @@
* Partial specialization of @c converter for @c boost::array of the same size
*/
template < typename Target, typename Source, std::size_t N>
- struct converter< array<Target,N>, array<Source,N> >
+ 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
+ >::type
+#endif
+ > : true_type
{
//! @Returns the array having as elements the result of the conversion of each one of the source array elements.
inline array<Target,N> operator()(array<Source,N> const & from)
@@ -44,14 +54,22 @@
* Partial specialization of @c assigner for @c boost::array of the same size
*/
template < typename Target, typename Source, std::size_t N>
- struct assigner< array<Target,N>, array<Source,N> >
+ 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 const&>::value
+ >::type
+#endif
+ > : true_type
{
//! @Effects assign to each one of the target array elements the conversion of the source array element.
array<Target,N>& operator()(array<Target,N>& to, array<Source,N> const & from)
{
for (unsigned int i =0; i<N; ++i)
{
- to[i]=boost::conversion::convert_to<Target>(from[i]);
+ boost::conversion::assign_to(to[i], from[i]);
}
return to;
}
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-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -28,7 +28,7 @@
//! @brief @c converter specialization for conversions from @c boost::chrono::duration<> to @c boost::posix_time::time_duration.
//!
template < class Rep, class Period>
- struct converter<posix_time::time_duration, chrono::duration<Rep, Period> >
+ struct converter<posix_time::time_duration, chrono::duration<Rep, Period> > : true_type
{
//! @Returns the duration converted to seconds+nanoseconds following the boost::posix_time::time_duration formatting.
posix_time::time_duration operator()(chrono::duration<Rep, Period> const & from)
@@ -51,7 +51,7 @@
//!
template < class Rep, class Period>
- struct converter<chrono::duration<Rep, Period>, posix_time::time_duration>
+ struct converter<chrono::duration<Rep, Period>, posix_time::time_duration> : true_type
{
//! @Returns the duration cast from a nanoseconds duration initialized to the total number of nanosecond of the @c from parameter.
chrono::duration<Rep, Period> operator()(posix_time::time_duration const & from)
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-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -28,7 +28,7 @@
namespace boost {
namespace conversion {
template < class Clock, class Duration>
- struct converter<posix_time::ptime, chrono::time_point<Clock, Duration> >
+ struct converter<posix_time::ptime, chrono::time_point<Clock, Duration> > : true_type
{
posix_time::ptime operator()(const chrono::time_point<Clock, Duration>& from)
{
@@ -49,7 +49,7 @@
};
template < class Clock, class Duration>
- struct converter<chrono::time_point<Clock, Duration>, posix_time::ptime>
+ struct converter<chrono::time_point<Clock, Duration>, posix_time::ptime> : true_type
{
chrono::time_point<Clock, Duration> operator()(const posix_time::ptime& from)
{
Modified: sandbox/conversion/boost/conversion/boost/interval.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/interval.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/interval.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -26,7 +26,13 @@
//! @brief @c converter specialization for source and target been @c boost::numeric::interval.
//!
template < class Target, class PTarget, class Source, class PSource>
- struct converter< numeric::interval<Target,PTarget>, numeric::interval<Source,PSource> >
+ struct converter< numeric::interval<Target,PTarget>, numeric::interval<Source,PSource>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<Source,Target>::value
+ >::type
+#endif
+ > : true_type
{
//! @Returns the target interval having as extremes the conversion from the source interval extremes.
numeric::interval<Target,PTarget> operator()(numeric::interval<Source,PSource> const & from)
@@ -35,7 +41,13 @@
}
};
template < class Target, class PTarget, class Source, class PSource>
- struct assigner< numeric::interval<Target,PTarget>, numeric::interval<Source,PSource> >
+ struct assigner< numeric::interval<Target,PTarget>, numeric::interval<Source,PSource>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<Source,Target>::value
+ >::type
+#endif
+ > : true_type
{
numeric::interval<Target,PTarget>& operator()(numeric::interval<Target,PTarget>& to, const numeric::interval<Source,PSource>& from)
{
Modified: sandbox/conversion/boost/conversion/boost/optional.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/optional.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/optional.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -45,7 +45,13 @@
* Partial specialization of @c converter for boost::optional
*/
template < class Target, class Source>
- struct converter< optional<Target>, optional<Source> >
+ struct converter< optional<Target>, optional<Source>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<Source,Target>::value
+ >::type
+#endif
+ > : true_type
{
//! @Returns If the optional source is initialized @c boost::optional<Target> initialized to the conversion of the optional value.
//! Uninitialized @c boost::optional<Target otherwise.
@@ -59,7 +65,14 @@
//!
//! We can see this specialization as a try_convert_to function.
template < class Target, class Source>
- struct converter< optional<Target>, Source>
+ struct converter< optional<Target>, Source
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<Source,Target>::value
+ >::type
+#endif
+ > : true_type
+
{
//! @Returns If the source is convertible to the target @c value_type
//! @c Target initialized to the result of the conversion.
@@ -87,8 +100,7 @@
//! @Effects As if <c>to = boost::conversion::convert_to<optional<Target> >(from)</c>.
//! @Returns The @c to parameter reference.
template < class Target, class Source>
- inline optional<Target>& assign_to(optional<Target>& to, const optional<Source>& from
- )
+ inline optional<Target>& assign_to(optional<Target>& to, const optional<Source>& from)
{
to = boost::conversion::convert_to<optional<Target> >(from);
return to;
Modified: sandbox/conversion/boost/conversion/boost/rational.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/rational.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/rational.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -29,7 +29,13 @@
//! @brief @c converter specialization for source and target been @c boost::rational.
//!
template < class Target, class Source>
- struct converter< rational<Target>, rational<Source> >
+ struct converter< rational<Target>, rational<Source>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<Source,Target>::value
+ >::type
+#endif
+ > : true_type
{
//! @Returns the target rational having as numerator and denominator the conversion from the numerator and denominator of the source rational.
rational<Target> operator()(rational<Source> const & from)
@@ -38,7 +44,13 @@
}
};
template < class Target, class Source>
- struct assigner< rational<Target>, rational<Source> >
+ struct assigner< rational<Target>, rational<Source>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<Source,Target>::value
+ >::type
+#endif
+ > : true_type
{
rational<Target>& operator()(rational<Target>& to, const rational<Source>& from)
{
Modified: sandbox/conversion/boost/conversion/boost/tuple.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/boost/tuple.hpp (original)
+++ sandbox/conversion/boost/conversion/boost/tuple.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -24,7 +24,7 @@
namespace boost {
namespace conversion {
template < class T1, class T2, class S1, class S2>
- struct converter< fusion::tuple<T1,T2>, fusion::tuple<S1,S2> >
+ struct converter< fusion::tuple<T1,T2>, fusion::tuple<S1,S2> > : true_type
{
fusion::tuple<T1,T2> operator()(fusion::tuple<S1,S2> const & from)
{
@@ -35,7 +35,7 @@
}
};
template < class T1, class T2, class T3, class S1, class S2, class S3>
- struct converter< fusion::tuple<T1,T2,T3>, fusion::tuple<S1,S2,S3> >
+ struct converter< fusion::tuple<T1,T2,T3>, fusion::tuple<S1,S2,S3> > : true_type
{
fusion::tuple<T1,T2,T3> operator()(fusion::tuple<S1,S2,S3> const & from)
{
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-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -34,11 +34,11 @@
#ifndef BOOST_CONVERSION_CONVERT_TO_HPP
#define BOOST_CONVERSION_CONVERT_TO_HPP
-//#include <boost/mpl/bool.hpp>
+//#define BOOST_CONVERSION_ENABLE_CND
+
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/integral_constant.hpp>
-//#include <boost/conversion/tt/is_explicit_constructible.hpp>
-//#include <boost/conversion/tt/is_extrinsic_convertible.hpp>
+#include <boost/conversion/type_traits/is_explicitly_convertible.hpp>
namespace boost {
@@ -74,17 +74,16 @@
#if defined(BOOST_CONVERSION_ENABLE_CND)
template < typename Target, typename Source, class Enable = void >
- struct converter;
+ struct converter : false_type {};
template < typename Target, typename Source >
struct converter<Target, Source
- , typename enable_if_c<
- is_explicit_constructible<Target, const Source&>::value
- or is_explicitly_convertible<Source,Target>::value
- >::type
- >
+ , typename enable_if<is_explicitly_convertible<Source,Target> >::type
+ > : true_type
+ //template < typename Target, typename Source, class Enable = void >
+ //struct converter : true_type
#else
template < typename Target, typename Source, class Enable = void >
- struct converter
+ struct converter : true_type
#endif
{
//! @Requires @c Target must be CopyConstructible from @c Source or @c Source convertible to @c Target
Modified: sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp (original)
+++ sandbox/conversion/boost/conversion/convert_to_or_fallback.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -42,7 +42,7 @@
//! @tparam Source source type of the conversion.
//! @tparam Fallback type of the fallback value which must be explicitly convertible to @c Target.
//! @tparam Enable A dummy template parameter that can be used for SFINAE.
- template < typename Target, typename Source, typename Fallback, class Enable = void>
+ template < typename Target, typename Source, typename Fallback=Target, class Enable = void>
struct converter_or_fallbacker {
//!
//! @Requires @c Fallback must be convertible to @c Target and @c ::boost::conversion::convert_to<Target>(from) must be well formed.
Modified: sandbox/conversion/boost/conversion/std/complex.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/complex.hpp (original)
+++ sandbox/conversion/boost/conversion/std/complex.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -28,7 +28,13 @@
* Partial specialization of @c convert_to for @c std::complex of the same size
*/
template < class Target, class Source>
- struct converter< std::complex<Target>, std::complex<Source> >
+ struct converter< std::complex<Target>, std::complex<Source>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<Source,Target>::value
+ >::type
+#endif
+ > : true_type
{
std::complex<Target> operator()(std::complex<Source> const & from)
{
@@ -38,7 +44,13 @@
}
};
template < class Target, class Source>
- struct assigner< std::complex<Target>, std::complex<Source> >
+ struct assigner< std::complex<Target>, std::complex<Source>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<Source,Target>::value
+ >::type
+#endif
+ > : true_type
{
std::complex<Target>& operator()(std::complex<Target>& to, const std::complex<Source>& from)
{
Modified: sandbox/conversion/boost/conversion/std/pair.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/std/pair.hpp (original)
+++ sandbox/conversion/boost/conversion/std/pair.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -26,7 +26,14 @@
// std namespace can not be overloaded
template < class T1, class T2, class S1, class S2>
- struct converter< std::pair<T1,T2>, std::pair<S1,S2> >
+ struct converter< std::pair<T1,T2>, std::pair<S1,S2>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<S1,T1>::value && is_extrinsic_convertible<S2,T2>::value
+ && ! is_explicitly_convertible<std::pair<S1,S2>,std::pair<T1,T2> >::value
+ >::type
+#endif
+ > : true_type
{
std::pair<T1,T2> operator()(std::pair<S1,S2> const & from)
{
@@ -34,7 +41,14 @@
}
};
template < class T1, class T2, class S1, class S2>
- struct assigner< std::pair<T1,T2>, std::pair<S1,S2> >
+ struct assigner< std::pair<T1,T2>, std::pair<S1,S2>
+#if defined(BOOST_CONVERSION_ENABLE_CND)
+ , typename enable_if_c<
+ is_extrinsic_convertible<S1,T1>::value && is_extrinsic_convertible<S2,T2>::value
+ && ! assigner_specialized<std::pair<T1,T2>,std::pair<S1,S2> >::value
+ >::type
+#endif
+ > : true_type
{
std::pair<T1,T2>& operator()(std::pair<T1,T2>& to, const std::pair<S1,S2>& from)
{
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-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -31,7 +31,7 @@
// std namespace can not be overloaded
template<typename T, typename CharT, typename Traits, typename Alloc>
- struct converter< std::basic_string<CharT,Traits,Alloc>, T >
+ struct converter< std::basic_string<CharT,Traits,Alloc>, T > : true_type
{
std::basic_string<CharT,Traits,Alloc> operator()(T const & from)
{
@@ -43,7 +43,7 @@
}
};
template<typename T, typename CharT, typename Traits, typename Alloc>
- struct converter< T, std::basic_string<CharT,Traits,Alloc> >
+ struct converter< T, std::basic_string<CharT,Traits,Alloc> > : true_type
{
T operator()(std::basic_string<CharT,Traits,Alloc> const & from)
{
@@ -56,7 +56,7 @@
};
template<typename T, typename CharT, typename Traits, typename Alloc>
- struct assigner< std::basic_string<CharT,Traits,Alloc>, T >
+ struct assigner< std::basic_string<CharT,Traits,Alloc>, T > : true_type
{
std::basic_string<CharT,Traits,Alloc>&
operator()(std::basic_string<CharT,Traits,Alloc>& to, const T& from)
@@ -66,7 +66,7 @@
}
};
template<typename T, typename CharT, typename Traits, typename Alloc>
- struct assigner< T, std::basic_string<CharT,Traits,Alloc> >
+ struct assigner< T, std::basic_string<CharT,Traits,Alloc> > : true_type
{
T& operator()(T& to, const std::basic_string<CharT,Traits,Alloc>& from)
{
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-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -29,7 +29,13 @@
// 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> >
+ 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
+ >::type
+#endif
+ > : true_type
{
std::vector<T1,A1> operator()(std::vector<T2,A2> const & from)
{
@@ -47,7 +53,15 @@
boost::reference_wrapper<std::vector<T2,A2> const>,
boost::reference_wrapper<A1 const>
>
- >
+#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
+ >::type
+#endif
+ > : false_type
{
std::vector<T1,A1> operator()(
typename boost::conversion::result_of::pack2<std::vector<T2,A2> const, A1 const>::type
@@ -62,7 +76,13 @@
};
template < class T1, class A1, class T2, class A2>
- struct assigner< std::vector<T1,A1>, std::vector<T2,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
+ >::type
+#endif
+ > : true_type
{
std::vector<T1,A1>& operator()(
std::vector<T1,A1>& to,
Added: sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -0,0 +1,76 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/type_traits for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief
+ */
+
+
+#ifndef BOOST_CONVERSION_TT_IS_ASSIGNABLE_HPP
+#define BOOST_CONVERSION_TT_IS_ASSIGNABLE_HPP
+
+#include <boost/type_traits/intrinsics.hpp>
+#if !defined(BOOST_IS_ASSIGNABLE)
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/type_traits/common_type.hpp>
+#include <boost/utility/declval.hpp>
+#include <boost/config.hpp>
+
+#if defined(BOOST_NO_DECLTYPE)
+#include <boost/typeof/typeof.hpp>
+#endif // defined(BOOST_NO_DECLTYPE)
+
+#endif // !defined(BOOST_IS_ASSIGNABLE)
+
+// should be always the last #include directive
+#include <boost/type_traits/detail/bool_trait_def.hpp>
+
+namespace boost {
+#ifndef BOOST_IS_ASSIGNABLE
+
+ namespace detail {
+
+ namespace is_assignable {
+ template <class Target, class Source>
+#if !defined(BOOST_NO_DECLTYPE)
+ decltype((declval<Target>() = declval<Source>(), true_type()))
+#else
+ BOOST_TYPEOF_TPL((declval<Target>() = declval<Source>(), true_type()))
+#endif
+ test(int);
+
+ template <class, class>
+ static false_type test(...);
+
+ template<class T, class U>
+ struct impl {
+#if !defined(BOOST_NO_DECLTYPE)
+ typedef decltype(test<T, U>(0)) type;
+#else
+ typedef BOOST_TYPEOF_TPL((test<T, U>(0))) type;
+#endif
+ };
+
+ }
+ }
+ BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_assignable,To,From,(::boost::detail::is_assignable::impl<To,From>::type::value))
+ BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_assignable2,To,From,false)
+
+#else
+
+ BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_assignable,To,From,BOOST_IS_ASSIGNABLE(To,From))
+
+#endif
+}
+
+#include <boost/type_traits/detail/bool_trait_undef.hpp>
+
+#endif
+
Added: sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -0,0 +1,200 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/conversion for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief
+ */
+
+
+#ifndef BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_HPP
+#define BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_HPP
+
+
+#include <boost/utility/declval.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/type_traits/common_type.hpp>
+#include <boost/type_traits/is_scalar.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/type_traits/is_abstract.hpp>
+#include <boost/type_traits/is_function.hpp>
+#include <boost/type_traits/is_void.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+#include <boost/type_traits/remove_all_extents.hpp>
+#include <boost/config.hpp>
+#if defined(BOOST_NO_DECLTYPE)
+#include <boost/typeof/typeof.hpp>
+#endif // defined(BOOST_NO_DECLTYPE)
+
+namespace boost {
+
+ namespace detail {
+
+ namespace is_constructible {
+ struct any {
+ template <typename T>
+ any(T);
+ };
+ template <class T>
+ BOOST_TYPEOF_TPL((T(), true_type()))
+ test0(T&);
+ false_type
+ test0(any);
+
+ template <class T, class A1>
+ BOOST_TYPEOF_TPL((T(declval<A1>()), true_type()))
+ test1(T&, A1&);
+ template <class A1>
+ false_type
+ test1(any, A1&);
+
+ template <class T, class A1, class A2>
+ BOOST_TYPEOF_TPL((T(declval<A1>(),declval<A2>()), true_type()))
+ test2(T&, A1&, A2&);
+ template <class A1, class A2>
+ false_type
+ test2(any, A1&, A2&);
+ template <bool, class T>
+ struct imp0 // false, T is not a scalar
+ : public common_type
+ <
+ BOOST_TYPEOF_TPL(test1(declval<T&>()))
+ >::type
+ {};
+ template <bool, class T, class A1>
+ struct imp1 // false, T is not a scalar
+ : public common_type
+ <
+ BOOST_TYPEOF_TPL(test1(declval<T&>(), declval<A1>()))
+ >::type
+ {};
+ template <bool, class T, class A1, class A2>
+ struct imp2 // false, T is not a scalar
+ : public common_type
+ <
+ BOOST_TYPEOF_TPL(test2(declval<T&>(), declval<A1>(), declval<A2>()))
+ >::type
+ {};
+ template <class T>
+ struct imp0<true, T>
+ : public is_scalar<T>
+ {};
+
+ template <class T, class A1>
+ struct imp1<true, T, A1>
+ : public is_convertible<A1, T>
+ {};
+
+ template <class T, class A1, class A2>
+ struct imp2<true, T, A1, A2>
+ : public false_type
+ {};
+ template <bool, class T>
+ struct void_check0
+ : public imp0<is_scalar<T>::value || is_reference<T>::value,
+ T>
+ {};
+
+ template <bool, class T, class A1>
+ struct void_check1
+ : public imp1<is_scalar<T>::value || is_reference<T>::value,
+ T, A1>
+ {};
+
+ template <bool, class T, class A1, class A2>
+ struct void_check2
+ : public imp2<is_scalar<T>::value || is_reference<T>::value,
+ T, A1, A2>
+ {};
+
+ template <class T>
+ struct void_check0<true, T>
+ : public false_type
+ {};
+
+ template <class T, class A1>
+ struct void_check1<true, T, A1>
+ : public false_type
+ {};
+
+ template <class T, class A1, class A2>
+ struct void_check2<true, T, A1, A2>
+ : public false_type
+ {};
+
+ struct nat {};
+
+ template <class A>
+ struct imp0<false, A[]>
+ : public false_type
+ {};
+
+ template <class A, class A1>
+ struct imp1<false, A[], A1>
+ : public false_type
+ {};
+
+ template <class A, class A1, class A2>
+ struct imp2<false, A[], A1, A2>
+ : public false_type
+ {};
+
+ }
+ }
+
+ template <class T, class A1 = detail::is_constructible::nat,
+ class A2 = detail::is_constructible::nat>
+ struct is_constructible
+ : public detail::is_constructible::void_check2<is_void<T>::value
+ || is_abstract<T>::value
+ || is_function<T>::value
+ || is_void<A1>::value
+ || is_void<A2>::value,
+ T, A1, A2>
+ {};
+
+ template <class T>
+ struct is_constructible<T, detail::is_constructible::nat, detail::is_constructible::nat>
+ : public detail::is_constructible::void_check0<is_void<T>::value
+ || is_abstract<T>::value
+ || is_function<T>::value,
+ T>
+ {};
+
+ template <class T, class A1>
+ struct is_constructible<T, A1, detail::is_constructible::nat>
+ : public detail::is_constructible::void_check1<is_void<T>::value
+ || is_abstract<T>::value
+ || is_function<T>::value
+ || is_void<A1>::value,
+ T, A1>
+ {};
+ namespace detail {
+ namespace is_constructible {
+ template <class A, std::size_t N>
+ struct imp0<false, A[N]>
+ : public boost::is_constructible<typename remove_all_extents<A>::type>
+ {};
+
+ template <class A, std::size_t N, class A1>
+ struct imp1<false, A[N], A1>
+ : public false_type
+ {};
+
+ template <class A, std::size_t N, class A1, class A2>
+ struct imp2<false, A[N], A1, A2>
+ : public false_type
+ {};
+ }
+ }
+}
+
+
+#endif
+
Added: sandbox/conversion/boost/conversion/type_traits/is_copy_assignable.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/type_traits/is_copy_assignable.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -0,0 +1,31 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/conversion for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief
+ */
+
+
+#ifndef BOOST_CONVERSION_TT_IS_COPY_ASSIGNABLE_HPP
+#define BOOST_CONVERSION_TT_IS_COPY_ASSIGNABLE_HPP
+
+#include <boost/conversion/type_traits/is_assignable.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+
+namespace boost {
+
+ template <class T>
+ struct is_copy_assignable : is_assignable<typename remove_reference<T>::type&, typename remove_reference<T>::type const&> {};
+
+}
+
+
+#endif
+
Added: sandbox/conversion/boost/conversion/type_traits/is_copy_constructible.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/type_traits/is_copy_constructible.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -0,0 +1,37 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/conversion for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief
+ */
+
+
+#ifndef BOOST_CONVERSION_TT_IS_COPY_CONSTRUCTIBLE_HPP
+#define BOOST_CONVERSION_TT_IS_COPY_CONSTRUCTIBLE_HPP
+
+#include <boost/conversion/type_traits/is_constructible.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+
+namespace boost {
+
+ template <class T>
+ struct is_copy_constructible : is_constructible<
+ typename remove_reference<T>::type,
+ typename remove_reference<T>::type const&
+ > {};
+
+ template <>
+ struct is_copy_constructible<void> : false_type {};
+
+}
+
+
+#endif
+
Added: sandbox/conversion/boost/conversion/type_traits/is_explicitly_convertible.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/type_traits/is_explicitly_convertible.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -0,0 +1,33 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/conversion for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief
+ */
+
+
+#ifndef BOOST_CONVERSION_TT_IS_EXPLICITLY_CONVERTIBLE_HPP
+#define BOOST_CONVERSION_TT_IS_EXPLICITLY_CONVERTIBLE_HPP
+
+#include <boost/conversion/type_traits/is_constructible.hpp>
+
+namespace boost {
+
+ template <class Source, class Target>
+ struct is_explicitly_convertible : is_constructible<Target, Source> {};
+
+ template <class Source, class Target>
+ struct is_explicitly_convertible2 : true_type {};
+
+}
+
+
+#endif
+
Added: sandbox/conversion/boost/conversion/type_traits/is_extrinsic_assignable.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/type_traits/is_extrinsic_assignable.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/conversion for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief
+ */
+
+
+#ifndef BOOST_CONVERSION_TT_IS_EXTRINSIC_ASSIGNABLE_HPP
+#define BOOST_CONVERSION_TT_IS_EXTRINSIC_ASSIGNABLE_HPP
+
+#include <boost/conversion/assign_to.hpp>
+
+namespace boost {
+
+ template <class Source, class Target>
+ struct is_extrinsic_assignable : conversion::assigner<Target, Source> {};
+
+}
+
+
+#endif
+
Added: sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp 2011-06-04 12:11:46 EDT (Sat, 04 Jun 2011)
@@ -0,0 +1,30 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009-2011. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/conversion for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+/**
+ * @file
+ * @brief
+ */
+
+
+#ifndef BOOST_CONVERSION_TT_IS_EXTRINSIC_CONVERTIBLE_HPP
+#define BOOST_CONVERSION_TT_IS_EXTRINSIC_CONVERTIBLE_HPP
+
+#include <boost/conversion/convert_to.hpp>
+
+namespace boost {
+
+ template <class Source, class Target>
+ struct is_extrinsic_convertible : conversion::converter<Target, Source> {};
+
+}
+
+
+#endif
+
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