added struct wrapping facilities to make it very easy to make any struct a conforming fusion sequence

[SVN r37328]
This commit is contained in:
Joel de Guzman
2007-04-02 03:31:13 +00:00
parent ddf9cb743a
commit 6002bc9bb4
13 changed files with 214 additions and 172 deletions

View File

@ -1,71 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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_24122005_1807)
#define BOOST_FUSION_AT_IMPL_24122005_1807
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/static_assert.hpp>
#include <boost/fusion/support/detail/access.hpp>
namespace boost { namespace fusion {
struct std_pair_tag;
namespace extension
{
template<typename T>
struct at_impl;
template <>
struct at_impl<std_pair_tag>
{
template <typename Sequence, typename N>
struct apply
{
static int const n_value = N::value;
BOOST_STATIC_ASSERT((n_value >= 0 && n_value < 2));
typedef typename
mpl::if_c<
(n_value == 0)
, typename Sequence::first_type
, typename Sequence::second_type
>
element;
typedef typename
mpl::eval_if<
is_const<Sequence>
, detail::cref_result<element>
, detail::ref_result<element>
>::type
type;
template <typename RT>
static RT get(Sequence& p, mpl::int_<0>)
{
return p.first;
}
template <typename RT>
static RT get(Sequence& p, mpl::int_<1>)
{
return p.second;
}
static type
call(Sequence& p)
{
return get<type>(p, N());
}
};
};
}
}}
#endif

View File

@ -1,40 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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_24122005_1752)
#define BOOST_FUSION_BEGIN_IMPL_24122005_1752
#include <boost/fusion/sequence/adapted/std_pair/std_pair_iterator.hpp>
namespace boost { namespace fusion {
struct std_pair_tag;
namespace extension
{
template<typename T>
struct begin_impl;
template <>
struct begin_impl<std_pair_tag>
{
template <typename Sequence>
struct apply
{
typedef std_pair_iterator<Sequence, 0> type;
static type
call(Sequence& v)
{
return type(v);
}
};
};
}
}}
#endif

View File

@ -1,35 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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_24122005_1731)
#define BOOST_FUSION_CATEGORY_OF_IMPL_24122005_1731
#include <utility>
namespace boost { namespace fusion {
struct std_pair_tag;
struct random_access_traversal_tag;
namespace extension
{
template<typename T>
struct category_of_impl;
template<>
struct category_of_impl<std_pair_tag>
{
template<typename T>
struct apply
{
typedef random_access_traversal_tag type;
};
};
}
}}
#endif

View File

@ -1,40 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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_24122005_1755)
#define BOOST_FUSION_END_IMPL_24122005_1755
#include <boost/fusion/sequence/adapted/std_pair/std_pair_iterator.hpp>
namespace boost { namespace fusion {
struct std_pair_tag;
namespace extension
{
template <typename Tag>
struct end_impl;
template <>
struct end_impl<std_pair_tag>
{
template <typename Sequence>
struct apply
{
typedef std_pair_iterator<Sequence, 2> type;
static type
call(Sequence& v)
{
return type(v);
}
};
};
}
}}
#endif

View File

@ -1,31 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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_27122005_1651)
#define BOOST_FUSION_IS_SEQUENCE_IMPL_27122005_1651
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion {
struct std_pair_tag;
namespace extension
{
template<typename Tag>
struct is_sequence_impl;
template<>
struct is_sequence_impl<std_pair_tag>
{
template<typename Sequence>
struct apply : mpl::true_ {};
};
}
}}
#endif

View File

@ -1,32 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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_27042006_2219)
#define BOOST_FUSION_IS_VIEW_IMPL_27042006_2219
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion
{
struct std_pair_tag;
namespace extension
{
template<typename Tag>
struct is_view_impl;
template<>
struct is_view_impl<std_pair_tag>
{
template<typename T>
struct apply : mpl::false_
{};
};
}
}}
#endif

View File

@ -1,31 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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_24122005_1759)
#define BOOST_FUSION_SIZE_IMPL_24122005_1759
#include <boost/mpl/int.hpp>
namespace boost { namespace fusion {
struct std_pair_tag;
namespace extension
{
template<typename T>
struct size_impl;
template <>
struct size_impl<std_pair_tag>
{
template <typename Sequence>
struct apply : mpl::int_<2> {};
};
}
}}
#endif

View File

@ -1,43 +0,0 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2005-2006 Dan Marsden
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_24122005_1917)
#define BOOST_FUSION_VALUE_AT_IMPL_24122005_1917
#include <boost/mpl/if.hpp>
#include <boost/static_assert.hpp>
namespace boost { namespace fusion {
struct std_pair_tag;
namespace extension
{
template<typename T>
struct value_at_impl;
template <>
struct value_at_impl<std_pair_tag>
{
template <typename Sequence, typename N>
struct apply
{
static int const n_value = N::value;
BOOST_STATIC_ASSERT((n_value >= 0 && n_value < 2));
typedef typename
mpl::if_c<
(n_value == 0)
, typename Sequence::first_type
, typename Sequence::second_type
>::type
type;
};
};
}
}}
#endif