|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72552 - in sandbox/conversion/boost/conversion: . type_traits
From: vicente.botet_at_[hidden]
Date: 2011-06-12 08:49:27
Author: viboes
Date: 2011-06-12 08:49:26 EDT (Sun, 12 Jun 2011)
New Revision: 72552
URL: http://svn.boost.org/trac/boost/changeset/72552
Log:
Conversion: Added wrappers for convertible from/to and assignable_to
Added:
sandbox/conversion/boost/conversion/assignable_to.hpp (contents, props changed)
sandbox/conversion/boost/conversion/convertible_from.hpp (contents, props changed)
sandbox/conversion/boost/conversion/convertible_to.hpp (contents, props changed)
Text files modified:
sandbox/conversion/boost/conversion/ca_wrapper.hpp | 3 ++-
sandbox/conversion/boost/conversion/include.hpp | 4 +++-
sandbox/conversion/boost/conversion/type_traits/is_extrinsic_convertible.hpp | 16 ++++++++--------
3 files changed, 13 insertions(+), 10 deletions(-)
Added: sandbox/conversion/boost/conversion/assignable_to.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/assignable_to.hpp 2011-06-12 08:49:26 EDT (Sun, 12 Jun 2011)
@@ -0,0 +1,98 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009. 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
+ Defines the free function @c mca.
+ */
+#ifndef BOOST_CONVERSION_ASSIGNABLE_TO_HPP
+#define BOOST_CONVERSION_ASSIGNABLE_TO_HPP
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
+
+namespace boost {
+ namespace conversion {
+
+ //! wrapper providing assignment from extrinsic assignable to @c Target.
+
+ template <typename Target>
+ class assignable_to {
+ public:
+ Target& ref_;
+
+ //! default copy constructor
+ //! @NoThrow.
+ //assignable_to(assignable_to const& r) : ref_(r.ref_) { }
+
+ //! constructor from a reference
+ //! @NoThrow.
+ assignable_to(Target& r) : ref_(r) {}
+
+ //! Implicit conversion to @c U.
+ //! @Effects Forwards the conversion from the reference using @c conver_to.
+ //! @Returns @c *this
+ //! @Throws Whatever @c convert_to throws.
+ template <typename U>
+ operator U()
+ {
+ return boost::conversion::convert_to<U>(ref_);
+ }
+
+ //! Assignment.
+ //!
+ //! @Effects Forwards the assignment to the reference.
+ //! @Returns @c *this
+ //! @Throws Whatever @c Target assignment can throws.
+ assignable_to& operator =(assignable_to<Target> const& u)
+ {
+ ref_ = u.ref_;
+ return *this;
+ }
+
+ //! Assignment from a converter assigner wrapping a type U convertible to Target.
+ //!
+ //! @Effects Forwards the assignment to the reference using assign_to.
+ //! @Returns @c *this
+ //! @Throws Whatever @c assign_to throws.
+ template <typename U>
+ assignable_to& operator =(assignable_to<U> const& u)
+ {
+ boost::conversion::assign_to(ref_, u.ref_);
+ return *this;
+ }
+
+ //! Assignment from a type Source assignable to Target.
+ //!
+ //! @Effects Forwards the assignment to the reference using assign_to
+ //! @Returns @c *this
+ //! @Throws Whatever @c assign_to throws.
+ template <typename Source>
+ assignable_to& operator =(Source const& u)
+ {
+ boost::conversion::assign_to(ref_, u);
+ return *this;
+ }
+ };
+ //! makes an assignable to @c Target.
+
+ //! The result is able to transform conversion by convert_to calls and assignments by assign_to calls.
+ //! @NoThrow.
+ template <typename Target>
+ assignable_to<Target> mat(Target& r)
+ {
+ return assignable_to<Target>(r);
+ }
+ }
+}
+
+#endif
+
Modified: sandbox/conversion/boost/conversion/ca_wrapper.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/ca_wrapper.hpp (original)
+++ sandbox/conversion/boost/conversion/ca_wrapper.hpp 2011-06-12 08:49:26 EDT (Sun, 12 Jun 2011)
@@ -28,6 +28,7 @@
class ca_wrapper {
public:
T& ref_;
+
//! copy constructor
//! @NoThrow.
ca_wrapper(ca_wrapper const& r) : ref_(r.ref_) { }
@@ -41,7 +42,7 @@
//! @Returns @c *this
//! @Throws Whatever @c convert_to throws.
template <typename U>
- operator U() {
+ operator U() const {
return boost::conversion::convert_to<U>(ref_);
}
Added: sandbox/conversion/boost/conversion/convertible_from.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/convertible_from.hpp 2011-06-12 08:49:26 EDT (Sun, 12 Jun 2011)
@@ -0,0 +1,59 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009. 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
+ Defines the free function @c mca.
+ */
+#ifndef BOOST_CONVERSION_CONVERTIBLE_FROM_HPP
+#define BOOST_CONVERSION_CONVERTIBLE_FROM_HPP
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
+
+namespace boost {
+ namespace conversion {
+
+ //! wrapper providing implicit conversion operation to @c Target.
+
+ template <typename Source>
+ class convertible_from {
+ Source val_;
+ public:
+
+ //! @brief constructor from a @c Source
+ //! @Throws Whatever the @c Source copy constructor could throw.
+ convertible_from(Source source) : val_(source) {}
+
+ //! @brief Implicit conversion to @c Target.
+ //! @Effects Forwards the conversion from the reference using @c conver_to.
+ //! @Returns the conversion using @c conver_to
+ //! @Throws Whatever extrinsic conversion from @c Source to @c Target could throw.
+ template <typename Target>
+ operator Target() const
+ {
+ return conversion::convert_to<Target>(val_);
+ }
+
+ };
+ //! @brief makes a convertible from @c Source.
+ //! The result provides implicitly conversion to any type which is extrinsic convertible from @c Source.
+ //! @NoThrow.
+ template <typename Source>
+ convertible_from<Source> mcf(Source s)
+ {
+ return convertible_from<Source>(s);
+ }
+ }
+}
+
+#endif
+
Added: sandbox/conversion/boost/conversion/convertible_to.hpp
==============================================================================
--- (empty file)
+++ sandbox/conversion/boost/conversion/convertible_to.hpp 2011-06-12 08:49:26 EDT (Sun, 12 Jun 2011)
@@ -0,0 +1,60 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2009. 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
+ Defines the free function @c mca.
+ */
+#ifndef BOOST_CONVERSION_CONVERTIBLE_TO_HPP
+#define BOOST_CONVERSION_CONVERTIBLE_TO_HPP
+
+#include <boost/conversion/convert_to.hpp>
+#include <boost/conversion/assign_to.hpp>
+
+namespace boost {
+ namespace conversion {
+
+ //! wrapper providing implicit conversion operation to @c Target.
+
+ template <typename Target>
+ class convertible_to {
+ Target val_;
+ public:
+
+ //! constructor from a extrinsic implicitly convertible to @c Target.
+ //! @Effects Store the extrinsic conversion from @c source to @ Target.
+ //! @Throws Whatever extrinsic implicit conversion from @c source to @c Target could throw.
+ template <typename Source>
+ convertible_to(Source const& source)
+ : val_(boost::conversion::convert_to<Target>(source))
+ {}
+
+ //! Implicit conversion to @c Target.
+ //! @Returns @c val_
+ //! @Throws Whatever @c target copy constructor could throw.
+ operator Target() const
+ {
+ return val_;
+ }
+ //! explicit conversion to @c Target.
+ //! @Returns @c val_
+ //! @Throws Whatever @c target copy constructor could throw.
+ Target get() const
+ {
+ return val_;
+ }
+
+ };
+ }
+}
+
+#endif
+
Modified: sandbox/conversion/boost/conversion/include.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/include.hpp (original)
+++ sandbox/conversion/boost/conversion/include.hpp 2011-06-12 08:49:26 EDT (Sun, 12 Jun 2011)
@@ -21,7 +21,9 @@
#include <boost/conversion/assign_to.hpp>
#include <boost/conversion/convert_to_via.hpp>
#include <boost/conversion/ca_wrapper.hpp>
-#include <boost/conversion/pack.hpp>
+#include <boost/conversion/convertible_to.hpp>
+#include <boost/conversion/convertible_from.hpp>
+#include <boost/conversion/assignable_to.hpp>
#include <boost/conversion/try_convert_to.hpp>
#include <boost/conversion/convert_to_or_fallback.hpp>
#include <boost/conversion/try_assign_to.hpp>
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-12 08:49:26 EDT (Sun, 12 Jun 2011)
@@ -25,14 +25,14 @@
struct is_extrinsic_convertible : conversion::converter<Target, Source> {};
template <class T>
struct is_extrinsic_convertible<fusion::void_,T> : false_type {};
- template <>
- struct is_extrinsic_convertible<void, void> : true_type {};
- template <>
- struct is_extrinsic_convertible<const void,void> : true_type {};
- template <>
- struct is_extrinsic_convertible<void, const void> : true_type {};
- template <>
- struct is_extrinsic_convertible<const void, const void> : true_type {};
+// template <>
+// struct is_extrinsic_convertible<void, void> : true_type {};
+// template <>
+// struct is_extrinsic_convertible<const void,void> : true_type {};
+// template <>
+// struct is_extrinsic_convertible<void, const void> : true_type {};
+// template <>
+// struct is_extrinsic_convertible<const void, const void> : 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