diff options
Diffstat (limited to 'boost/fusion/adapted/boost_tuple')
10 files changed, 599 insertions, 0 deletions
diff --git a/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp b/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp new file mode 100644 index 0000000000..551f0fd900 --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp @@ -0,0 +1,189 @@ +/*============================================================================= + 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_BOOST_TUPLE_ITERATOR_09262006_1851) +#define FUSION_BOOST_TUPLE_ITERATOR_09262006_1851 + +#include <boost/fusion/iterator/iterator_facade.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/mpl/identity.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/eval_if.hpp> +#include <boost/mpl/or.hpp> +#include <boost/mpl/plus.hpp> +#include <boost/mpl/int.hpp> +#include <boost/mpl/apply.hpp> +#include <boost/tuple/tuple.hpp> + +namespace boost { namespace fusion +{ + struct forward_traversal_tag; + + namespace detail + { + template <typename T> + struct boost_tuple_is_empty : mpl::false_ {}; + + template <> + struct boost_tuple_is_empty<tuples::null_type> : mpl::true_ {}; + + template <> + struct boost_tuple_is_empty<tuples::null_type const> : mpl::true_ {}; + + template <> + struct boost_tuple_is_empty<tuples::tuple<> > : mpl::true_ {}; + + template <> + struct boost_tuple_is_empty<tuples::tuple<> const> : mpl::true_ {}; + } + + template <typename Cons = tuples::null_type> + struct boost_tuple_iterator + : iterator_facade<boost_tuple_iterator<Cons>, forward_traversal_tag> + { + typedef Cons cons_type; + + explicit boost_tuple_iterator(Cons& in_cons) + : cons(in_cons) {} + Cons& cons; + + template <typename Iterator> + struct value_of : mpl::identity<typename Iterator::cons_type::head_type> {}; + + template <typename Iterator> + struct deref + { + typedef typename value_of<Iterator>::type element; + + typedef typename + mpl::if_< + is_const<typename Iterator::cons_type> + , typename tuples::access_traits<element>::const_type + , typename tuples::access_traits<element>::non_const_type + >::type + type; + + static type + call(Iterator const& iter) + { + return iter.cons.get_head(); + } + }; + + template <typename Iterator> + struct next + { + typedef typename Iterator::cons_type cons_type; + typedef typename cons_type::tail_type tail_type; + + typedef boost_tuple_iterator< + typename mpl::eval_if< + is_const<cons_type> + , add_const<tail_type> + , mpl::identity<tail_type> + >::type> + type; + + static type + call(Iterator const& iter) + { + return type(iter.cons.get_tail()); + } + }; + + template <typename I1, typename I2> + struct distance; + + // detail + template <typename I1, typename I2> + struct lazy_next_distance + { + typedef + typename mpl::plus< + mpl::int_<1>, + typename distance< + typename next<I1>::type, + I2 + >::type + >::type type; + }; + + template <typename I1, typename I2> + struct distance + { + typedef typename mpl::eval_if< + boost::is_same<I1, I2>, + mpl::int_<0>, + lazy_next_distance<I1, I2> + >::type type; + + static type + call(I1 const&, I2 const&) + { + return type(); + } + }; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + boost_tuple_iterator& operator= (boost_tuple_iterator const&); + }; + + template <typename Null> + struct boost_tuple_null_iterator + : iterator_facade<boost_tuple_iterator<Null>, forward_traversal_tag> + { + typedef Null cons_type; + + template <typename I1, typename I2> + struct equal_to + : mpl::or_< + is_same<I1, I2> + , mpl::and_< + detail::boost_tuple_is_empty<typename I1::cons_type> + , detail::boost_tuple_is_empty<typename I2::cons_type> + > + > + {}; + }; + + template <> + struct boost_tuple_iterator<tuples::null_type> + : boost_tuple_null_iterator<tuples::null_type> + { + template <typename Cons> + explicit boost_tuple_iterator(Cons const&) {} + }; + + template <> + struct boost_tuple_iterator<tuples::null_type const> + : boost_tuple_null_iterator<tuples::null_type const> + { + template <typename Cons> + explicit boost_tuple_iterator(Cons const&) {} + }; + + template <> + struct boost_tuple_iterator<tuples::tuple<> > + : boost_tuple_null_iterator<tuples::tuple<> > + { + template <typename Cons> + explicit boost_tuple_iterator(Cons const&) {} + }; + + template <> + struct boost_tuple_iterator<tuples::tuple<> const> + : boost_tuple_null_iterator<tuples::tuple<> const> + { + template <typename Cons> + explicit boost_tuple_iterator(Cons const&) {} + }; +}} + +#endif + + diff --git a/boost/fusion/adapted/boost_tuple/detail/at_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/at_impl.hpp new file mode 100644 index 0000000000..8e2312500b --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/at_impl.hpp @@ -0,0 +1,50 @@ +/*============================================================================= + 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_09262006_1920) +#define BOOST_FUSION_AT_IMPL_09262006_1920 + +#include <boost/tuple/tuple.hpp> +#include <boost/mpl/if.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename T> + struct at_impl; + + template <> + struct at_impl<boost_tuple_tag> + { + template <typename Sequence, typename N> + struct apply + { + typedef typename + tuples::element<N::value, Sequence>::type + element; + + typedef typename + mpl::if_< + is_const<Sequence> + , typename tuples::access_traits<element>::const_type + , typename tuples::access_traits<element>::non_const_type + >::type + type; + + static type + call(Sequence& seq) + { + return tuples::get<N::value>(seq); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/begin_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/begin_impl.hpp new file mode 100644 index 0000000000..010c442750 --- /dev/null +++ b/boost/fusion/adapted/boost_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_09272006_0719) +#define BOOST_FUSION_BEGIN_IMPL_09272006_0719 + +#include <boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename T> + struct begin_impl; + + template <> + struct begin_impl<boost_tuple_tag> + { + template <typename Sequence> + struct apply + { + typedef boost_tuple_iterator<Sequence> type; + + static type + call(Sequence& v) + { + return type(v); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/category_of_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/category_of_impl.hpp new file mode 100644 index 0000000000..9b52c98a88 --- /dev/null +++ b/boost/fusion/adapted/boost_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 boost_tuple_tag; + struct forward_traversal_tag; + + namespace extension + { + template<typename T> + struct category_of_impl; + + template<> + struct category_of_impl<boost_tuple_tag> + { + template<typename T> + struct apply + { + typedef forward_traversal_tag type; + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/end_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/end_impl.hpp new file mode 100644 index 0000000000..e54702bf74 --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/end_impl.hpp @@ -0,0 +1,54 @@ +/*============================================================================= + 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_09272006_0721) +#define BOOST_FUSION_END_IMPL_09272006_0721 + +#include <boost/fusion/adapted/boost_tuple/boost_tuple_iterator.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_const.hpp> + +namespace boost { namespace tuples +{ + struct null_type; +}} + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template <typename Tag> + struct end_impl; + + template <> + struct end_impl<boost_tuple_tag> + { + template <typename Sequence> + struct apply + { + typedef + boost_tuple_iterator< + typename mpl::if_< + is_const<Sequence> + , tuples::null_type const + , tuples::null_type + >::type + > + type; + + static type + call(Sequence& seq) + { + return type(seq); + } + }; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/is_sequence_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/is_sequence_impl.hpp new file mode 100644 index 0000000000..c74fb4dfea --- /dev/null +++ b/boost/fusion/adapted/boost_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_09272006_0726) +#define BOOST_FUSION_IS_SEQUENCE_IMPL_09272006_0726 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename Tag> + struct is_sequence_impl; + + template<> + struct is_sequence_impl<boost_tuple_tag> + { + template<typename Sequence> + struct apply : mpl::true_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/is_view_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/is_view_impl.hpp new file mode 100644 index 0000000000..5d639d2b23 --- /dev/null +++ b/boost/fusion/adapted/boost_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_09272006_0725) +#define BOOST_FUSION_IS_VIEW_IMPL_09272006_0725 + +#include <boost/mpl/bool.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename Tag> + struct is_view_impl; + + template<> + struct is_view_impl<boost_tuple_tag> + { + template<typename T> + struct apply : mpl::false_ {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/size_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/size_impl.hpp new file mode 100644 index 0000000000..1dad42030f --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/detail/size_impl.hpp @@ -0,0 +1,31 @@ +/*============================================================================= + 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_09272006_0724) +#define BOOST_FUSION_SIZE_IMPL_09272006_0724 + +#include <boost/tuple/tuple.hpp> +#include <boost/mpl/int.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename T> + struct size_impl; + + template <> + struct size_impl<boost_tuple_tag> + { + template <typename Sequence> + struct apply : mpl::int_<tuples::length<Sequence>::value> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/detail/value_at_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/value_at_impl.hpp new file mode 100644 index 0000000000..4f5fc6a656 --- /dev/null +++ b/boost/fusion/adapted/boost_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_09262006_1926) +#define BOOST_FUSION_VALUE_AT_IMPL_09262006_1926 + +#include <boost/tuple/tuple.hpp> + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + + namespace extension + { + template<typename T> + struct value_at_impl; + + template <> + struct value_at_impl<boost_tuple_tag> + { + template <typename Sequence, typename N> + struct apply : tuples::element<N::value, Sequence> {}; + }; + } +}} + +#endif diff --git a/boost/fusion/adapted/boost_tuple/tag_of.hpp b/boost/fusion/adapted/boost_tuple/tag_of.hpp new file mode 100644 index 0000000000..18356de2af --- /dev/null +++ b/boost/fusion/adapted/boost_tuple/tag_of.hpp @@ -0,0 +1,114 @@ +/*============================================================================= + 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_09262006_1900) +#define BOOST_FUSION_TAG_OF_09262006_1900 + +#include <boost/fusion/support/tag_of_fwd.hpp> + +namespace boost { namespace tuples +{ + struct null_type; + + template < + class T0, class T1, class T2, class T3, class T4, + class T5, class T6, class T7, class T8, class T9 + > + class tuple; + + template <class Head, class Tail> + struct cons; +}} + +namespace boost { namespace fusion +{ + struct boost_tuple_tag; + struct fusion_sequence_tag; + + namespace traits + { + template < + class T0, class T1, class T2, class T3, class T4, + class T5, class T6, class T7, class T8, class T9 + > +#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) + struct tag_of<tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>, void > +#else + struct tag_of<tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> > +#endif + { + typedef boost_tuple_tag type; + }; + + template <class Head, class Tail> +#if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) + struct tag_of<tuples::cons<Head, Tail>, void > +#else + struct tag_of<tuples::cons<Head, Tail> > +#endif + { + typedef boost_tuple_tag type; + }; + + template <> + struct tag_of<tuples::null_type> + { + typedef boost_tuple_tag type; + }; + } +}} + +namespace boost { namespace mpl +{ + template<typename> + struct sequence_tag; + + template < + class T0, class T1, class T2, class T3, class T4, + class T5, class T6, class T7, class T8, class T9 + > + struct sequence_tag<tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> > + { + typedef fusion::fusion_sequence_tag type; + }; + + template < + class T0, class T1, class T2, class T3, class T4, + class T5, class T6, class T7, class T8, class T9 + > + struct sequence_tag< + tuples::tuple<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> const + > + { + typedef fusion::fusion_sequence_tag type; + }; + + template <class Head, class Tail> + struct sequence_tag<tuples::cons<Head, Tail> > + { + typedef fusion::fusion_sequence_tag type; + }; + + template <class Head, class Tail> + struct sequence_tag<tuples::cons<Head, Tail> const> + { + typedef fusion::fusion_sequence_tag type; + }; + + template <> + struct sequence_tag<tuples::null_type> + { + typedef fusion::fusion_sequence_tag type; + }; + + template <> + struct sequence_tag<tuples::null_type const> + { + typedef fusion::fusion_sequence_tag type; + }; +}} + +#endif |