forked from boostorg/fusion
phase2: refactoring for v2.1
[SVN r40209]
This commit is contained in:
1 parent
a77599ed49
commit
9243ee2450
227 files changed
+350
-354
No files matched your search
@@ -0,0 +1,49 @@
|
||||
/*=============================================================================
|
||||
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_AT_KEY_IMPL_05222005_0254)
|
||||
#define FUSION_AT_KEY_IMPL_05222005_0254
|
||||
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct map_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct at_key_impl;
|
||||
|
||||
template <>
|
||||
struct at_key_impl<map_tag>
|
||||
{
|
||||
template <typename Sequence, typename Key>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::template meta_at_impl<Key> element;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
is_const<Sequence>
|
||||
, detail::cref_result<element>
|
||||
, detail::ref_result<element>
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Sequence& m)
|
||||
{
|
||||
return m.at_impl(mpl::identity<Key>());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
/*=============================================================================
|
||||
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_BEGIN_IMPL_05222005_1108)
|
||||
#define FUSION_BEGIN_IMPL_05222005_1108
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/begin.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct map_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct begin_impl;
|
||||
|
||||
template <>
|
||||
struct begin_impl<map_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
result_of::begin<typename Sequence::storage_type>::type
|
||||
iterator_type;
|
||||
|
||||
typedef typename
|
||||
result_of::begin<typename Sequence::storage_type const>::type
|
||||
const_iterator_type;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
is_const<Sequence>
|
||||
, mpl::identity<const_iterator_type>
|
||||
, mpl::identity<iterator_type>
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Sequence& m)
|
||||
{
|
||||
return fusion::begin(m.get_data());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
/*=============================================================================
|
||||
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_END_IMPL_05222005_1108)
|
||||
#define FUSION_END_IMPL_05222005_1108
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct map_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct end_impl;
|
||||
|
||||
template <>
|
||||
struct end_impl<map_tag>
|
||||
{
|
||||
template <typename Sequence>
|
||||
struct apply
|
||||
{
|
||||
typedef typename
|
||||
result_of::end<typename Sequence::storage_type>::type
|
||||
iterator_type;
|
||||
|
||||
typedef typename
|
||||
result_of::end<typename Sequence::storage_type const>::type
|
||||
const_iterator_type;
|
||||
|
||||
typedef typename
|
||||
mpl::eval_if<
|
||||
is_const<Sequence>
|
||||
, mpl::identity<const_iterator_type>
|
||||
, mpl::identity<iterator_type>
|
||||
>::type
|
||||
type;
|
||||
|
||||
static type
|
||||
call(Sequence& m)
|
||||
{
|
||||
return fusion::end(m.get_data());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
/*=============================================================================
|
||||
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_LOOKUP_KEY_07222005_1248)
|
||||
#define FUSION_LOOKUP_KEY_07222005_1248
|
||||
|
||||
#include <boost/mpl/int.hpp>
|
||||
#include <boost/type_traits/add_const.hpp>
|
||||
#include <boost/type_traits/add_reference.hpp>
|
||||
#include <boost/fusion/support/detail/unknown_key.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
}}
|
||||
|
||||
namespace boost { namespace fusion { namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
struct map_data_type
|
||||
{
|
||||
typedef typename
|
||||
add_reference<
|
||||
typename T::second_type
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct map_data_type<void_>
|
||||
{
|
||||
typedef void_& type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct map_const_data_type
|
||||
{
|
||||
typedef typename
|
||||
add_reference<
|
||||
typename add_const<
|
||||
typename T::second_type
|
||||
>::type
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct map_const_data_type<void_>
|
||||
{
|
||||
typedef void_ const& type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct map_value_type
|
||||
{
|
||||
typedef typename T::second_type type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct map_value_type<void_>
|
||||
{
|
||||
typedef void_ type;
|
||||
};
|
||||
|
||||
template <typename T, int index>
|
||||
struct map_key_type
|
||||
{
|
||||
typedef typename T::first_type type;
|
||||
};
|
||||
|
||||
template <int index>
|
||||
struct map_key_type<void_, index>
|
||||
{
|
||||
typedef unknown_key<index> type;
|
||||
};
|
||||
|
||||
template <int index, typename RT, typename Key, typename Vector>
|
||||
struct map_lookup_key
|
||||
{
|
||||
static RT
|
||||
call(Vector& vec)
|
||||
{
|
||||
return vec.at_impl(mpl::int_<index>()).second;
|
||||
}
|
||||
};
|
||||
|
||||
template <int index, typename Vector>
|
||||
struct map_lookup_key<index, void_&, unknown_key<index>, Vector>
|
||||
{
|
||||
static void_&
|
||||
call(Vector& vec); // intentionally undefined
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*=============================================================================
|
||||
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_MAP_FORWARD_CTOR_07222005_0106)
|
||||
#define FUSION_MAP_FORWARD_CTOR_07222005_0106
|
||||
|
||||
#include <boost/preprocessor/iterate.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
|
||||
#define BOOST_PP_FILENAME_1 \
|
||||
<boost/fusion/container/map/detail/map_forward_ctor.hpp>
|
||||
#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_MAP_SIZE)
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
#endif
|
||||
#else // defined(BOOST_PP_IS_ITERATING)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Preprocessor vertical repetition code
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
#if N == 1
|
||||
explicit
|
||||
#endif
|
||||
map(BOOST_PP_ENUM_BINARY_PARAMS(N, T, const& _))
|
||||
: data(BOOST_PP_ENUM_PARAMS(N, _)) {}
|
||||
|
||||
#undef N
|
||||
#endif // defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*=============================================================================
|
||||
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_MAP_LOOKUP_07212005_1118)
|
||||
#define FUSION_MAP_LOOKUP_07212005_1118
|
||||
|
||||
#include <boost/preprocessor/iterate.hpp>
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/preprocessor/arithmetic/dec.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310)
|
||||
#pragma warning (push)
|
||||
#pragma warning(disable: 4348) // redefinition of default parameter
|
||||
#endif
|
||||
|
||||
template <typename Key, typename dummy = int>
|
||||
struct meta_at_impl
|
||||
{
|
||||
typedef void_ type;
|
||||
};
|
||||
|
||||
template <typename Key, typename dummy = int>
|
||||
struct meta_find_impl
|
||||
{
|
||||
typedef vector_iterator<storage_type, storage_type::size::value> type;
|
||||
};
|
||||
|
||||
template <typename Key, typename dummy = int>
|
||||
struct meta_find_impl_const
|
||||
{
|
||||
typedef vector_iterator<storage_type const, storage_type::size::value> type;
|
||||
};
|
||||
|
||||
template <typename Key>
|
||||
vector_iterator<storage_type const, storage_type::size::value>
|
||||
find_impl(mpl::identity<Key>) const
|
||||
{
|
||||
return vector_iterator<storage_type const, storage_type::size::value>(data);
|
||||
}
|
||||
|
||||
template <typename Key>
|
||||
vector_iterator<storage_type, storage_type::size::value>
|
||||
find_impl(mpl::identity<Key>)
|
||||
{
|
||||
return vector_iterator<storage_type, storage_type::size::value>(data);
|
||||
}
|
||||
|
||||
#define BOOST_PP_FILENAME_1 \
|
||||
<boost/fusion/container/map/detail/map_lookup.hpp>
|
||||
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_DEC(FUSION_MAX_MAP_SIZE))
|
||||
#include BOOST_PP_ITERATE()
|
||||
|
||||
#if defined(BOOST_MSVC) && (BOOST_MSVC == 1310)
|
||||
#pragma warning (pop)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#else // defined(BOOST_PP_IS_ITERATING)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Preprocessor vertical repetition code
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define N BOOST_PP_ITERATION()
|
||||
|
||||
template <typename dummy>
|
||||
struct meta_at_impl<
|
||||
typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
|
||||
{
|
||||
typedef typename detail::map_value_type<BOOST_PP_CAT(T, N)>::type type;
|
||||
};
|
||||
|
||||
typename detail::map_data_type<BOOST_PP_CAT(T, N)>::type
|
||||
at_impl(mpl::identity<typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type>)
|
||||
{
|
||||
return detail::map_lookup_key<
|
||||
N
|
||||
, typename detail::map_data_type<BOOST_PP_CAT(T, N)>::type
|
||||
, typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type
|
||||
, storage_type>::call(data);
|
||||
}
|
||||
|
||||
typename detail::map_const_data_type<BOOST_PP_CAT(T, N)>::type
|
||||
at_impl(mpl::identity<typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type>) const
|
||||
{
|
||||
return detail::map_lookup_key<
|
||||
N
|
||||
, typename detail::map_const_data_type<BOOST_PP_CAT(T, N)>::type
|
||||
, typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type
|
||||
, storage_type const>::call(data);
|
||||
}
|
||||
|
||||
template <typename dummy>
|
||||
struct meta_find_impl<
|
||||
typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
|
||||
{
|
||||
typedef vector_iterator<storage_type, N> type;
|
||||
};
|
||||
|
||||
template <typename dummy>
|
||||
struct meta_find_impl_const<
|
||||
typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
|
||||
{
|
||||
typedef vector_iterator<storage_type const, N> type;
|
||||
};
|
||||
|
||||
vector_iterator<storage_type, N>
|
||||
find_impl(mpl::identity<typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type>)
|
||||
{
|
||||
return vector_iterator<storage_type, N>(data);
|
||||
}
|
||||
|
||||
vector_iterator<storage_type const, N>
|
||||
find_impl(mpl::identity<typename detail::map_key_type<BOOST_PP_CAT(T, N), N>::type>) const
|
||||
{
|
||||
return vector_iterator<storage_type const, N>(data);
|
||||
}
|
||||
|
||||
#undef N
|
||||
#endif // defined(BOOST_PP_IS_ITERATING)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2001-2006 Joel de Guzman
|
||||
Copyright (c) 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_VALUE_AT_KEY_IMPL_05222005_0325)
|
||||
#define FUSION_VALUE_AT_KEY_IMPL_05222005_0325
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct map_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_at_key_impl;
|
||||
|
||||
template <>
|
||||
struct value_at_key_impl<map_tag>
|
||||
{
|
||||
template <typename Sequence, typename Key>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::
|
||||
template meta_at_impl<Key>::type type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,25 @@
|
||||
/*=============================================================================
|
||||
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_MAP_LIMITS_07212005_1104)
|
||||
#define FUSION_MAP_LIMITS_07212005_1104
|
||||
|
||||
#include <boost/fusion/container/vector/limits.hpp>
|
||||
|
||||
#if !defined(FUSION_MAX_MAP_SIZE)
|
||||
# define FUSION_MAX_MAP_SIZE FUSION_MAX_VECTOR_SIZE
|
||||
#else
|
||||
# if FUSION_MAX_MAP_SIZE < 3
|
||||
# undef FUSION_MAX_MAP_SIZE
|
||||
# if (FUSION_MAX_VECTOR_SIZE > 10)
|
||||
# define FUSION_MAX_MAP_SIZE 10
|
||||
# else
|
||||
# define FUSION_MAX_MAP_SIZE FUSION_MAX_VECTOR_SIZE
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,71 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005 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_MAP_07212005_1106)
|
||||
#define FUSION_MAP_07212005_1106
|
||||
|
||||
#include <boost/fusion/support/pair.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/fusion/container/map/map_fwd.hpp>
|
||||
#include <boost/fusion/container/map/detail/lookup_key.hpp>
|
||||
#include <boost/fusion/container/map/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/end_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/at_key_impl.hpp>
|
||||
#include <boost/fusion/container/map/detail/value_at_key_impl.hpp>
|
||||
#include <boost/fusion/container/vector/vector.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
struct map_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_MAP_SIZE, typename T)>
|
||||
struct map : sequence_base<map<BOOST_PP_ENUM_PARAMS(FUSION_MAX_MAP_SIZE, T)> >
|
||||
{
|
||||
struct category : forward_traversal_tag, associative_sequence_tag {};
|
||||
|
||||
typedef map_tag fusion_tag;
|
||||
typedef fusion_sequence_tag tag; // this gets picked up by MPL
|
||||
typedef mpl::false_ is_view;
|
||||
|
||||
typedef vector<
|
||||
BOOST_PP_ENUM_PARAMS(FUSION_MAX_MAP_SIZE, T)>
|
||||
storage_type;
|
||||
|
||||
typedef typename storage_type::size size;
|
||||
|
||||
map()
|
||||
: data() {}
|
||||
|
||||
template <typename Sequence>
|
||||
map(Sequence const& rhs)
|
||||
: data(rhs) {}
|
||||
|
||||
#include <boost/fusion/container/map/detail/map_forward_ctor.hpp>
|
||||
#include <boost/fusion/container/map/detail/map_lookup.hpp>
|
||||
|
||||
template <typename T>
|
||||
map&
|
||||
operator=(T const& rhs)
|
||||
{
|
||||
data = rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
storage_type& get_data() { return data; }
|
||||
storage_type const& get_data() const { return data; }
|
||||
|
||||
private:
|
||||
|
||||
storage_type data;
|
||||
};
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
/*=============================================================================
|
||||
Copyright (c) 2005 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_MAP_FORWARD_07212005_1105)
|
||||
#define FUSION_MAP_FORWARD_07212005_1105
|
||||
|
||||
#include <boost/fusion/container/map/limits.hpp>
|
||||
#include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct void_;
|
||||
|
||||
template <
|
||||
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
|
||||
FUSION_MAX_MAP_SIZE, typename T, void_)
|
||||
>
|
||||
struct map;
|
||||
}}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user