|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72397 - in sandbox/conversion/boost/conversion: . type_traits
From: vicente.botet_at_[hidden]
Date: 2011-06-04 17:31:53
Author: viboes
Date: 2011-06-04 17:31:53 EDT (Sat, 04 Jun 2011)
New Revision: 72397
URL: http://svn.boost.org/trac/boost/changeset/72397
Log:
Conversion: fix bugs when decltype is supported.
Fix problem with constructor and assignment overloads on std::pair from another pair<U1,U2> via workaround on is_constructible and is_assignable specializations.
Add is_convertible tests.
Text files modified:
sandbox/conversion/boost/conversion/assign_to.hpp | 8 +++---
sandbox/conversion/boost/conversion/type_traits/is_assignable.hpp | 5 ++++
sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp | 46 +++++++++++++++++++++++++++++++++------
3 files changed, 48 insertions(+), 11 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 17:31:53 EDT (Sat, 04 Jun 2011)
@@ -63,7 +63,7 @@
, typename enable_if_c<
is_copy_assignable<Target>::value
&& is_extrinsic_convertible<Source,Target>::value
- && ! is_assignable<Source&,Target const&>::value
+ && ! is_assignable<Source,Target>::value
>::type
> : true_type
#else
@@ -83,7 +83,7 @@
#if defined(BOOST_CONVERSION_ENABLE_CND)
template < typename Target, typename Source>
struct assigner<Target,Source
- , typename enable_if<is_assignable<Target&, Source const&> >::type
+ , typename enable_if<is_assignable<Target, Source> >::type
> : true_type
{
//! @Requires @c Target must be Assinable from Source.
@@ -103,7 +103,7 @@
, typename enable_if_c<
is_copy_assignable<Target>::value
&& is_extrinsic_convertible<Source,Target>::value
- && ! is_assignable<Source&,Target const&>::value
+ && ! is_assignable<Target,Source>::value
>::type
#endif
> : true_type
@@ -126,7 +126,7 @@
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
+ is_assignable<Target, Source>::value
>::type
> : true_type
{
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-04 17:31:53 EDT (Sat, 04 Jun 2011)
@@ -22,6 +22,7 @@
#include <boost/type_traits/common_type.hpp>
#include <boost/utility/declval.hpp>
#include <boost/config.hpp>
+#include <utility>
#if defined(BOOST_NO_DECLTYPE)
#include <boost/typeof/typeof.hpp>
@@ -62,6 +63,10 @@
}
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)
+ 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 >
+ {};
#else
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-04 17:31:53 EDT (Sat, 04 Jun 2011)
@@ -31,6 +31,7 @@
#if defined(BOOST_NO_DECLTYPE)
#include <boost/typeof/typeof.hpp>
#endif // defined(BOOST_NO_DECLTYPE)
+#include <utility>
namespace boost {
@@ -42,43 +43,67 @@
any(T);
};
template <class T>
+#if defined(BOOST_NO_DECLTYPE)
BOOST_TYPEOF_TPL((T(), true_type()))
+#else
+ decltype((T(), true_type()))
+#endif
test0(T&);
false_type
test0(any);
template <class T, class A1>
+#if defined(BOOST_NO_DECLTYPE)
BOOST_TYPEOF_TPL((T(declval<A1>()), true_type()))
- test1(T&, A1&);
+#else
+ decltype((T(declval<A1>()), true_type()))
+#endif
+ test1(T&, A1);
template <class A1>
false_type
- test1(any, A1&);
+ test1(any, A1);
template <class T, class A1, class A2>
+#if defined(BOOST_NO_DECLTYPE)
BOOST_TYPEOF_TPL((T(declval<A1>(),declval<A2>()), true_type()))
- test2(T&, A1&, A2&);
+#else
+ decltype((T(declval<A1>(),declval<A2>()), true_type()))
+#endif
+ test2(T&, A1, A2);
template <class A1, class A2>
false_type
- test2(any, A1&, A2&);
+ 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&>()))
+#if defined(BOOST_NO_DECLTYPE)
+ BOOST_TYPEOF_TPL(test0(declval<T&>()))
+#else
+ decltype(test0(declval<T&>()))
+#endif
>::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>()))
+#if defined(BOOST_NO_DECLTYPE)
+ BOOST_TYPEOF_TPL(test1(declval<T&>(), declval<A1>()))
+#else
+ decltype(test1(declval<T&>(), declval<A1>()))
+#endif
>::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>()))
+#if defined(BOOST_NO_DECLTYPE)
+ BOOST_TYPEOF_TPL(test2(declval<T&>(), declval<A1>(), declval<A2>()))
+#else
+ decltype(test2(declval<T&>(), declval<A1>(), declval<A2>()))
+#endif
>::type
{};
template <class T>
@@ -175,6 +200,13 @@
|| is_void<A1>::value,
T, A1>
{};
+
+ template <class A1, class A2, class B1, class B2>
+ struct is_constructible< std::pair<A1,A2>, std::pair<B1,B2>, detail::is_constructible::nat>
+ : integral_constant<bool, is_constructible<A1,B1>::value && is_constructible<A2,B2>::value >
+ {};
+
+
namespace detail {
namespace is_constructible {
template <class A, std::size_t N>
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