Ticket #7343: ean_result_of_sfinae.patch

File ean_result_of_sfinae.patch, 2.4 KB (added by Eric Niebler, 10 years ago)

simpler patch, tested with clang-trunk

  • boost/utility/detail/result_of_iterate.hpp

     
    6060
    6161template<typename F BOOST_PP_COMMA_IF(BOOST_PP_ITERATION())
    6262         BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),typename T)>
    63 struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T))>
     63struct cpp0x_result_of_impl<F(BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(),T)),
     64         typename result_of_always_void<decltype(
     65           boost::declval<F>()(
     66             BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PP_ITERATION(), declval<T, >() BOOST_PP_INTERCEPT)
     67           )
     68         )>::type>
    6469{
    6570  typedef decltype(
    6671    boost::declval<F>()(
  • boost/utility/result_of.hpp

     
    5656#if !defined(BOOST_NO_SFINAE) && !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
    5757namespace detail {
    5858
     59template<typename T>
     60struct result_of_always_void
     61{
     62    typedef void type;
     63};
     64
    5965BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
    6066
    6167template<typename F, typename FArgs, bool HasResultType> struct tr1_result_of_impl;
    62 template<typename F> struct cpp0x_result_of_impl;
     68template<typename F, typename Enable = void> struct cpp0x_result_of_impl {};
    6369
    6470template<typename F>
    6571struct result_of_void_impl
  • libs/utility/test/result_of_test.cpp

     
    129129#endif
    130130};
    131131
     132// sfinae_tests are derived from example code from Joel de Guzman,
     133// which demonstrated the interaction between result_of and SFINAE.
     134template <typename F, typename Arg>
     135typename boost::result_of<F(Arg const&)>::type
     136sfinae_test(F f, Arg const& arg)
     137{
     138    return f(arg);
     139}
     140
     141template <typename F, typename Arg>
     142typename boost::result_of<F(Arg&)>::type
     143sfinae_test(F f, Arg& arg)
     144{
     145    return f(arg);
     146}
     147
     148int sfinae_test_f(int& i)
     149{
     150    return i;
     151}
     152
    132153struct X {};
    133154
    134155int main()
     
    268289#endif
    269290#endif
    270291
     292#if defined(BOOST_RESULT_OF_USE_DECLTYPE)
     293  int i = 123;
     294  sfinae_test(sfinae_test_f, i);
     295#endif // defined(BOOST_RESULT_OF_USE_DECLTYPE)
     296
    271297  return 0;
    272298}