forked from boostorg/fusion
phase4: refactoring for v2.1
[SVN r40213]
This commit is contained in:
47
include/boost/fusion/container/vector/convert.hpp
Normal file
47
include/boost/fusion/container/vector/convert.hpp
Normal file
@ -0,0 +1,47 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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_CONVERT_09222005_1104)
|
||||
#define FUSION_CONVERT_09222005_1104
|
||||
|
||||
#include <boost/fusion/container/vector/detail/as_vector.hpp>
|
||||
#include <boost/fusion/container/vector/detail/convert_impl.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
namespace result_of
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct as_vector
|
||||
{
|
||||
typedef typename detail::as_vector<result_of::size<Sequence>::value> gen;
|
||||
typedef typename gen::
|
||||
template apply<typename result_of::begin<Sequence>::type>::type
|
||||
type;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
inline typename result_of::as_vector<Sequence>::type
|
||||
as_vector(Sequence& seq)
|
||||
{
|
||||
typedef typename result_of::as_vector<Sequence>::gen gen;
|
||||
return gen::call(fusion::begin(seq));
|
||||
}
|
||||
|
||||
template <typename Sequence>
|
||||
inline typename result_of::as_vector<Sequence const>::type
|
||||
as_vector(Sequence const& seq)
|
||||
{
|
||||
typedef typename result_of::as_vector<Sequence const>::gen gen;
|
||||
return gen::call(fusion::begin(seq));
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
101
include/boost/fusion/container/vector/detail/as_vector.hpp
Normal file
101
include/boost/fusion/container/vector/detail/as_vector.hpp
Normal file
@ -0,0 +1,101 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 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)
|
||||
==============================================================================*/
|
||||
#ifndef BOOST_PP_IS_ITERATING
|
||||
#if !defined(FUSION_AS_VECTOR_09222005_0950)
|
||||
#define FUSION_AS_VECTOR_09222005_0950
|
||||
|
||||
#include <boost/preprocessor/iterate.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
#include <boost/preprocessor/repetition/repeat.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/inc.hpp>
|
||||
#include <boost/preprocessor/dec.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/iterator/value_of.hpp>
|
||||
#include <boost/fusion/iterator/deref.hpp>
|
||||
#include <boost/fusion/iterator/next.hpp>
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <int size>
|
||||
struct as_vector;
|
||||
|
||||
template <>
|
||||
struct as_vector<0>
|
||||
{
|
||||
template <typename Iterator>
|
||||
struct apply
|
||||
{
|
||||
typedef vector<> type;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
static typename apply<Iterator>::type
|
||||
call(Iterator)
|
||||
{
|
||||
return vector<>();
|
||||
}
|
||||
};
|
||||
|
||||
#define BOOST_FUSION_NEXT_ITERATOR(z, n, data) \
|
||||
typedef typename fusion::result_of::next<BOOST_PP_CAT(I, n)>::type \
|
||||
BOOST_PP_CAT(I, BOOST_PP_INC(n));
|
||||
|
||||
#define BOOST_FUSION_NEXT_CALL_ITERATOR(z, n, data) \
|
||||
typename gen::BOOST_PP_CAT(I, BOOST_PP_INC(n)) \
|
||||
BOOST_PP_CAT(i, BOOST_PP_INC(n)) = fusion::next(BOOST_PP_CAT(i, n));
|
||||
|
||||
#define BOOST_FUSION_VALUE_OF_ITERATOR(z, n, data) \
|
||||
typedef typename fusion::result_of::value_of<BOOST_PP_CAT(I, n)>::type \
|
||||
BOOST_PP_CAT(T, n);
|
||||
|
||||
#define BOOST_PP_FILENAME_1 <boost/fusion/container/vector/detail/as_vector.hpp>
|
||||
#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE)
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
#undef BOOST_FUSION_NEXT_ITERATOR
|
||||
#undef BOOST_FUSION_NEXT_CALL_ITERATOR
|
||||
#undef BOOST_FUSION_VALUE_OF_ITERATOR
|
||||
|
||||
}}}
|
||||
|
||||
#endif
|
||||
#else // defined(BOOST_PP_IS_ITERATING)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Preprocessor vertical repetition code
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
template <>
|
||||
struct as_vector<N>
|
||||
{
|
||||
template <typename I0>
|
||||
struct apply
|
||||
{
|
||||
BOOST_PP_REPEAT(N, BOOST_FUSION_NEXT_ITERATOR, _)
|
||||
BOOST_PP_REPEAT(N, BOOST_FUSION_VALUE_OF_ITERATOR, _)
|
||||
typedef vector<BOOST_PP_ENUM_PARAMS(N, T)> type;
|
||||
};
|
||||
|
||||
template <typename Iterator>
|
||||
static typename apply<Iterator>::type
|
||||
call(Iterator const& i0)
|
||||
{
|
||||
typedef apply<Iterator> gen;
|
||||
typedef typename gen::type result;
|
||||
BOOST_PP_REPEAT(BOOST_PP_DEC(N), BOOST_FUSION_NEXT_CALL_ITERATOR, _)
|
||||
return result(BOOST_PP_ENUM_PARAMS(N, *i));
|
||||
}
|
||||
};
|
||||
|
||||
#undef N
|
||||
#endif // defined(BOOST_PP_IS_ITERATING)
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*=============================================================================
|
||||
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(FUSION_CONVERT_IMPL_09222005_1104)
|
||||
#define FUSION_CONVERT_IMPL_09222005_1104
|
||||
|
||||
#include <boost/fusion/container/vector/detail/as_vector.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct vector_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename T>
|
||||
struct convert_impl;
|
||||
|
||||
template <>
|
||||
struct convert_impl<vector_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename detail::as_vector<result_of::size<Sequence>::value> gen;
|
||||
typedef typename gen::
|
||||
template apply<typename result_of::begin<Sequence>::type>::type
|
||||
type;
|
||||
|
||||
static type call(Sequence& seq)
|
||||
{
|
||||
return gen::call(fusion::begin(seq));
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <boost/fusion/container/vector/vector_fwd.hpp>
|
||||
#include <boost/fusion/container/vector/detail/vector_n_chooser.hpp>
|
||||
#include <boost/fusion/sequence/conversion/detail/as_vector.hpp>
|
||||
#include <boost/fusion/container/vector/detail/as_vector.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/mpl/at.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
Reference in New Issue
Block a user