Initial move from Spirit CVS

[SVN r34896]
This commit is contained in:
Joel de Guzman
2006-08-16 16:50:52 +00:00
commit 75b9d13a88
370 changed files with 17939 additions and 0 deletions

View File

@ -0,0 +1,50 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Use, modification and distribution is subject to 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

View File

@ -0,0 +1,57 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Use, modification and distribution is subject to 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

View File

@ -0,0 +1,54 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Use, modification and distribution is subject to 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

View File

@ -0,0 +1,33 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Use, modification and distribution is subject to 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_ASSOCIATIVE_IMPL_20060304_2310)
#define BOOST_FUSION_IS_ASSOCIATIVE_IMPL_20060304_2310
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion {
struct map_tag;
namespace extension {
template<typename Tag>
struct is_associative_impl;
template<>
struct is_associative_impl<fusion::map_tag>
{
template<typename Seq>
struct apply
: mpl::true_
{};
};
}
}}
#endif

View File

@ -0,0 +1,100 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Use, modification and distribution is subject to 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

View File

@ -0,0 +1,39 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Use, modification and distribution is subject to 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/sequence/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)

View File

@ -0,0 +1,124 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Use, modification and distribution is subject to 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(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/sequence/container/map/detail/map_lookup.hpp>
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_DEC(FUSION_MAX_MAP_SIZE))
#include BOOST_PP_ITERATE()
#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)

View File

@ -0,0 +1,34 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2006 Dan Marsden
Use, modification and distribution is subject to 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

View File

@ -0,0 +1,26 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Use, modification and distribution is subject to 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/sequence/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

View File

@ -0,0 +1,73 @@
/*=============================================================================
Copyright (c) 2005 Joel de Guzman
Use, modification and distribution is subject to 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/detail/access.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/fusion/sequence/container/map/map_fwd.hpp>
#include <boost/fusion/sequence/container/map/detail/lookup_key.hpp>
#include <boost/fusion/sequence/container/map/detail/begin_impl.hpp>
#include <boost/fusion/sequence/container/map/detail/end_impl.hpp>
#include <boost/fusion/sequence/container/map/detail/at_key_impl.hpp>
#include <boost/fusion/sequence/container/map/detail/value_at_key_impl.hpp>
#include <boost/fusion/sequence/container/map/detail/is_associative_impl.hpp>
#include <boost/fusion/sequence/container/vector/vector.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/bool.hpp>
namespace boost { namespace fusion
{
struct void_;
struct map_tag;
struct forward_sequence_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)> >
{
typedef map_tag ftag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
typedef forward_sequence_tag category;
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 T>
explicit map(T const& rhs)
: data(rhs) {}
#include <boost/fusion/sequence/container/map/detail/map_forward_ctor.hpp>
#include <boost/fusion/sequence/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

View File

@ -0,0 +1,25 @@
/*=============================================================================
Copyright (c) 2005 Joel de Guzman
Use, modification and distribution is subject to 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/sequence/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