Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61149 - in branches/release: boost/utility boost/utility/detail libs/utility libs/utility/swap/test libs/utility/test
From: daniel_james_at_[hidden]
Date: 2010-04-08 17:59:35


Author: danieljames
Date: 2010-04-08 17:59:33 EDT (Thu, 08 Apr 2010)
New Revision: 61149
URL: http://svn.boost.org/trac/boost/changeset/61149

Log:
Revert changes to result_of. Reopens #862, #1310, #1535.

Properties modified:
   branches/release/boost/utility/ (props changed)
   branches/release/boost/utility/value_init.hpp (props changed)
   branches/release/libs/utility/ (props changed)
   branches/release/libs/utility/swap.html (props changed)
   branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
   branches/release/libs/utility/value_init.htm (props changed)
   branches/release/libs/utility/value_init_test.cpp (props changed)
Text files modified:
   branches/release/boost/utility/detail/result_of_iterate.hpp | 54 ----------------
   branches/release/boost/utility/result_of.hpp | 17 ----
   branches/release/libs/utility/test/result_of_test.cpp | 131 ++-------------------------------------
   branches/release/libs/utility/utility.htm | 8 -
   4 files changed, 16 insertions(+), 194 deletions(-)

Modified: branches/release/boost/utility/detail/result_of_iterate.hpp
==============================================================================
--- branches/release/boost/utility/detail/result_of_iterate.hpp (original)
+++ branches/release/boost/utility/detail/result_of_iterate.hpp 2010-04-08 17:59:33 EDT (Thu, 08 Apr 2010)
@@ -10,47 +10,6 @@
 # error Boost result_of - do not include this file!
 #endif
 
-#if defined(BOOST_HAS_DECLTYPE)
-
-// As of N2588, C++0x result_of only supports function call
-// expressions of the form f(x). This precludes support for member
-// function pointers, which are invoked with expressions of the form
-// o->*f(x). This implementation supports both.
-template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
-struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
- : mpl::if_<
- mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
- , detail::result_of_impl<
- typename remove_cv<F>::type,
- typename remove_cv<F>::type(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)), false
- >
- , detail::result_of_decltype_impl<
- F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))
- >
- >::type
-{};
-
-namespace detail {
-
-# define BOOST_RESULT_OF_STATIC_MEMBERS(z, n, _) \
- static T ## n t ## n; \
- /**/
-
-template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
- BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
-class result_of_decltype_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
-{
- static F f;
- BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _)
-public:
- typedef decltype(f(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),t))) type;
-};
-
-} // namespace detail
-
-#else // defined(BOOST_HAS_DECLTYPE)
-
 // CWPro8 requires an argument in a function type specialization
 #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3002)) && BOOST_PP_ITERATION() == 0
 # define BOOST_RESULT_OF_ARGS void
@@ -62,22 +21,11 @@
 template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
          BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
 struct result_of<F(BOOST_RESULT_OF_ARGS)>
- : mpl::if_<
- mpl::or_< is_pointer<F>, is_member_function_pointer<F> >
- , boost::detail::result_of_impl<
- typename remove_cv<F>::type,
- typename remove_cv<F>::type(BOOST_RESULT_OF_ARGS),
- (boost::detail::has_result_type<F>::value)>
- , boost::detail::result_of_impl<
- F,
- F(BOOST_RESULT_OF_ARGS),
- (boost::detail::has_result_type<F>::value)> >::type { };
+ : boost::detail::result_of_impl<F, F(BOOST_RESULT_OF_ARGS), (boost::detail::has_result_type<F>::value)> {};
 #endif
 
 #undef BOOST_RESULT_OF_ARGS
 
-#endif // defined(BOOST_HAS_DECLTYPE)
-
 #if BOOST_PP_ITERATION() >= 1
 
 namespace detail {

Modified: branches/release/boost/utility/result_of.hpp
==============================================================================
--- branches/release/boost/utility/result_of.hpp (original)
+++ branches/release/boost/utility/result_of.hpp 2010-04-08 17:59:33 EDT (Thu, 08 Apr 2010)
@@ -10,18 +10,13 @@
 #define BOOST_RESULT_OF_HPP
 
 #include <boost/config.hpp>
-#include <boost/preprocessor/iteration/iterate.hpp>
-#include <boost/preprocessor/punctuation/comma_if.hpp>
-#include <boost/preprocessor/repetition/enum_params.hpp>
-#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
+#include <boost/type_traits/ice.hpp>
+#include <boost/type.hpp>
+#include <boost/preprocessor.hpp>
 #include <boost/detail/workaround.hpp>
 #include <boost/mpl/has_xxx.hpp>
 #include <boost/mpl/if.hpp>
 #include <boost/mpl/bool.hpp>
-#include <boost/mpl/or.hpp>
-#include <boost/type_traits/is_pointer.hpp>
-#include <boost/type_traits/is_member_function_pointer.hpp>
-#include <boost/type_traits/remove_cv.hpp>
 
 #ifndef BOOST_RESULT_OF_NUM_ARGS
 # define BOOST_RESULT_OF_NUM_ARGS 10
@@ -37,7 +32,6 @@
 BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
 
 template<typename F, typename FArgs, bool HasResultType> struct result_of_impl;
-template<typename F> struct result_of_decltype_impl;
 
 template<typename F>
 struct result_of_void_impl
@@ -57,11 +51,6 @@
   typedef R type;
 };
 
