Add new traits named has_no_bounds.

It is for special usecase: some thing like a window function.
This commit relative to c9ae4fc886 .
Users who wants to access out-of-bounds of sequence, specify new
category to it.

    struct sequence {
        struct category
            : fusion::random_access_traversal_tag
            , fusion::no_bounds_tag {};
        ...
    };

All of bounds related intrinsics of the /no-bounds-sequence/ *should*
guarantee to be well-defined or SFINAE-friendly, or compile error.
This commit is contained in:
Kohei Takahashi
2015-03-20 00:34:37 +09:00
parent 973f2d3940
commit 1e21a4eb7a
3 changed files with 36 additions and 4 deletions

View File

@ -10,12 +10,13 @@
#include <boost/fusion/support/config.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/empty_base.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
#include <boost/fusion/support/tag_of.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/support/category_of.hpp>
namespace boost { namespace fusion
{
@ -64,7 +65,10 @@ namespace boost { namespace fusion
template <typename Sequence, typename N, typename Tag>
struct at_impl
: mpl::if_<
mpl::less<N, typename extension::size_impl<Tag>::template apply<Sequence>::type>
mpl::or_<
mpl::less<N, typename extension::size_impl<Tag>::template apply<Sequence>::type>
, traits::has_no_bounds<Sequence>
>
, typename extension::at_impl<Tag>::template apply<Sequence, N>
, mpl::empty_base
>::type