diff --git a/include/boost/fusion/container/vector/detail/preprocessed/vvector10.hpp b/include/boost/fusion/container/vector/detail/preprocessed/vvector10.hpp index a566278a..8e6f1f68 100644 --- a/include/boost/fusion/container/vector/detail/preprocessed/vvector10.hpp +++ b/include/boost/fusion/container/vector/detail/preprocessed/vvector10.hpp @@ -36,7 +36,7 @@ namespace boost { namespace fusion : vec(rhs.vec) {} template vector(Sequence const& rhs) - : vec(rhs) {} + : vec(BOOST_FUSION_VECTOR_COPY_INIT()) {} @@ -116,6 +116,7 @@ namespace boost { namespace fusion return vec.at_impl(mpl::int_()); } private: + BOOST_FUSION_VECTOR_CTOR_HELPER() vector_n vec; }; }} diff --git a/include/boost/fusion/container/vector/detail/preprocessed/vvector20.hpp b/include/boost/fusion/container/vector/detail/preprocessed/vvector20.hpp index 378ea978..bc04fefe 100644 --- a/include/boost/fusion/container/vector/detail/preprocessed/vvector20.hpp +++ b/include/boost/fusion/container/vector/detail/preprocessed/vvector20.hpp @@ -36,7 +36,7 @@ namespace boost { namespace fusion : vec(rhs.vec) {} template vector(Sequence const& rhs) - : vec(rhs) {} + : vec(BOOST_FUSION_VECTOR_COPY_INIT()) {} @@ -136,6 +136,7 @@ namespace boost { namespace fusion return vec.at_impl(mpl::int_()); } private: + BOOST_FUSION_VECTOR_CTOR_HELPER() vector_n vec; }; }} diff --git a/include/boost/fusion/container/vector/detail/preprocessed/vvector30.hpp b/include/boost/fusion/container/vector/detail/preprocessed/vvector30.hpp index f49d3ef2..0841920a 100644 --- a/include/boost/fusion/container/vector/detail/preprocessed/vvector30.hpp +++ b/include/boost/fusion/container/vector/detail/preprocessed/vvector30.hpp @@ -36,7 +36,7 @@ namespace boost { namespace fusion : vec(rhs.vec) {} template vector(Sequence const& rhs) - : vec(rhs) {} + : vec(BOOST_FUSION_VECTOR_COPY_INIT()) {} @@ -156,6 +156,7 @@ namespace boost { namespace fusion return vec.at_impl(mpl::int_()); } private: + BOOST_FUSION_VECTOR_CTOR_HELPER() vector_n vec; }; }} diff --git a/include/boost/fusion/container/vector/detail/preprocessed/vvector40.hpp b/include/boost/fusion/container/vector/detail/preprocessed/vvector40.hpp index c683cba6..11d9cc7d 100644 --- a/include/boost/fusion/container/vector/detail/preprocessed/vvector40.hpp +++ b/include/boost/fusion/container/vector/detail/preprocessed/vvector40.hpp @@ -36,7 +36,7 @@ namespace boost { namespace fusion : vec(rhs.vec) {} template vector(Sequence const& rhs) - : vec(rhs) {} + : vec(BOOST_FUSION_VECTOR_COPY_INIT()) {} @@ -176,6 +176,7 @@ namespace boost { namespace fusion return vec.at_impl(mpl::int_()); } private: + BOOST_FUSION_VECTOR_CTOR_HELPER() vector_n vec; }; }} diff --git a/include/boost/fusion/container/vector/detail/preprocessed/vvector50.hpp b/include/boost/fusion/container/vector/detail/preprocessed/vvector50.hpp index 316f9d27..1ac6c6f4 100644 --- a/include/boost/fusion/container/vector/detail/preprocessed/vvector50.hpp +++ b/include/boost/fusion/container/vector/detail/preprocessed/vvector50.hpp @@ -36,7 +36,7 @@ namespace boost { namespace fusion : vec(rhs.vec) {} template vector(Sequence const& rhs) - : vec(rhs) {} + : vec(BOOST_FUSION_VECTOR_COPY_INIT()) {} @@ -196,6 +196,7 @@ namespace boost { namespace fusion return vec.at_impl(mpl::int_()); } private: + BOOST_FUSION_VECTOR_CTOR_HELPER() vector_n vec; }; }} diff --git a/include/boost/fusion/container/vector/vector.hpp b/include/boost/fusion/container/vector/vector.hpp index 5bb0b6ab..6563bc93 100644 --- a/include/boost/fusion/container/vector/vector.hpp +++ b/include/boost/fusion/container/vector/vector.hpp @@ -17,6 +17,38 @@ #include #include +#if !defined(__WAVE__) + +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1600) + +#define BOOST_FUSION_VECTOR_COPY_INIT() \ + ctor_helper(rhs, is_base_of()) \ + +#define BOOST_FUSION_VECTOR_CTOR_HELPER() \ + static vector_n const& \ + ctor_helper(vector const& rhs, mpl::true_) \ + { \ + return rhs.vec; \ + } \ + \ + template \ + static T const& \ + ctor_helper(T const& rhs, mpl::false_) \ + { \ + return rhs; \ + } + +#else + +#define BOOST_FUSION_VECTOR_COPY_INIT() \ + rhs \ + +#define BOOST_FUSION_VECTOR_CTOR_HELPER() + +#endif + +#endif // !defined(__WAVE__) + #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES) #include #else @@ -76,11 +108,7 @@ namespace boost { namespace fusion template vector(Sequence const& rhs) -#if BOOST_WORKAROUND(BOOST_MSVC, <= 1600) - : vec(ctor_helper(rhs, is_base_of())) {} -#else - : vec(rhs) {} -#endif + : vec(BOOST_FUSION_VECTOR_COPY_INIT()) {} // Expand a couple of forwarding constructors for arguments // of type (T0), (T0, T1), (T0, T1, T2) etc. Example: @@ -149,21 +177,7 @@ namespace boost { namespace fusion private: -#if BOOST_WORKAROUND(BOOST_MSVC, <= 1600) - static vector_n const& - ctor_helper(vector const& rhs, mpl::true_) - { - return rhs.vec; - } - - template - static T const& - ctor_helper(T const& rhs, mpl::false_) - { - return rhs; - } -#endif - + BOOST_FUSION_VECTOR_CTOR_HELPER() vector_n vec; }; }} diff --git a/include/boost/fusion/support/deduce_sequence.hpp b/include/boost/fusion/support/deduce_sequence.hpp index 77631b79..ce02a3cd 100644 --- a/include/boost/fusion/support/deduce_sequence.hpp +++ b/include/boost/fusion/support/deduce_sequence.hpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace boost { namespace fusion { namespace traits @@ -29,6 +30,13 @@ namespace boost { namespace fusion { namespace traits struct result< Self(T) > : fusion::traits::deduce { }; + + // never called, but needed for decltype-based result_of (C++0x) +#ifndef BOOST_NO_RVALUE_REFERENCES + template + typename result< deducer(T) >::type + operator()(T&&) const; +#endif }; } diff --git a/include/boost/fusion/view/detail/strictest_traversal.hpp b/include/boost/fusion/view/detail/strictest_traversal.hpp index 39a389c3..7b7c9760 100644 --- a/include/boost/fusion/view/detail/strictest_traversal.hpp +++ b/include/boost/fusion/view/detail/strictest_traversal.hpp @@ -8,6 +8,7 @@ #if !defined(FUSION_STRICTEST_TRAVERSAL_20060123_2101) #define FUSION_STRICTEST_TRAVERSAL_20060123_2101 +#include #include #include #include @@ -53,6 +54,13 @@ namespace boost { namespace fusion typedef typename stricter_traversal::type type; }; + + // never called, but needed for decltype-based result_of (C++0x) +#ifndef BOOST_NO_RVALUE_REFERENCES + template + typename result::type + operator()(StrictestSoFar&&, Next&&) const; +#endif }; template diff --git a/include/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp b/include/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp index d63c2b32..e5f5ed0b 100644 --- a/include/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp +++ b/include/boost/fusion/view/iterator_range/detail/segmented_iterator_range.hpp @@ -29,11 +29,21 @@ // - All other ranges point to ranges // - The front of each range in the stack (besides the // topmost) is the range above it - + namespace boost { namespace fusion { template struct iterator_range; + + namespace result_of + { + template + struct push_back; + } + + template + typename result_of::push_back::type + push_back(Sequence const& seq, T const& x); }} namespace boost { namespace fusion { namespace detail @@ -117,7 +127,7 @@ namespace boost { namespace fusion { namespace detail segment_sequence< typename result_of::push_front< rest_type const - , typename recurse::type + , typename recurse::type >::type > type; @@ -184,7 +194,7 @@ namespace boost { namespace fusion { namespace detail { return stack.cdr; } - }; + }; //auto make_segment_sequence_back(stack_end) //{ @@ -260,7 +270,7 @@ namespace boost { namespace fusion { namespace detail segment_sequence< typename result_of::push_back< rest_type const - , typename recurse::type + , typename recurse::type >::type > type; @@ -328,7 +338,7 @@ namespace boost { namespace fusion { namespace detail return stack.cdr; } }; - + //auto make_segmented_range_reduce(stack_begin, stack_end) //{ // if (size(stack_begin) == 1 && size(stack_end) == 1) @@ -373,7 +383,7 @@ namespace boost { namespace fusion { namespace detail template < typename StackBegin , typename StackEnd - , bool SameSegment = + , bool SameSegment = result_of::equal_to< typename StackBegin::car_type::begin_type , typename StackEnd::car_type::begin_type diff --git a/include/boost/fusion/view/nview/detail/nview_impl.hpp b/include/boost/fusion/view/nview/detail/nview_impl.hpp index 03aa49f4..555c34ea 100644 --- a/include/boost/fusion/view/nview/detail/nview_impl.hpp +++ b/include/boost/fusion/view/nview/detail/nview_impl.hpp @@ -1,7 +1,7 @@ /*============================================================================= Copyright (c) 2009 Hartmut Kaiser - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ @@ -27,7 +27,7 @@ namespace boost { namespace fusion { namespace result_of { template + , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(FUSION_MAX_VECTOR_SIZE, int I, INT_MAX)> struct as_nview { typedef mpl::vector_c< diff --git a/include/boost/fusion/view/nview/nview.hpp b/include/boost/fusion/view/nview/nview.hpp index 02422e0b..2355b688 100644 --- a/include/boost/fusion/view/nview/nview.hpp +++ b/include/boost/fusion/view/nview/nview.hpp @@ -23,6 +23,8 @@ #include #include +#include + namespace boost { namespace fusion { namespace detail @@ -35,12 +37,21 @@ namespace boost { namespace fusion template struct result : add_reference {}; +#ifdef BOOST_NO_RVALUE_REFERENCES template typename add_reference::type operator()(T& x) const { return x; } +#else + template + typename result::type + operator()(T&& x) const + { + return x; + } +#endif }; struct addconstref diff --git a/include/boost/fusion/view/zip_view/detail/end_impl.hpp b/include/boost/fusion/view/zip_view/detail/end_impl.hpp index b58854e3..6423a88f 100644 --- a/include/boost/fusion/view/zip_view/detail/end_impl.hpp +++ b/include/boost/fusion/view/zip_view/detail/end_impl.hpp @@ -62,7 +62,7 @@ namespace boost { namespace fusion { template typename result::type - operator()(Seq const& seq) + operator()(Seq const& seq) const { return fusion::advance(fusion::begin(seq)); } diff --git a/include/boost/fusion/view/zip_view/detail/value_at_impl.hpp b/include/boost/fusion/view/zip_view/detail/value_at_impl.hpp index 93f0979b..13e0274f 100644 --- a/include/boost/fusion/view/zip_view/detail/value_at_impl.hpp +++ b/include/boost/fusion/view/zip_view/detail/value_at_impl.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace fusion { @@ -35,6 +36,13 @@ namespace boost { namespace fusion { mpl::identity, result_of::value_at::type, N> > {}; + + // never called, but needed for decltype-based result_of (C++0x) +#ifndef BOOST_NO_RVALUE_REFERENCES + template + typename result::type + operator()(Seq&&) const; +#endif }; } diff --git a/include/boost/fusion/view/zip_view/detail/value_of_impl.hpp b/include/boost/fusion/view/zip_view/detail/value_of_impl.hpp index 45b7b962..5571155e 100644 --- a/include/boost/fusion/view/zip_view/detail/value_of_impl.hpp +++ b/include/boost/fusion/view/zip_view/detail/value_of_impl.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace fusion { @@ -34,6 +35,13 @@ namespace boost { namespace fusion mpl::identity, result_of::value_of > {}; + + // never called, but needed for decltype-based result_of (C++0x) +#ifndef BOOST_NO_RVALUE_REFERENCES + template + typename result::type + operator()(It&&) const; +#endif }; } diff --git a/include/boost/fusion/view/zip_view/zip_view.hpp b/include/boost/fusion/view/zip_view/zip_view.hpp index 6258711c..e9a0222d 100644 --- a/include/boost/fusion/view/zip_view/zip_view.hpp +++ b/include/boost/fusion/view/zip_view/zip_view.hpp @@ -37,6 +37,8 @@ #include #include +#include + namespace boost { namespace fusion { namespace detail @@ -64,6 +66,13 @@ namespace boost { namespace fusion { result_of::size, mpl::int_ >::type type; }; + + // never called, but needed for decltype-based result_of (C++0x) +#ifndef BOOST_NO_RVALUE_REFERENCES + template + typename result::type + operator()(Seq&&) const; +#endif }; struct poly_min @@ -78,6 +87,13 @@ namespace boost { namespace fusion { typedef typename remove_reference::type rhs; typedef typename mpl::min::type type; }; + + // never called, but needed for decltype-based result_of (C++0x) +#ifndef BOOST_NO_RVALUE_REFERENCES + template + typename result::type + operator()(Lhs&&, Rhs&&) const; +#endif }; template diff --git a/test/functional/invoke.cpp b/test/functional/invoke.cpp index 52740eec..f326cbd8 100644 --- a/test/functional/invoke.cpp +++ b/test/functional/invoke.cpp @@ -72,6 +72,8 @@ struct fobj int operator()(int i, object &, object_nc &) { return 10 + i; } int operator()(int i, object &, object_nc &) const { return 11 + i; } + int operator()(int i, object const &, object_nc &); + int operator()(int i, object const &, object_nc &) const; }; struct nullary_fobj diff --git a/test/functional/invoke_function_object.cpp b/test/functional/invoke_function_object.cpp index 31357aa8..7cbe6e59 100644 --- a/test/functional/invoke_function_object.cpp +++ b/test/functional/invoke_function_object.cpp @@ -75,6 +75,8 @@ struct fobj int operator()(int i, object &, object_nc &) { return 10 + i; } int operator()(int i, object &, object_nc &) const { return 11 + i; } + int operator()(int i, object const &, object_nc &); + int operator()(int i, object const &, object_nc &) const; }; struct nullary_fobj diff --git a/test/functional/unfused.cpp b/test/functional/unfused.cpp index 27a242a6..bde9b95b 100644 --- a/test/functional/unfused.cpp +++ b/test/functional/unfused.cpp @@ -71,7 +71,7 @@ void result_type_tests() typedef fusion::unfused< test_func<> > t; BOOST_TEST(( is_same< boost::result_of< t () >::type, long >::value )); - BOOST_TEST(( is_same< boost::result_of< t (int) >::type, long >::value )); + BOOST_TEST(( is_same< boost::result_of< t (int &) >::type, long >::value )); } int main() diff --git a/test/functional/unfused_typed.cpp b/test/functional/unfused_typed.cpp index 85783c86..93c35b6d 100644 --- a/test/functional/unfused_typed.cpp +++ b/test/functional/unfused_typed.cpp @@ -85,7 +85,7 @@ void result_type_tests() typedef fusion::unfused_typed< test_func<>, types0 > t0; BOOST_TEST(( is_same< boost::result_of< t0 () >::type, long >::value )); typedef fusion::unfused_typed< test_func<>, types1 > t1; - BOOST_TEST(( is_same< boost::result_of< t1 (int) >::type, long >::value )); + BOOST_TEST(( is_same< boost::result_of< t1 (long &) >::type, long >::value )); } #if defined(BOOST_MSVC) && BOOST_MSVC < 1400