Fix result_of's handling of F(void).

[SVN r37140]
This commit is contained in:
Douglas Gregor 2007-03-05 15:25:16 +00:00
parent 66514f61ff
commit 2d860e2574
2 changed files with 16 additions and 6 deletions

View File

@ -15,6 +15,8 @@
#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>
#ifndef BOOST_RESULT_OF_NUM_ARGS
# define BOOST_RESULT_OF_NUM_ARGS 10
@ -55,14 +57,21 @@ struct result_of_impl<F, FArgs, true>
typedef typename F::result_type type;
};
template<typename F, typename FArgs>
struct result_of_impl<F, FArgs, false>
: F::template result<FArgs>
{};
template<typename FArgs>
struct is_function_with_no_args : mpl::false_ {};
template<typename F>
struct result_of_impl<F, F(void), false>
: result_of_void_impl<F>
struct is_function_with_no_args<F(void)> : mpl::true_ {};
template<typename F, typename FArgs>
struct result_of_nested_result : F::template result<FArgs>
{};
template<typename F, typename FArgs>
struct result_of_impl<F, FArgs, false>
: mpl::if_<is_function_with_no_args<FArgs>,
result_of_void_impl<F>,
result_of_nested_result<F, FArgs> >::type
{};
} // end namespace detail

View File

@ -79,6 +79,7 @@ int main()
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_v(X,char)>::type, int>::value));
BOOST_STATIC_ASSERT((is_same<result_of<mem_func_ptr_cv(X,char)>::type, int>::value));
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));
return 0;
}