Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72542 - in sandbox/conversion/boost/conversion: . boost type_traits
From: vicente.botet_at_[hidden]
Date: 2011-06-11 05:54:14


Author: viboes
Date: 2011-06-11 05:54:12 EDT (Sat, 11 Jun 2011)
New Revision: 72542
URL: http://svn.boost.org/trac/boost/changeset/72542

Log:
Conversion: Updated comments
Text files modified:
   sandbox/conversion/boost/conversion/assign_to.hpp | 42 +++++++++++++++-------
   sandbox/conversion/boost/conversion/boost/interval.hpp | 2
   sandbox/conversion/boost/conversion/convert_to.hpp | 38 +++++++++++---------
   sandbox/conversion/boost/conversion/try_assign_to.hpp | 31 ++++++++++------
   sandbox/conversion/boost/conversion/try_convert_to.hpp | 24 +++++++-----
   sandbox/conversion/boost/conversion/type_traits/is_constructible.hpp | 74 ++++++++++++++++++++++++++++++++++++++++
   6 files changed, 156 insertions(+), 55 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-11 05:54:12 EDT (Sat, 11 Jun 2011)
@@ -13,10 +13,10 @@
  Defines the free function @c assign_to and its customization point @c assigner.
 
 The function @c assign_to assigns the @c from parameter to the @c to parameter.
-The default implementation of the @c assigner uses the @c convert_to to convert the source to the target and
-uses the copy assignment of the @c Target class.
- */
 
+ */
+#ifndef BOOST_CONVERSION_ASSIGN_TO_HPP
+#define BOOST_CONVERSION_ASSIGN_TO_HPP
 #if defined(BOOST_CONVERSION_DOUBLE_CP)
 /**
 A user adapting another type could need to specialize the @c assign_to free function if the default behavior is not satisfactory.
@@ -28,8 +28,7 @@
  */
 #endif
 
-#ifndef BOOST_CONVERSION_ASSIGN_TO_HPP
-#define BOOST_CONVERSION_ASSIGN_TO_HPP
+
 
 #include <cstddef> //for std::size_t
 #include <boost/conversion/convert_to.hpp>
@@ -43,8 +42,11 @@
 namespace boost {
   namespace conversion {
 
-#if defined(BOOST_CONVERSION_ENABLE_CND)
+#if defined(BOOST_CONVERSION_ENABLE_CND) || defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
 
+ /**
+ * States the default assigner condition used when no constraint is associated to the @c Target and @c Source parameters.
+ */
     template < typename Target, typename Source>
     struct default_assigner_condition
             : integral_constant<bool,
@@ -55,14 +57,21 @@
     {};
 #endif
 
- //! Customization point for @assign_to.
+ //! Customization point for @c assign_to.
     //! @tparam Target target type of the conversion.
     //! @tparam Source source type of the conversion.
     //! @tparam Enable A dummy template parameter that can be used for SFINAE.
 
-#if defined(BOOST_CONVERSION_ENABLE_CND)
+#if defined(BOOST_CONVERSION_ENABLE_CND) || defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
     template < typename Target, typename Source, class Enable = void>
     struct assigner : false_type {};
+
+
+
+ /**
+ * Specialization when @c Target is not assignable from @c Source, but @c Target is copy constructible and @c Source is extrinsic convertible to @c Target.
+ * @Requires @c Target must be CopyAssinable and @c @c Source must be extrinsic convertible to @c Target.
+ */
     template < typename Target, typename Source>
     struct assigner<Target, Source
             , typename enable_if_c<
@@ -76,7 +85,6 @@
     struct assigner
 #endif
     {
- //! @Requires @c Target must be CopyAssinable and @c ::boost::conversion::convert_to<Target>(from) must be well formed.
       //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator.
       //! @Throws Whatever the underlying assignment operator of the @c Target class throws.
       Target& operator()(Target& to, const Source& from)
@@ -85,13 +93,16 @@
         return to;
       }
     };
-#if defined(BOOST_CONVERSION_ENABLE_CND)
+#if defined(BOOST_CONVERSION_ENABLE_CND) || defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+ /**
+ * Specialization when @c Target is assignable from @c Source.
+ * @Requires @c Target must be Assinable from Source.
+ */
     template < typename Target, typename Source>
     struct assigner<Target,Source
             , typename enable_if<is_assignable<Target, Source> >::type
> : true_type
     {
- //! @Requires @c Target must be Assinable from Source.
       //! @Effects Assigns the @c from parameter to the @c to parameter.
       //! @Throws Whatever the underlying assignment operator of the @c Target class throws.
       Target& operator()(Target& to, const Source& from)
@@ -101,10 +112,12 @@
       }
     };
 #endif
