Merged doc updates and fix for #5098 from trunk

[SVN r76804]
This commit is contained in:
Daniel Walker 2012-01-31 02:30:03 +00:00
parent c9d56eed6e
commit 87b3643647
4 changed files with 42 additions and 13 deletions

View File

@ -35,10 +35,7 @@ struct tr1_result_of<F(BOOST_RESULT_OF_ARGS)>
#if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE) #if !defined(BOOST_NO_DECLTYPE) && defined(BOOST_RESULT_OF_USE_DECLTYPE)
// As of N2588, C++0x result_of only supports function call // Uses declval following N3225 20.7.7.6 when F is not a pointer.
// 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()) template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))> struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
@ -56,18 +53,15 @@ struct result_of<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
namespace detail { 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()) template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)> BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
class cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))> struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
{ {
static F f; typedef decltype(
BOOST_PP_REPEAT(BOOST_PP_ITERATION(), BOOST_RESULT_OF_STATIC_MEMBERS, _) boost::declval<F>()(
public: BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), declval<T, >() BOOST_PP_INTERCEPT)
typedef decltype(f(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),t))) type; )
) type;
}; };
} // namespace detail } // namespace detail

View File

@ -13,7 +13,9 @@
#include <boost/preprocessor/iteration/iterate.hpp> #include <boost/preprocessor/iteration/iterate.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp> #include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_shifted_params.hpp> #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/detail/workaround.hpp> #include <boost/detail/workaround.hpp>
#include <boost/mpl/has_xxx.hpp> #include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/if.hpp> #include <boost/mpl/if.hpp>
@ -22,6 +24,7 @@
#include <boost/type_traits/is_pointer.hpp> #include <boost/type_traits/is_pointer.hpp>
#include <boost/type_traits/is_member_function_pointer.hpp> #include <boost/type_traits/is_member_function_pointer.hpp>
#include <boost/type_traits/remove_cv.hpp> #include <boost/type_traits/remove_cv.hpp>
#include <boost/utility/declval.hpp>
#ifndef BOOST_RESULT_OF_NUM_ARGS #ifndef BOOST_RESULT_OF_NUM_ARGS
# define BOOST_RESULT_OF_NUM_ARGS 10 # define BOOST_RESULT_OF_NUM_ARGS 10

View File

@ -98,6 +98,11 @@ struct no_result_type_or_result_of
unsigned int operator()(); unsigned int operator()();
unsigned short operator()() volatile; unsigned short operator()() volatile;
const unsigned short operator()() const volatile; const unsigned short operator()() const volatile;
#if !defined(BOOST_NO_RVALUE_REFERENCES)
short operator()(int&&);
int operator()(int&);
long operator()(int const&);
#endif
}; };
template<typename T> template<typename T>
@ -108,6 +113,11 @@ struct no_result_type_or_result_of_template
unsigned int operator()(); unsigned int operator()();
unsigned short operator()() volatile; unsigned short operator()() volatile;
const unsigned short operator()() const volatile; const unsigned short operator()() const volatile;
#if !defined(BOOST_NO_RVALUE_REFERENCES)
short operator()(int&&);
int operator()(int&);
long operator()(int const&);
#endif
}; };
struct X {}; struct X {};
@ -232,6 +242,14 @@ int main()
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<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<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)); BOOST_STATIC_ASSERT((is_same<result_of<const volatile no_result_type_or_result_of_template<void>(void)>::type, const unsigned short>::value));
#if !defined(BOOST_NO_RVALUE_REFERENCES)
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(int&&)>::type, short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(int&)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of(int const&)>::type, long>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(int&&)>::type, short>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(int&)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<no_result_type_or_result_of_template<void>(int const&)>::type, long>::value));
#endif
#endif #endif
return 0; return 0;

View File

@ -224,6 +224,20 @@ typedef boost::result_of&lt;
&gt;::type type;</pre> &gt;::type type;</pre>
</blockquote> </blockquote>
<p>In a future
release, <code>BOOST_RESULT_OF_USE_DECLTYPE</code>
may be enabled by default on compilers that
support <code>decltype</code>, so if you use the above
protocol please take care to ensure that
the <code>result_type</code>
and <code>result&lt;&gt;</code> members accurately
represent the result type. If you wish to continue to
use the protocol on compilers that
support <code>decltype</code>,
use <code>boost::tr1_result_of</code>, which is also
defined
in <code>&lt;<a href="../../boost/utility/result_of.hpp">boost/utility/result_of.hpp</a>&gt;</code>.</p>
<a name="BOOST_NO_RESULT_OF"></a> <a name="BOOST_NO_RESULT_OF"></a>
<p>This implementation of <code>result_of</code> <p>This implementation of <code>result_of</code>
requires class template partial specialization, the requires class template partial specialization, the