-// Determine the return type of a function pointer or pointer to member.
-template<typename F, typename FArgs>
-struct result_of_pointer
- : result_of_impl<typename remove_cv<F>::type, FArgs, false> { };
-
 template<typename F, typename FArgs>
 struct result_of_impl<F, FArgs, true>
 {

Modified: branches/release/libs/utility/test/result_of_test.cpp
==============================================================================
--- branches/release/libs/utility/test/result_of_test.cpp (original)
+++ branches/release/libs/utility/test/result_of_test.cpp 2010-04-08 17:59:33 EDT (Thu, 08 Apr 2010)
@@ -11,101 +11,35 @@
 #include <boost/static_assert.hpp>
 #include <boost/type_traits/is_same.hpp>
 
-struct int_result_type
-{
- typedef int result_type;
- result_type operator()(float);
-};
+struct int_result_type { typedef int result_type; };
 
 struct int_result_of
 {
   template<typename F> struct result { typedef int type; };
- result<int_result_of(double)>::type operator()(double);
- result<const int_result_of(double)>::type operator()(double) const;
- result<int_result_of()>::type operator()();
- result<volatile int_result_of()>::type operator()() volatile;
 };
 
-struct int_result_type_and_float_result_of_and_char_return
+struct int_result_type_and_float_result_of
 {
   typedef int result_type;
   template<typename F> struct result { typedef float type; };
- char operator()(char);
 };
 
 template<typename T>
-struct int_result_type_template
-{
- typedef int result_type;
- result_type operator()(float);
-};
+struct int_result_type_template { typedef int result_type; };
 
 template<typename T>
 struct int_result_of_template
 {
   template<typename F> struct result;
   template<typename This, typename That> struct result<This(That)> { typedef int type; };
- typename result<int_result_of_template<T>(double)>::type operator()(double);
- typename result<const int_result_of_template<T>(double)>::type operator()(double) const;
- typename result<int_result_of_template<T>(double)>::type operator()();
- typename result<volatile int_result_of_template<T>(double)>::type operator()() volatile;
 };
 
 template<typename T>
-struct int_result_type_and_float_result_of_and_char_return_template
+struct int_result_type_and_float_result_of_template
 {
   typedef int result_type;
   template<typename F> struct result;
   template<typename This, typename That> struct result<This(That)> { typedef float type; };
- char operator()(char);
-};
-
-struct result_of_member_function_template
-{
- template<typename F> struct result;
-
- template<typename This, typename That> struct result<This(That)> { typedef That type; };
- template<class T> typename result<result_of_member_function_template(T)>::type operator()(T);
-
- template<typename This, typename That> struct result<const This(That)> { typedef const That type; };
- template<class T> typename result<const result_of_member_function_template(T)>::type operator()(T) const;
-
- template<typename This, typename That> struct result<volatile This(That)> { typedef volatile That type; };
- template<class T> typename result<volatile result_of_member_function_template(T)>::type operator()(T) volatile;
-
- template<typename This, typename That> struct result<const volatile This(That)> { typedef const volatile That type; };
- template<class T> typename result<const volatile result_of_member_function_template(T)>::type operator()(T) const volatile;
-
- template<typename This, typename That> struct result<This(That &, That)> { typedef That & type; };
- template<class T> typename result<result_of_member_function_template(T &, T)>::type operator()(T &, T);
-
- template<typename This, typename That> struct result<This(That const &, That)> { typedef That const & type; };
- template<class T> typename result<result_of_member_function_template(T const &, T)>::type operator()(T const &, T);
-
- template<typename This, typename That> struct result<This(That volatile &, That)> { typedef That volatile & type; };
- template<class T> typename result<result_of_member_function_template(T volatile &, T)>::type operator()(T volatile &, T);
-
- template<typename This, typename That> struct result<This(That const volatile &, That)> { typedef That const volatile & type; };
- template<class T> typename result<result_of_member_function_template(T const volatile &, T)>::type operator()(T const volatile &, T);
-};
-
-struct no_result_type_or_result_of
-{
- int operator()(double);
- short operator()(double) const;
- unsigned int operator()();
- unsigned short operator()() volatile;
- const unsigned short operator()() const volatile;
-};
-
-template<typename T>
-struct no_result_type_or_result_of_template
-{
- int operator()(double);
- short operator()(double) const;
- unsigned int operator()();
- unsigned short operator()() volatile;
- const unsigned short operator()() const volatile;
 };
 
 struct X {};
@@ -126,37 +60,16 @@
 
   BOOST_STATIC_ASSERT((is_same<result_of<int_result_type(float)>::type, int>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(double)>::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of(double)>::type, int>::value));
+ BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
+ BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of(char)>::type, int>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_template<void>(float)>::type, int>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(double)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value));
-
- // Prior to decltype, result_of could not deduce the return type
- // nullary function objects unless they exposed a result_type.
-#if defined(BOOST_HAS_DECLTYPE)
- BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, int>::value));
-#else
- BOOST_STATIC_ASSERT((is_same<result_of<int_result_of(void)>::type, void>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of(void)>::type, void>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<int_result_of_template<void>(void)>::type, void>::value));
+ BOOST_STATIC_ASSERT((is_same<result_of<const int_result_of_template<void>(double)>::type, int>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<volatile int_result_of_template<void>(void)>::type, void>::value));
-#endif
-
- // Prior to decltype, result_of ignored a nested result<> if
- // result_type was defined. After decltype, result_of deduces the
- // actual return type of the function object, ignoring both
- // result<> and result_type.
-#if defined(BOOST_HAS_DECLTYPE)
- BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, char>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, char>::value));
-#else
- BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return(char)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_and_char_return_template<void>(char)>::type, int>::value));
-#endif
-
+ BOOST_STATIC_ASSERT((is_same<result_of<int_result_type_and_float_result_of_template<void>(char)>::type, int>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(char, float)>::type, int>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<func_ref(char, float)>::type, int>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<func_ptr_0()>::type, int>::value));
@@ -168,31 +81,5 @@
   BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_0(X)>::type, int>::value));
   BOOST_STATIC_ASSERT((is_same<result_of<func_ptr(void)>::type, int>::value));
 
- BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(double)>::type, double>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<const result_of_member_function_template(double)>::type, const double>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<volatile result_of_member_function_template(double)>::type, volatile double>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<const volatile result_of_member_function_template(double)>::type, const volatile double>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int &, int)>::type, int &>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int const &, int)>::type, int const &>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int volatile &, int)>::type, int volatile &>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<result_of_member_function_template(int const volatile &, int)>::type, int const volatile &>::value));
-
- typedef int (*pf_t)(int);
- BOOST_STATIC_ASSERT((is_same<result_of<pf_t(int)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<pf_t const(int)>::type,int>::value));
-
-#if defined(BOOST_HAS_DECLTYPE)
- BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(double)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(void)>::type, unsigned int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of(double)>::type, short>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of(void)>::type, unsigned short>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of(void)>::type, const unsigned short>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(double)>::type, int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(void)>::type, unsigned int>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<const no_result_type_or_result_of_template<void>(double)>::type, short>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<volatile no_result_type_or_result_of_template<void>(void)>::type, unsigned short>::value));
- BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of_template<void>(void)>::type, const unsigned short>::value));
-#endif
-
   return 0;
 }

Modified: branches/release/libs/utility/utility.htm
==============================================================================
--- branches/release/libs/utility/utility.htm (original)
+++ branches/release/libs/utility/utility.htm 2010-04-08 17:59:33 EDT (Thu, 08 Apr 2010)
@@ -154,13 +154,11 @@
                 ...,t<em>N</em>)</code>. The implementation permits
                 the type <code>F</code> to be a function pointer,
                 function reference, member function pointer, or class
- type.</p> <p>If your compiler does not support
- <code>decltype</code>, then when <code>F</code> is a
- class type with a member type <code>result_type</code>,
+ type. When <code>F</code> is a class type with a
+ member type <code>result_type</code>,
                 <code>result_of&lt;F(T1, T2, ...,
                 T<em>N</em>)&gt;</code> is
- <code>F::result_type</code>. When <code>F</code>
- does not contain <code>result_type</code>,
+ <code>F::result_type</code>. Otherwise,
                 <code>result_of&lt;F(T1, T2, ...,
                 T<em>N</em>)&gt;</code> is <code>F::result&lt;F(T1,
                 T2, ..., T<em>N</em>)&gt;::type</code> when


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