mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-30 20:47:31 +02:00
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:
@ -10,12 +10,13 @@
|
|||||||
#include <boost/fusion/support/config.hpp>
|
#include <boost/fusion/support/config.hpp>
|
||||||
#include <boost/mpl/int.hpp>
|
#include <boost/mpl/int.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/mpl/if.hpp>
|
||||||
|
#include <boost/mpl/or.hpp>
|
||||||
#include <boost/mpl/less.hpp>
|
#include <boost/mpl/less.hpp>
|
||||||
#include <boost/mpl/empty_base.hpp>
|
#include <boost/mpl/empty_base.hpp>
|
||||||
#include <boost/type_traits/is_const.hpp>
|
#include <boost/type_traits/is_const.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
|
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
|
||||||
#include <boost/fusion/support/tag_of.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
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
@ -64,7 +65,10 @@ namespace boost { namespace fusion
|
|||||||
template <typename Sequence, typename N, typename Tag>
|
template <typename Sequence, typename N, typename Tag>
|
||||||
struct at_impl
|
struct at_impl
|
||||||
: mpl::if_<
|
: 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>
|
, typename extension::at_impl<Tag>::template apply<Sequence, N>
|
||||||
, mpl::empty_base
|
, mpl::empty_base
|
||||||
>::type
|
>::type
|
||||||
|
@ -9,8 +9,13 @@
|
|||||||
|
|
||||||
#include <boost/fusion/support/config.hpp>
|
#include <boost/fusion/support/config.hpp>
|
||||||
#include <boost/mpl/int.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/fusion/sequence/intrinsic_fwd.hpp>
|
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
|
||||||
#include <boost/fusion/support/tag_of.hpp>
|
#include <boost/fusion/support/tag_of.hpp>
|
||||||
|
#include <boost/fusion/support/category_of.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
@ -50,12 +55,26 @@ namespace boost { namespace fusion
|
|||||||
struct value_at_impl<std_pair_tag>;
|
struct value_at_impl<std_pair_tag>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <typename Sequence, typename N, typename Tag>
|
||||||
|
struct value_at_impl
|
||||||
|
: mpl::if_<
|
||||||
|
mpl::or_<
|
||||||
|
mpl::less<N, typename extension::size_impl<Tag>::template apply<Sequence>::type>
|
||||||
|
, traits::has_no_bounds<Sequence>
|
||||||
|
>
|
||||||
|
, typename extension::value_at_impl<Tag>::template apply<Sequence, N>
|
||||||
|
, mpl::empty_base
|
||||||
|
>::type
|
||||||
|
{};
|
||||||
|
}
|
||||||
|
|
||||||
namespace result_of
|
namespace result_of
|
||||||
{
|
{
|
||||||
template <typename Sequence, typename N>
|
template <typename Sequence, typename N>
|
||||||
struct value_at
|
struct value_at
|
||||||
: extension::value_at_impl<typename detail::tag_of<Sequence>::type>::
|
: detail::value_at_impl<Sequence, N, typename detail::tag_of<Sequence>::type>
|
||||||
template apply<Sequence, N>
|
|
||||||
{};
|
{};
|
||||||
|
|
||||||
template <typename Sequence, int N>
|
template <typename Sequence, int N>
|
||||||
|
@ -36,6 +36,8 @@ namespace boost { namespace fusion
|
|||||||
|
|
||||||
struct associative_tag {};
|
struct associative_tag {};
|
||||||
|
|
||||||
|
struct no_bounds_tag {};
|
||||||
|
|
||||||
namespace extension
|
namespace extension
|
||||||
{
|
{
|
||||||
template<typename Tag>
|
template<typename Tag>
|
||||||
@ -107,6 +109,13 @@ namespace boost { namespace fusion
|
|||||||
random_access_traversal_tag
|
random_access_traversal_tag
|
||||||
, typename category_of<T>::type>
|
, typename category_of<T>::type>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct has_no_bounds
|
||||||
|
: is_base_of<
|
||||||
|
no_bounds_tag
|
||||||
|
, typename category_of<T>::type>
|
||||||
|
{};
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user