+
     //! partial specialization for c-array types.
+ //! @Requires @c Target must be CopyAssinable and @c @c Source must be extrinsic convertible to @c Target.
     template < typename Target, typename Source, std::size_t N >
     struct assigner<Target[N],Source[N]
-#if defined(BOOST_CONVERSION_ENABLE_CND)
+#if defined(BOOST_CONVERSION_ENABLE_CND) || defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
                    , typename enable_if_c<
                          is_copy_assignable<Target>::value
                          && is_extrinsic_convertible<Source,Target>::value
@@ -126,8 +139,9 @@
       }
     };
 
-#if defined(BOOST_CONVERSION_ENABLE_CND)
+#if defined(BOOST_CONVERSION_ENABLE_CND) || defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
     //! partial specialization for c-array types.
+ //! @Requires @c Target must be Assinable from @c Source.
     template < typename Target, typename Source, std::size_t N >
     struct assigner<Target[N],Source[N]
                    , typename enable_if_c<
@@ -190,7 +204,7 @@
     //! @Param{to,target of the conversion}
     //! @Param{from,source of the conversion}
 
- //! @Effects The ones of the assigner customization point.
+ //! @Effects The ones of the assigner customization point.
     //! @Throws Whatever the assigner customization point throws.
 
     template <typename Target, typename Source>

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-11 05:54:12 EDT (Sat, 11 Jun 2011)
@@ -9,7 +9,7 @@
 //////////////////////////////////////////////////////////////////////////////
 
 /*!
- @ile
+ @file
  @brief
  Include this file when using conversions between @c boost::numeric::interval<> of convertible types.
  */

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-11 05:54:12 EDT (Sat, 11 Jun 2011)
@@ -12,11 +12,10 @@
  * @brief Defines the free function @c convert_to and its customization point @c converter.
  *
  * The @c convert_to function converts the @c from parameter to a @c Target type.
- * The default implementation of @ converter applies the conversion @c Target operator of the @c Source class or
- * the copy constructor of the @c Target class.
- * Of course if both exist the conversion is ambiguous.
  *
  */
+#ifndef BOOST_CONVERSION_CONVERT_TO_HPP
+#define BOOST_CONVERSION_CONVERT_TO_HPP
 #if defined(BOOST_CONVERSION_DOUBLE_CP)
 /**
  * A user adapting another type could need to overload the @c convert_to free function
@@ -31,8 +30,7 @@
  */
 #endif
 
-#ifndef BOOST_CONVERSION_CONVERT_TO_HPP
-#define BOOST_CONVERSION_CONVERT_TO_HPP
+
 
 #include <boost/config.hpp>
 #if ! defined(BOOST_NO_DECLTYPE)
@@ -40,13 +38,15 @@
 #define BOOST_CONVERSION_ENABLE_CND
 #endif
 #endif
+#if defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
+#define BOOST_CONVERSION_ENABLE_CND
+#endif
 
 #include <boost/utility/enable_if.hpp>
 #include <boost/type_traits/integral_constant.hpp>
 #if defined(BOOST_CONVERSION_ENABLE_CND)
 #include <boost/conversion/type_traits/is_explicitly_convertible.hpp>
 #endif
