Files

89 lines
2.6 KiB
C++
Raw Permalink Normal View History

2006-08-16 16:50:52 +00:00
/*=============================================================================
2011-09-16 05:30:23 +00:00
Copyright (c) 2001-2011 Joel de Guzman
2006-08-16 16:50:52 +00:00
2007-03-02 10:44:14 +00:00
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
2006-08-16 16:50:52 +00:00
==============================================================================*/
#if !defined(FUSION_VALUE_AT_05052005_0229)
#define FUSION_VALUE_AT_05052005_0229
2014-01-09 17:58:06 -08:00
#include <boost/fusion/support/config.hpp>
2006-08-16 16:50:52 +00:00
#include <boost/mpl/int.hpp>
2015-03-20 00:34:37 +09:00
#include <boost/mpl/if.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/empty_base.hpp>
2011-08-17 18:53:56 +00:00
#include <boost/fusion/sequence/intrinsic_fwd.hpp>
2006-08-16 16:50:52 +00:00
#include <boost/fusion/support/tag_of.hpp>
2015-03-20 00:34:37 +09:00
#include <boost/fusion/support/category_of.hpp>
2006-08-16 16:50:52 +00:00
namespace boost { namespace fusion
{
// Special tags:
struct sequence_facade_tag;
2006-09-27 00:42:32 +00:00
struct boost_tuple_tag; // boost::tuples::tuple tag
2010-02-07 18:22:06 +00:00
struct boost_array_tag; // boost::array tag
2006-09-22 13:39:27 +00:00
struct mpl_sequence_tag; // mpl sequence tag
struct std_pair_tag; // std::pair tag
2006-08-16 16:50:52 +00:00
namespace extension
{
template <typename Tag>
struct value_at_impl
{
template <typename Sequence, typename N>
struct apply;
};
2006-09-22 13:39:27 +00:00
template <>
struct value_at_impl<sequence_facade_tag>
{
template <typename Sequence, typename N>
struct apply : Sequence::template value_at<Sequence, N> {};
};
2006-09-27 00:42:32 +00:00
template <>
struct value_at_impl<boost_tuple_tag>;
2006-09-22 13:39:27 +00:00
template <>
2010-02-07 18:22:06 +00:00
struct value_at_impl<boost_array_tag>;
2006-09-22 13:39:27 +00:00
template <>
struct value_at_impl<mpl_sequence_tag>;
template <>
struct value_at_impl<std_pair_tag>;
2006-08-16 16:50:52 +00:00
}
2015-03-20 00:34:37 +09:00
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::is_unbounded<Sequence>
2015-03-20 00:34:37 +09:00
>
, typename extension::value_at_impl<Tag>::template apply<Sequence, N>
, mpl::empty_base
>::type
{};
}
2006-08-16 16:50:52 +00:00
namespace result_of
{
template <typename Sequence, typename N>
struct value_at
2015-03-20 00:34:37 +09:00
: detail::value_at_impl<Sequence, N, typename detail::tag_of<Sequence>::type>
2006-08-16 16:50:52 +00:00
{};
template <typename Sequence, int N>
struct value_at_c
: fusion::result_of::value_at<Sequence, mpl::int_<N> >
{};
}
}}
#endif