diff options
Diffstat (limited to 'boost/fusion/adapted/std_tuple')
10 files changed, 451 insertions, 0 deletions
diff --git a/boost/fusion/adapted/std_tuple/detail/at_impl.hpp b/boost/fusion/adapted/std_tuple/detail/at_impl.hpp new file mode 100644 index 0000000000..2f09719ca7 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/at_impl.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_AT_IMPL_09242011_1744) +#define BOOST_FUSION_AT_IMPL_09242011_1744 + +#include <tuple> +#include <utility> +#include <boost/mpl/eval_if.hpp> +#include <boost/fusion/support/detail/access.hpp> +#include <boost/type_traits/remove_const.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct at_impl; + + template <> + struct at_impl<std_tuple_tag> + { + template <typename Sequence, typename N> + struct apply + { + typedef typename remove_const<Sequence>::type seq_type; + typedef std::tuple_element<N::value, seq_type> element; + + typedef typename + mpl::eval_if< + is_const<Sequence> + , fusion::detail::cref_result<element> + , fusion::detail::ref_result<element> + >::type + type; + + static type + call(Sequence& seq) + { + return std::get<N::value>(seq); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/begin_impl.hpp b/boost/fusion/adapted/std_tuple/detail/begin_impl.hpp new file mode 100644 index 0000000000..8b219024b8 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/begin_impl.hpp @@ -0,0 +1,39 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_BEGIN_IMPL_09242011_1744) +#define BOOST_FUSION_BEGIN_IMPL_09242011_1744 + +#include <boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct begin_impl; + + template <> + struct begin_impl<std_tuple_tag> + { + template <typename Sequence> + struct apply + { + typedef std_tuple_iterator<Sequence, 0> type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/category_of_impl.hpp b/boost/fusion/adapted/std_tuple/detail/category_of_impl.hpp new file mode 100644 index 0000000000..96d567d5e9 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/category_of_impl.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_CATEGORY_OF_IMPL_09272006_0726) +#define BOOST_FUSION_CATEGORY_OF_IMPL_09272006_0726 + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + struct random_access_traversal_tag; + + namespace extension + { + template<typename T> + struct category_of_impl; + + template<> + struct category_of_impl<std_tuple_tag> + { + template<typename T> + struct apply + { + typedef random_access_traversal_tag type; + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/end_impl.hpp b/boost/fusion/adapted/std_tuple/detail/end_impl.hpp new file mode 100644 index 0000000000..78782b7943 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/end_impl.hpp @@ -0,0 +1,43 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_END_IMPL_09242011_1744) +#define BOOST_FUSION_END_IMPL_09242011_1744 + +#include <boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <tuple> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct end_impl; + + template <> + struct end_impl<std_tuple_tag> + { + template <typename Sequence> + struct apply + { + typedef typename remove_const<Sequence>::type seq_type; + static int const size = std::tuple_size<seq_type>::value; + typedef std_tuple_iterator<Sequence, size> type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/is_sequence_impl.hpp b/boost/fusion/adapted/std_tuple/detail/is_sequence_impl.hpp new file mode 100644 index 0000000000..6da5bdc34d --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/is_sequence_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_IS_SEQUENCE_IMPL_09242011_1744) +#define BOOST_FUSION_IS_SEQUENCE_IMPL_09242011_1744 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename Tag> + struct is_sequence_impl; + + template<> + struct is_sequence_impl<std_tuple_tag> + { + template<typename Sequence> + struct apply : mpl::true_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/is_view_impl.hpp b/boost/fusion/adapted/std_tuple/detail/is_view_impl.hpp new file mode 100644 index 0000000000..9439431b5a --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/is_view_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_IS_VIEW_IMPL_09242011_1744) +#define BOOST_FUSION_IS_VIEW_IMPL_09242011_1744 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename Tag> + struct is_view_impl; + + template<> + struct is_view_impl<std_tuple_tag> + { + template<typename T> + struct apply : mpl::false_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/size_impl.hpp b/boost/fusion/adapted/std_tuple/detail/size_impl.hpp new file mode 100644 index 0000000000..d8b10af1ef --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/size_impl.hpp @@ -0,0 +1,36 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_SIZE_IMPL_09242011_1744) +#define BOOST_FUSION_SIZE_IMPL_09242011_1744 + +#include <tuple> +#include <boost/mpl/int.hpp> +#include <boost/type_traits/remove_const.hpp> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct size_impl; + + template <> + struct size_impl<std_tuple_tag> + { + template <typename Sequence> + struct apply : + mpl::int_<std::tuple_size< + typename remove_const<Sequence>::type>::value + > + {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/detail/value_at_impl.hpp b/boost/fusion/adapted/std_tuple/detail/value_at_impl.hpp new file mode 100644 index 0000000000..fa9656e7b2 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/detail/value_at_impl.hpp @@ -0,0 +1,30 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_VALUE_AT_IMPL_09242011_1744) +#define BOOST_FUSION_VALUE_AT_IMPL_09242011_1744 + +#include <tuple> + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + + namespace extension + { + template<typename T> + struct value_at_impl; + + template <> + struct value_at_impl<std_tuple_tag> + { + template <typename Sequence, typename N> + struct apply : std::tuple_element<N::value, Sequence> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp b/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp new file mode 100644 index 0000000000..4998e21d1a --- /dev/null +++ b/boost/fusion/adapted/std_tuple/std_tuple_iterator.hpp @@ -0,0 +1,107 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(FUSION_STD_TUPLE_ITERATOR_09112011_1905) +#define FUSION_STD_TUPLE_ITERATOR_09112011_1905 + +#include <boost/fusion/iterator/iterator_facade.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/fusion/support/detail/access.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/eval_if.hpp> +#include <tuple> +#include <utility> + +namespace boost { namespace fusion +{ + struct random_access_traversal_tag; + + template <typename Tuple, int Index> + struct std_tuple_iterator_identity; + + template <typename Tuple, int Index> + struct std_tuple_iterator + : iterator_facade< + std_tuple_iterator<Tuple, Index> + , random_access_traversal_tag> + { + typedef Tuple tuple_type; + static int const index = Index; + typedef std_tuple_iterator_identity< + typename add_const<Tuple>::type, Index> + identity; + + explicit std_tuple_iterator(Tuple& tuple) + : tuple(tuple) {} + + Tuple& tuple; + + template <typename Iterator> + struct value_of + : std::tuple_element<Iterator::index, + typename remove_const<typename Iterator::tuple_type>::type> {}; + + template <typename Iterator> + struct deref + { + typedef value_of<Iterator> element; + typedef typename + mpl::eval_if< + is_const<typename Iterator::tuple_type> + , fusion::detail::cref_result<element> + , fusion::detail::ref_result<element> + >::type + type; + + static type + call(Iterator const& iter) + { + return std::get<Index>(iter.tuple); + } + }; + + template <typename Iterator, typename N> + struct advance + { + static int const index = Iterator::index; + typedef typename Iterator::tuple_type tuple_type; + typedef std_tuple_iterator<tuple_type, index+N::value> type; + + static type + call(Iterator const& i) + { + return type(i.tuple); + } + }; + + template <typename Iterator> + struct next : advance<Iterator, mpl::int_<1>> {}; + + template <typename Iterator> + struct prior : advance<Iterator, mpl::int_<-1>> {}; + + template <typename I1, typename I2> + struct equal_to + : is_same<typename I1::identity, typename I2::identity> {}; + + template <typename First, typename Last> + struct distance + { + typedef mpl::int_<Last::index-First::index> type; + + static type + call(First const&, Last const&) + { + return type(); + } + }; + }; +}} + +#endif + + diff --git a/boost/fusion/adapted/std_tuple/tag_of.hpp b/boost/fusion/adapted/std_tuple/tag_of.hpp new file mode 100644 index 0000000000..10e2e18142 --- /dev/null +++ b/boost/fusion/adapted/std_tuple/tag_of.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2001-2011 Joel de Guzman + + 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) +==============================================================================*/ +#if !defined(BOOST_FUSION_TAG_OF_09112011_1842) +#define BOOST_FUSION_TAG_OF_09112011_1842 + +#include <tuple> +#include <boost/fusion/support/tag_of_fwd.hpp> + +namespace std +{ + template <typename... Elements> + class tuple; +} + +namespace boost { namespace fusion +{ + struct std_tuple_tag; + struct fusion_sequence_tag; + + namespace traits + { + template <typename... Elements> + struct tag_of<std::tuple<Elements...>> + { + typedef std_tuple_tag type; + }; + } +}} + +namespace boost { namespace mpl +{ + template <typename> + struct sequence_tag; + + template <typename... Elements> + struct sequence_tag<std::tuple<Elements...>> + { + typedef fusion::fusion_sequence_tag type; + }; + + template <typename... Elements> + struct sequence_tag<std::tuple<Elements...> const> + { + typedef fusion::fusion_sequence_tag type; + }; +}} + +#endif |