#ifndef NIO_PLAY_FUSION_STD_TUPLE #define NIO_PLAY_FUSION_STD_TUPLE // Adapting the MS STL 2010 tuple to Fusion #include #include #include #include #include namespace boost { namespace fusion { struct std_tuple_tag; struct fusion_sequence_tag; struct forward_traversal_tag; namespace detail { template T&& declval(); } template ::value> struct std_tuple_iterator : iterator_facade< std_tuple_iterator, forward_traversal_tag> { typedef T tuple_type; static const unsigned index = I; T& tup; explicit std_tuple_iterator(T& in) : tup(in) {} template struct value_of : std::tuple_element {}; template struct deref { typedef decltype(std::get(detail::declval())) type; static type call(Iterator const& iter) { return std::get(iter.tup); } }; template struct next { typedef std_tuple_iterator type; static type call(Iterator const& iter) { return type(iter.tup); } }; template struct distance { typedef boost::mpl::int_ type; static type call(const I1&, const I2&) { return type(); } }; std_tuple_iterator& operator =(const std_tuple_iterator&); }; template struct std_tuple_iterator : iterator_facade< std_tuple_iterator, forward_traversal_tag> { typedef T tuple_type; explicit std_tuple_iterator(T&) {} }; namespace traits { template struct tag_of> { typedef std_tuple_tag type; }; } namespace extension { template struct is_view_impl; template struct is_sequence_impl; template struct category_of_impl; template struct begin_impl; template struct end_impl; template struct size_impl; template struct at_impl; template struct value_at_impl; template<> struct is_view_impl { template struct apply : mpl::false_ {}; }; template<> struct is_sequence_impl { template struct apply : mpl::true_ {}; }; template<> struct category_of_impl { template struct apply { typedef forward_traversal_tag type; }; }; template <> struct begin_impl { template struct apply { typedef std_tuple_iterator type; static type call(Sequence& v) { return type(v); } }; }; template <> struct end_impl { template struct apply { typedef std_tuple_iterator::value> type; static type call(Sequence& v) { return type(v); } }; }; template <> struct size_impl { template struct apply : mpl::int_::value> {}; }; template <> struct at_impl { template struct apply { typedef decltype(std::get(detail::declval())) type; static type call(Sequence& seq) { return std::get(seq); } }; }; template <> struct value_at_impl { template struct apply : std::tuple_element {}; }; } } namespace mpl { template struct sequence_tag; template struct sequence_tag> { typedef fusion::fusion_sequence_tag type; }; template struct sequence_tag const> { typedef fusion::fusion_sequence_tag type; }; } } #endif