-
 namespace boost {
 
   namespace conversion {
@@ -74,38 +74,42 @@
     template <typename T, typename Enabled=void>
     struct enable_functor : false_type {};
 
- //! Customization point for @convert_to.
- //! @tparam Target target type of the conversion.
- //! @tparam Source source type of the conversion.
- //! @tparam Enable A dummy template parameter that can be used for SFINAE.
 
 #if defined(BOOST_CONVERSION_ENABLE_CND)
 
+ /**
+ * States the default converter condition used when no constraint is associated to the @c Target and @c Source parameters.
+ */
     template < typename Target, typename Source>
     struct default_converter_condition
- : integral_constant<bool,
- is_explicitly_convertible<Source,Target>::value
+ : is_explicitly_convertible<Source,Target>
>
     {};
 #endif
 
+ //! Customization point for @c convert_to.
+ //! @tparam Target target type of the conversion.
+ //! @tparam Source source type of the conversion.
+ //! @tparam Enable A dummy template parameter that can be used for SFINAE.
 #if defined(BOOST_CONVERSION_ENABLE_CND)
     template < typename Target, typename Source, class Enable = void >
     struct converter : false_type {};
+
+ //! Specialization for @c converter when @c is_explicitly_convertible<Source,Target>.
+ //! @Requires @c is_explicitly_convertible<Source,Target>
     template < typename Target, typename Source >
     struct converter<Target, Source
+#if !defined(BOOST_CONVERSION_DOXYGEN_INVOKED)
               , typename enable_if<is_explicitly_convertible<Source,Target> >::type
+#endif
> : 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 : true_type
 #endif
     {
- //! @Requires @c Target must be CopyConstructible from @c Source or @c Source convertible to @c Target
- //! @Effects Converts the @c from parameter to an instance of the @c Target type, using by default the conversion operator or copy constructor.
- //! @Throws Whatever the underlying conversion @c Target operator of the @c Source class or the copy constructor of the @c Target class throws.
+ //! @Effects Converts the @c from parameter to an instance of the @c Target type, using the conversion operator or copy constructor.
+ //! @Throws Whatever the underlying conversion @c Target operator of the @c Source class throws.
       Target operator()(const Source& val)
       {
         return Target((val));

Modified: sandbox/conversion/boost/conversion/try_assign_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/try_assign_to.hpp (original)
+++ sandbox/conversion/boost/conversion/try_assign_to.hpp 2011-06-11 05:54:12 EDT (Sat, 11 Jun 2011)
@@ -10,12 +10,19 @@
 /*!
  @file
  @brief
- Defines the free function @c try_assign_to.
+ Defines the free function @c try_assign_to and its customization point @c try_assigner.
 
-The function @c try_assign_to assigns the @c from parameter to the @c to parameter. Return @c true if assignation done and @c false otherwise.
-The default implementation applies the the assignment operator of the @c Target class.
-A user adapting another type could need to specialize the @c try_assign_to free function if the default behavior is not satisfactory ot if it can improve the performances
+The function @c try_assign_to assigns the @c from parameter to the @c to parameter. Return @c true if assignment done and @c false otherwise.
 
+
+ */
+
+#ifndef BOOST_CONVERSION_TRY_ASSIGN_TO_HPP
+#define BOOST_CONVERSION_TRY_ASSIGN_TO_HPP
+
+#if defined(BOOST_CONVERSION_DOUBLE_CP)
+
+/**
 The user can add the @c try_assign_to overloading on the namespace of the Source or Target classes.
 But sometimes as it is the case for the standard classes, we can not add new functions on the std namespace,
 so we need a different technique.
@@ -25,11 +32,8 @@
 instead of calling directly to the @c try_assign_to member function, @c try_assign_to calls to the static operation apply
 on a class with the same name in the namespace @c overload_workaround.
 Thus the user can specialize partially this class.
-
- */
-
-#ifndef BOOST_CONVERSION_TRY_ASSIGN_TO_HPP
-#define BOOST_CONVERSION_TRY_ASSIGN_TO_HPP
+*/
+#endif
 
 #include <cstddef> //for std::size_t
 #include <boost/conversion/convert_to.hpp>
@@ -37,7 +41,7 @@
 
 namespace boost {
   namespace conversion {
- //! Customization point for @try_assign_to.
+ //! Customization point for @c try_assign_to.
     //! @tparam Target target type of the conversion.
     //! @tparam Source source type of the conversion.
     //! @tparam Enable A dummy template parameter that can be used for SFINAE.
@@ -64,8 +68,11 @@
         }
       }
     };
- template < typename Target, typename Source, std::size_t N >
- struct try_assigner<Target[N],Source[N]>
+
+ //! specialization for c-arrays
+ //!
+ template < typename Target, typename Source, std::size_t N, class Enable >
+ struct try_assigner<Target[N],Source[N],Enable>
     {
       //! @Effects Converts the @c from parameter to the @c to parameter, using by default the assignment operator on each vector element.
       //! @NoThrow

Modified: sandbox/conversion/boost/conversion/try_convert_to.hpp
==============================================================================
--- sandbox/conversion/boost/conversion/try_convert_to.hpp (original)
+++ sandbox/conversion/boost/conversion/try_convert_to.hpp 2011-06-11 05:54:12 EDT (Sat, 11 Jun 2011)
@@ -10,14 +10,19 @@
 /*!
  @file
  @brief
- Defines the free function @c try_convert_to.
+ Defines the free function @c try_convert_to and its customization point @c try_converter.
 
  The @c try_convert_to function converts the @c from parameter to a @c Target type and returns an optional<Target>, uninitialized if conversion fails.
  
- The default implementation applies the conversion @c Target operator of the @c Source class or
- the copy constructor of the @c Target class on a try-catch block and returns optional with the converted value if succeeds and an uninitialized optional otherwise.
- Of course if both exist the conversion is ambiguous.
- A user adapting specific types could need to specialize the @c try_convert_to free function if the default behavior is not satisfactory or if the specialization can perform better.
+
+ */
+
+#ifndef BOOST_CONVERSION_TRY_CONVERT_TO_HPP
+#define BOOST_CONVERSION_TRY_CONVERT_TO_HPP
+
+#if defined(BOOST_CONVERSION_DOUBLE_CP)
+/**
+ * A user adapting specific types could need to specialize the @c try_convert_to free function if the default behavior is not satisfactory or if the specialization can perform better.
 
  * A user adapting another type could need to overload the @c try_convert_to free function
  * if the default behavior is not satisfactory.
@@ -27,18 +32,15 @@
  * But sometimes, as it is the case for the standard classes,
  * we can not add new functions on the @c std namespace, so we need a different technique.
  * In this case the user can partially specialize the @c boost::conversion::overload_workaround::try_convert_to struct.
-
- */
-
-#ifndef BOOST_CONVERSION_TRY_CONVERT_TO_HPP
-#define BOOST_CONVERSION_TRY_CONVERT_TO_HPP
+*/
+#endif
 
 #include <boost/conversion/convert_to.hpp>
 #include <boost/conversion/boost/optional.hpp>
 
 namespace boost {
   namespace conversion {
- //! Customization point for @try_convert_to.
+ //! Customization point for @c try_convert_to.
     //! @tparam Target target type of the conversion.
     //! @tparam Source source type of the conversion.
     //! @tparam Enable A dummy template parameter that can be used for SFINAE.

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-11 05:54:12 EDT (Sat, 11 Jun 2011)
@@ -16,7 +16,80 @@
 #ifndef BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_HPP
 #define BOOST_CONVERSION_TT_IS_CONSTRUCTIBLE_HPP
 
+#if 0
+
+#include <boost/config.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum_binary_params.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/facilities/intercept.hpp>
+#include <cstddef>
+
+#ifndef BOOST_IS_CONSTRUCTIBLE_ARITY_MAX
+#define BOOST_IS_CONSTRUCTIBLE_ARITY_MAX 5
+#endif
+
+namespace boost
+{
+ namespace type_traits_detail
+ {
+ template<class T>
+ T declval();
+
+ typedef char true_type;
+ struct false_type { char a[2]; };
+
+ template<std::size_t N>
+ struct dummy;
+ }
+
+ template<class T, BOOST_PP_ENUM_BINARY_PARAMS(BOOST_IS_CONSTRUCTIBLE_ARITY_MAX, class A, = void BOOST_PP_INTERCEPT)>
+ struct is_constructible;
+
+#ifndef BOOST_NO_SFINAE_EXPR
+
+ #define M1(z,n,t) type_traits_detail::declval<A##n>()
 
+ #define M0(z,n,t) \
+ template<class T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
+ struct is_constructible<T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, A)> \
+ { \
+ template<class X> \
+ static type_traits_detail::true_type \
+ test(type_traits_detail::dummy<sizeof(X(BOOST_PP_ENUM(n, M1, ~)))>*); \
+ \
+ template<class X> \
+ static type_traits_detail::false_type \
+ test(...); \
+ \
+ static const bool value = sizeof(test<T>(0)) == sizeof(type_traits_detail::true_type); \
+ typedef boost::mpl::bool_<value> type; \
+ };
+
+ BOOST_PP_REPEAT(BOOST_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
+ #undef M0
+ #undef M1
+
+#else
+
+ #define M0(z,n,t) \
+ template<class T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, class A)> \
+ struct is_constructible<T BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, A)> \
+ : boost::mpl::false_ \
+ { \
+ };
+
+ BOOST_PP_REPEAT(BOOST_IS_CONSTRUCTIBLE_ARITY_MAX, M0, ~)
+ #undef M0
+
+#endif
+
+}
+
+#else
 #include <boost/utility/declval.hpp>
 #include <boost/type_traits/integral_constant.hpp>
 #include <boost/type_traits/common_type.hpp>
@@ -258,4 +331,5 @@
 
 
 #endif
+#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