File indexing completed on 2025-01-18 09:34:42
0001
0002
0003
0004
0005
0006
0007 #if !defined(FUSION_AT_05042005_0722)
0008 #define FUSION_AT_05042005_0722
0009
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/mpl/int.hpp>
0012 #include <boost/mpl/if.hpp>
0013 #include <boost/mpl/or.hpp>
0014 #include <boost/mpl/less.hpp>
0015 #include <boost/mpl/empty_base.hpp>
0016 #include <boost/type_traits/is_const.hpp>
0017 #include <boost/fusion/sequence/intrinsic_fwd.hpp>
0018 #include <boost/fusion/support/tag_of.hpp>
0019 #include <boost/fusion/support/category_of.hpp>
0020
0021 namespace boost { namespace fusion
0022 {
0023
0024 struct sequence_facade_tag;
0025 struct boost_tuple_tag;
0026 struct boost_array_tag;
0027 struct mpl_sequence_tag;
0028 struct std_pair_tag;
0029 struct std_tuple_tag;
0030
0031 namespace extension
0032 {
0033 template <typename Tag>
0034 struct at_impl
0035 {
0036 template <typename Sequence, typename N>
0037 struct apply;
0038 };
0039
0040 template <>
0041 struct at_impl<sequence_facade_tag>
0042 {
0043 template <typename Sequence, typename N>
0044 struct apply : Sequence::template at<Sequence, N> {};
0045 };
0046
0047 template <>
0048 struct at_impl<boost_tuple_tag>;
0049
0050 template <>
0051 struct at_impl<boost_array_tag>;
0052
0053 template <>
0054 struct at_impl<mpl_sequence_tag>;
0055
0056 template <>
0057 struct at_impl<std_pair_tag>;
0058
0059 template <>
0060 struct at_impl<std_tuple_tag>;
0061 }
0062
0063 namespace detail
0064 {
0065 template <typename Sequence, typename N, typename Tag>
0066 struct at_impl
0067 : mpl::if_<
0068 mpl::or_<
0069 mpl::less<N, typename extension::size_impl<Tag>::template apply<Sequence>::type>
0070 , traits::is_unbounded<Sequence>
0071 >
0072 , typename extension::at_impl<Tag>::template apply<Sequence, N>
0073 , mpl::empty_base
0074 >::type
0075 {};
0076 }
0077
0078 namespace result_of
0079 {
0080 template <typename Sequence, typename N>
0081 struct at
0082 : detail::at_impl<Sequence, N, typename detail::tag_of<Sequence>::type>
0083 {};
0084
0085 template <typename Sequence, int N>
0086 struct at_c
0087 : at<Sequence, mpl::int_<N> >
0088 {};
0089 }
0090
0091
0092 template <typename N, typename Sequence>
0093 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0094 inline typename
0095 lazy_disable_if<
0096 is_const<Sequence>
0097 , result_of::at<Sequence, N>
0098 >::type
0099 at(Sequence& seq)
0100 {
0101 return result_of::at<Sequence, N>::call(seq);
0102 }
0103
0104 template <typename N, typename Sequence>
0105 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0106 inline typename result_of::at<Sequence const, N>::type
0107 at(Sequence const& seq)
0108 {
0109 return result_of::at<Sequence const, N>::call(seq);
0110 }
0111
0112 template <int N, typename Sequence>
0113 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0114 inline typename
0115 lazy_disable_if<
0116 is_const<Sequence>
0117 , result_of::at_c<Sequence, N>
0118 >::type
0119 at_c(Sequence& seq)
0120 {
0121 return result_of::at_c<Sequence, N>::call(seq);
0122 }
0123
0124 template <int N, typename Sequence>
0125 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0126 inline typename result_of::at_c<Sequence const, N>::type
0127 at_c(Sequence const& seq)
0128 {
0129 return result_of::at_c<Sequence const, N>::call(seq);
0130 }
0131 }}
0132
0133 #endif
0134