Ticket #7526: boost_tuple-convert.patch

File boost_tuple-convert.patch, 6.4 KB (added by Kohei Takahashi <flast@…>, 10 years ago)
  • boost/fusion/adapted/boost_tuple.hpp

    From 6e2bfab3fda26abf264c9b4578b6e0ba41e3d20a Mon Sep 17 00:00:00 2001
    From: Kohei Takahashi <flast@flast.jp>
    Date: Wed, 17 Oct 2012 18:05:39 +0900
    Subject: [PATCH] Support adapting Boost.Tuple to Boost.MPL via Boost.Fusion
    
    ---
     boost/fusion/adapted/boost_tuple.hpp               |    3 ++
     .../adapted/boost_tuple/detail/build_cons.hpp      |   57 ++++++++++++++++++++
     .../adapted/boost_tuple/detail/convert_impl.hpp    |   48 +++++++++++++++++
     boost/fusion/adapted/boost_tuple/mpl/clear.hpp     |   23 ++++++++
     4 files changed, 131 insertions(+)
     create mode 100644 boost/fusion/adapted/boost_tuple/detail/build_cons.hpp
     create mode 100644 boost/fusion/adapted/boost_tuple/detail/convert_impl.hpp
     create mode 100644 boost/fusion/adapted/boost_tuple/mpl/clear.hpp
    
    diff --git a/boost/fusion/adapted/boost_tuple.hpp b/boost/fusion/adapted/boost_tuple.hpp
    index 6149478..88eada1 100644
    a b  
    11/*=============================================================================
    22    Copyright (c) 2001-2011 Joel de Guzman
     3    Copyright (c) 2012 Kohei Takahashi
    34
    45    Distributed under the Boost Software License, Version 1.0. (See accompanying
    56    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     
    1617#include <boost/fusion/adapted/boost_tuple/detail/size_impl.hpp>
    1718#include <boost/fusion/adapted/boost_tuple/detail/at_impl.hpp>
    1819#include <boost/fusion/adapted/boost_tuple/detail/value_at_impl.hpp>
     20#include <boost/fusion/adapted/boost_tuple/detail/convert_impl.hpp>
     21#include <boost/fusion/adapted/boost_tuple/mpl/clear.hpp>
    1922
    2023#endif
  • new file oost/fusion/adapted/boost_tuple/detail/build_cons.hpp

    diff --git a/boost/fusion/adapted/boost_tuple/detail/build_cons.hpp b/boost/fusion/adapted/boost_tuple/detail/build_cons.hpp
    new file mode 100644
    index 0000000..9e2673e
    - +  
     1/*=============================================================================
     2    Copyright (c) 2012 Kohei Takahashi
     3
     4    Distributed under the Boost Software License, Version 1.0. (See accompanying
     5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     6==============================================================================*/
     7#if !defined(BOOST_FUSION_BUILD_CONS_10172012_0130)
     8#define BOOST_FUSION_BUILD_CONS_10172012_0130
     9
     10#include <boost/tuple/tuple.hpp>
     11#include <boost/fusion/iterator/equal_to.hpp>
     12#include <boost/fusion/iterator/next.hpp>
     13#include <boost/fusion/iterator/value_of.hpp>
     14#include <boost/fusion/iterator/deref.hpp>
     15
     16namespace boost { namespace fusion { namespace detail
     17{
     18    template <
     19        typename First
     20      , typename Last
     21      , bool is_empty = result_of::equal_to<First, Last>::value>
     22    struct build_cons;
     23
     24    template <typename First, typename Last>
     25    struct build_cons<First, Last, true>
     26    {
     27        typedef boost::tuples::null_type type;
     28
     29        static type
     30        call(First const&, Last const&)
     31        {
     32            return type();
     33        }
     34    };
     35
     36    template <typename First, typename Last>
     37    struct build_cons<First, Last, false>
     38    {
     39        typedef
     40            build_cons<typename result_of::next<First>::type, Last>
     41        next_build_cons;
     42
     43        typedef boost::tuples::cons<
     44            typename result_of::value_of<First>::type
     45          , typename next_build_cons::type>
     46        type;
     47
     48        static type
     49        call(First const& f, Last const& l)
     50        {
     51            typename result_of::value_of<First>::type v = *f;
     52            return type(v, next_build_cons::call(fusion::next(f), l));
     53        }
     54    };
     55}}}
     56
     57#endif
  • new file oost/fusion/adapted/boost_tuple/detail/convert_impl.hpp

    diff --git a/boost/fusion/adapted/boost_tuple/detail/convert_impl.hpp b/boost/fusion/adapted/boost_tuple/detail/convert_impl.hpp
    new file mode 100644
    index 0000000..e099981
    - +  
     1/*=============================================================================
     2    Copyright (c) 2012 Kohei Takahashi
     3
     4    Distributed under the Boost Software License, Version 1.0. (See accompanying
     5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     6==============================================================================*/
     7#if !defined(BOOST_FUSION_CONVERT_IMPL_10172012_0120)
     8#define BOOST_FUSION_CONVERT_IMPL_10172012_0120
     9
     10#include <boost/tuple/tuple.hpp>
     11#include <boost/fusion/adapted/boost_tuple/detail/build_cons.hpp>
     12#include <boost/fusion/sequence/intrinsic/begin.hpp>
     13#include <boost/fusion/sequence/intrinsic/end.hpp>
     14
     15namespace boost { namespace fusion
     16{
     17    struct boost_tuple_tag;
     18
     19    namespace extension
     20    {
     21        template <typename T>
     22        struct convert_impl;
     23
     24        template <>
     25        struct convert_impl<boost_tuple_tag>
     26        {
     27            template <typename Sequence>
     28            struct apply
     29            {
     30                typedef typename
     31                    detail::build_cons<
     32                        typename result_of::begin<Sequence>::type
     33                      , typename result_of::end<Sequence>::type
     34                    >
     35                build_cons;
     36
     37                typedef typename build_cons::type type;
     38
     39                static type call(Sequence& seq)
     40                {
     41                    return build_cons::call(fusion::begin(seq), fusion::end(seq));
     42                }
     43            };
     44        };
     45    }
     46}}
     47
     48#endif
  • new file oost/fusion/adapted/boost_tuple/mpl/clear.hpp

    diff --git a/boost/fusion/adapted/boost_tuple/mpl/clear.hpp b/boost/fusion/adapted/boost_tuple/mpl/clear.hpp
    new file mode 100644
    index 0000000..1cca019
    - +  
     1/*=============================================================================
     2    Copyright (c) 2012 Kohei Takahashi
     3
     4    Distributed under the Boost Software License, Version 1.0. (See accompanying
     5    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     6==============================================================================*/
     7#if !defined(BOOST_FUSION_CLEAR_10172012_0100)
     8#define BOOST_FUSION_CLEAR_10172012_0100
     9
     10#include <boost/mpl/identity.hpp>
     11#include <boost/fusion/adapted/boost_tuple/tag_of.hpp>
     12
     13namespace boost { namespace fusion { namespace detail {
     14
     15  template <typename Tag>
     16  struct clear;
     17
     18  template <>
     19  struct clear<boost_tuple_tag> : mpl::identity<boost::tuple<> > {};
     20
     21}}}
     22
     23#endif