mirror of
https://github.com/boostorg/fusion.git
synced 2025-07-30 20:47:31 +02:00
at_key and value_at_key are aware of no-bounds sequence.
This commit is contained in:
@ -11,10 +11,15 @@
|
|||||||
#include <boost/fusion/support/config.hpp>
|
#include <boost/fusion/support/config.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/sequence/intrinsic/has_key.hpp>
|
||||||
#include <boost/fusion/algorithm/query/find.hpp>
|
#include <boost/fusion/algorithm/query/find.hpp>
|
||||||
#include <boost/fusion/iterator/deref_data.hpp>
|
#include <boost/fusion/iterator/deref_data.hpp>
|
||||||
#include <boost/fusion/support/tag_of.hpp>
|
#include <boost/fusion/support/tag_of.hpp>
|
||||||
|
#include <boost/fusion/support/category_of.hpp>
|
||||||
#include <boost/fusion/support/detail/access.hpp>
|
#include <boost/fusion/support/detail/access.hpp>
|
||||||
|
#include <boost/mpl/empty_base.hpp>
|
||||||
|
#include <boost/mpl/if.hpp>
|
||||||
|
#include <boost/mpl/or.hpp>
|
||||||
|
|
||||||
namespace boost { namespace fusion
|
namespace boost { namespace fusion
|
||||||
{
|
{
|
||||||
@ -64,12 +69,26 @@ namespace boost { namespace fusion
|
|||||||
struct at_key_impl<std_pair_tag>;
|
struct at_key_impl<std_pair_tag>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <typename Sequence, typename Key, typename Tag>
|
||||||
|
struct at_key_impl
|
||||||
|
: mpl::if_<
|
||||||
|
mpl::or_<
|
||||||
|
typename extension::has_key_impl<Tag>::template apply<Sequence, Key>
|
||||||
|
, traits::has_no_bounds<Sequence>
|
||||||
|
>
|
||||||
|
, typename extension::at_key_impl<Tag>::template apply<Sequence, Key>
|
||||||
|
, mpl::empty_base
|
||||||
|
>::type
|
||||||
|
{};
|
||||||
|
}
|
||||||
|
|
||||||
namespace result_of
|
namespace result_of
|
||||||
{
|
{
|
||||||
template <typename Sequence, typename Key>
|
template <typename Sequence, typename Key>
|
||||||
struct at_key
|
struct at_key
|
||||||
: extension::at_key_impl<typename detail::tag_of<Sequence>::type>::
|
: detail::at_key_impl<Sequence, Key, typename detail::tag_of<Sequence>::type>
|
||||||
template apply<Sequence, Key>
|
|
||||||
{};
|
{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,10 +10,15 @@
|
|||||||
|
|
||||||
#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/empty_base.hpp>
|
||||||
|
#include <boost/mpl/if.hpp>
|
||||||
|
#include <boost/mpl/or.hpp>
|
||||||
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
|
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
|
||||||
|
#include <boost/fusion/sequence/intrinsic/has_key.hpp>
|
||||||
#include <boost/fusion/iterator/value_of_data.hpp>
|
#include <boost/fusion/iterator/value_of_data.hpp>
|
||||||
#include <boost/fusion/algorithm/query/find.hpp>
|
#include <boost/fusion/algorithm/query/find.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
|
||||||
{
|
{
|
||||||
@ -53,12 +58,26 @@ namespace boost { namespace fusion
|
|||||||
struct value_at_key_impl<std_pair_tag>;
|
struct value_at_key_impl<std_pair_tag>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
template <typename Sequence, typename N, typename Tag>
|
||||||
|
struct value_at_key_impl
|
||||||
|
: mpl::if_<
|
||||||
|
mpl::or_<
|
||||||
|
typename extension::has_key_impl<Tag>::template apply<Sequence, N>
|
||||||
|
, traits::has_no_bounds<Sequence>
|
||||||
|
>
|
||||||
|
, typename extension::value_at_key_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_key
|
struct value_at_key
|
||||||
: extension::value_at_key_impl<typename detail::tag_of<Sequence>::type>::
|
: detail::value_at_key_impl<Sequence, N, typename detail::tag_of<Sequence>::type>
|
||||||
template apply<Sequence, N>
|
|
||||||
{};
|
{};
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
Reference in New Issue
Block a user