diff --git a/include/boost/fusion/iterator/iterator_facade.hpp b/include/boost/fusion/iterator/iterator_facade.hpp index a7250427..dd02e31c 100644 --- a/include/boost/fusion/iterator/iterator_facade.hpp +++ b/include/boost/fusion/iterator/iterator_facade.hpp @@ -9,7 +9,9 @@ #define FUSION_ITERATOR_FACADE_09252006_1011 #include +#include #include +#include namespace boost { namespace fusion { @@ -22,6 +24,7 @@ namespace boost { namespace fusion typedef Derived derived_type; typedef Category category; + // default implementation template struct equal_to // default implementation : is_same< @@ -29,6 +32,18 @@ namespace boost { namespace fusion , typename I2::derived_type > {}; + + // default implementation + template + struct advance : + mpl::if_c< + (N::value > 0) + , advance_detail::forward + , advance_detail::backward + >::type + { + BOOST_MPL_ASSERT_NOT((traits::is_random_access)); + }; }; }} diff --git a/include/boost/fusion/sequence/adapted/variant/variant_iterator.hpp b/include/boost/fusion/sequence/adapted/variant/variant_iterator.hpp index edf3c096..e3817d32 100644 --- a/include/boost/fusion/sequence/adapted/variant/variant_iterator.hpp +++ b/include/boost/fusion/sequence/adapted/variant/variant_iterator.hpp @@ -77,14 +77,20 @@ namespace boost { namespace fusion { typename add_const::type>, typename mpl::deref >::type + value_type; + + typedef typename + add_reference::type type; static type call(Iterator const & it) { typedef typename mpl::deref::type type; - type* result = get(&it.var_); - return result ? *result : type(); + if (type* result = get(&it.var_)) + return *result; + it.var_ = type(); // prime the variant + return *boost::get(&it.var_); // no-throw! } }; };