mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-23 09:07:26 +02:00
minor tweaks
[SVN r36016]
This commit is contained in:
@ -9,7 +9,9 @@
|
||||
#define FUSION_ITERATOR_FACADE_09252006_1011
|
||||
|
||||
#include <boost/fusion/support/iterator_base.hpp>
|
||||
#include <boost/fusion/iterator/detail/advance.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
@ -22,6 +24,7 @@ namespace boost { namespace fusion
|
||||
typedef Derived derived_type;
|
||||
typedef Category category;
|
||||
|
||||
// default implementation
|
||||
template <typename I1, typename I2>
|
||||
struct equal_to // default implementation
|
||||
: is_same<
|
||||
@ -29,6 +32,18 @@ namespace boost { namespace fusion
|
||||
, typename I2::derived_type
|
||||
>
|
||||
{};
|
||||
|
||||
// default implementation
|
||||
template <typename Iterator, typename N>
|
||||
struct advance :
|
||||
mpl::if_c<
|
||||
(N::value > 0)
|
||||
, advance_detail::forward<Iterator, N::value>
|
||||
, advance_detail::backward<Iterator, N::value>
|
||||
>::type
|
||||
{
|
||||
BOOST_MPL_ASSERT_NOT((traits::is_random_access<Iterator>));
|
||||
};
|
||||
};
|
||||
}}
|
||||
|
||||
|
@ -77,14 +77,20 @@ namespace boost { namespace fusion {
|
||||
typename add_const<typename mpl::deref<typename Iterator::iterator>::type>,
|
||||
typename mpl::deref<typename Iterator::iterator>
|
||||
>::type
|
||||
value_type;
|
||||
|
||||
typedef typename
|
||||
add_reference<value_type>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Iterator const & it)
|
||||
{
|
||||
typedef typename mpl::deref<typename Iterator::iterator>::type type;
|
||||
type* result = get<type>(&it.var_);
|
||||
return result ? *result : type();
|
||||
if (type* result = get<type>(&it.var_))
|
||||
return *result;
|
||||
it.var_ = type(); // prime the variant
|
||||
return *boost::get<type>(&it.var_); // no-throw!
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user