Added adapter for std::tuple (only for implementations using variadic templates)

[SVN r74546]
This commit is contained in:
Joel de Guzman
2011-09-24 13:07:09 +00:00
parent d1a397c427
commit b2c3737eaf
13 changed files with 476 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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_09242011_1744)
#define BOOST_FUSION_SIZE_IMPL_09242011_1744
#include <tuple>
#include <boost/mpl/int.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<Sequence>::value> {};
};
}
}}
#endif

View File

@ -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