forked from boostorg/fusion
phase2: refactoring for v2.1
[SVN r40209]
This commit is contained in:
49
include/boost/fusion/container/set/detail/at_key_impl.hpp
Normal file
49
include/boost/fusion/container/set/detail/at_key_impl.hpp
Normal file
@ -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_09162005_1118)
|
||||
#define FUSION_AT_KEY_IMPL_09162005_1118
|
||||
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct set_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct at_key_impl;
|
||||
|
||||
template <>
|
||||
struct at_key_impl<set_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& s)
|
||||
{
|
||||
return s.at_impl(mpl::identity<Key>());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
56
include/boost/fusion/container/set/detail/begin_impl.hpp
Normal file
56
include/boost/fusion/container/set/detail/begin_impl.hpp
Normal file
@ -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_09162005_1120)
|
||||
#define FUSION_BEGIN_IMPL_09162005_1120
|
||||
|
||||
#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 set_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct begin_impl;
|
||||
|
||||
template <>
|
||||
struct begin_impl<set_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& s)
|
||||
{
|
||||
return fusion::begin(s.get_data());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
53
include/boost/fusion/container/set/detail/end_impl.hpp
Normal file
53
include/boost/fusion/container/set/detail/end_impl.hpp
Normal file
@ -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_09162005_1121)
|
||||
#define FUSION_END_IMPL_09162005_1121
|
||||
|
||||
#include <boost/fusion/sequence/intrinsic/end.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct set_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct end_impl;
|
||||
|
||||
template <>
|
||||
struct end_impl<set_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& s)
|
||||
{
|
||||
return fusion::end(s.get_data());
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
93
include/boost/fusion/container/set/detail/lookup_key.hpp
Normal file
93
include/boost/fusion/container/set/detail/lookup_key.hpp
Normal file
@ -0,0 +1,93 @@
|
||||
/*=============================================================================
|
||||
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_09162005_1111)
|
||||
#define FUSION_LOOKUP_KEY_09162005_1111
|
||||
|
||||
#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 set_data_type
|
||||
{
|
||||
typedef typename add_reference<T>::type type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct set_data_type<void_>
|
||||
{
|
||||
typedef void_& type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct set_const_data_type
|
||||
{
|
||||
typedef typename
|
||||
add_reference<
|
||||
typename add_const<T>::type
|
||||
>::type
|
||||
type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct set_const_data_type<void_>
|
||||
{
|
||||
typedef void_ const& type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct set_value_type
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct set_value_type<void_>
|
||||
{
|
||||
typedef void_ type;
|
||||
};
|
||||
|
||||
template <typename T, int index>
|
||||
struct set_key_type
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <int index>
|
||||
struct set_key_type<void_, index>
|
||||
{
|
||||
typedef unknown_key<index> type;
|
||||
};
|
||||
|
||||
template <int index, typename RT, typename Key, typename Vector>
|
||||
struct set_lookup_key
|
||||
{
|
||||
static RT
|
||||
call(Vector& vec)
|
||||
{
|
||||
return vec.at_impl(mpl::int_<index>());
|
||||
}
|
||||
};
|
||||
|
||||
template <int index, typename Vector>
|
||||
struct set_lookup_key<index, void_&, unknown_key<index>, Vector>
|
||||
{
|
||||
static void_&
|
||||
call(Vector& vec); // intentionally undefined
|
||||
};
|
||||
}}}
|
||||
|
||||
#endif
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*=============================================================================
|
||||
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_SET_FORWARD_CTOR_09162005_1115)
|
||||
#define FUSION_SET_FORWARD_CTOR_09162005_1115
|
||||
|
||||
#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/set/detail/set_forward_ctor.hpp>
|
||||
#define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_SET_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
|
||||
set(BOOST_PP_ENUM_BINARY_PARAMS(
|
||||
N, typename detail::call_param<T, >::type _))
|
||||
: data(BOOST_PP_ENUM_PARAMS(N, _)) {}
|
||||
|
||||
#undef N
|
||||
#endif // defined(BOOST_PP_IS_ITERATING)
|
||||
|
128
include/boost/fusion/container/set/detail/set_lookup.hpp
Normal file
128
include/boost/fusion/container/set/detail/set_lookup.hpp
Normal file
@ -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_SET_LOOKUP_09162005_1116)
|
||||
#define FUSION_SET_LOOKUP_09162005_1116
|
||||
|
||||
#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/set/detail/set_lookup.hpp>
|
||||
#define BOOST_PP_ITERATION_LIMITS (0, BOOST_PP_DEC(FUSION_MAX_SET_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::set_key_type<BOOST_PP_CAT(T, N), N>::type, dummy>
|
||||
{
|
||||
typedef typename detail::set_value_type<BOOST_PP_CAT(T, N)>::type type;
|
||||
};
|
||||
|
||||
typename detail::set_data_type<BOOST_PP_CAT(T, N)>::type
|
||||
at_impl(mpl::identity<typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type>)
|
||||
{
|
||||
return detail::set_lookup_key<
|
||||
N
|
||||
, typename detail::set_data_type<BOOST_PP_CAT(T, N)>::type
|
||||
, typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type
|
||||
, storage_type>::call(data);
|
||||
}
|
||||
|
||||
typename detail::set_const_data_type<BOOST_PP_CAT(T, N)>::type
|
||||
at_impl(mpl::identity<typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type>) const
|
||||
{
|
||||
return detail::set_lookup_key<
|
||||
N
|
||||
, typename detail::set_const_data_type<BOOST_PP_CAT(T, N)>::type
|
||||
, typename detail::set_key_type<BOOST_PP_CAT(T, N), N>::type
|
||||
, storage_type const>::call(data);
|
||||
}
|
||||
|
||||
template <typename dummy>
|
||||
struct meta_find_impl<
|
||||
typename detail::set_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::set_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::set_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::set_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,35 @@
|
||||
/*=============================================================================
|
||||
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_09162005_1123)
|
||||
#define FUSION_VALUE_AT_KEY_IMPL_09162005_1123
|
||||
|
||||
#include <boost/mpl/at.hpp>
|
||||
|
||||
namespace boost { namespace fusion
|
||||
{
|
||||
struct set_tag;
|
||||
|
||||
namespace extension
|
||||
{
|
||||
template <typename Tag>
|
||||
struct value_at_key_impl;
|
||||
|
||||
template <>
|
||||
struct value_at_key_impl<set_tag>
|
||||
{
|
||||
template <typename Sequence, typename Key>
|
||||
struct apply
|
||||
{
|
||||
typedef typename Sequence::
|
||||
template meta_at_impl<Key>::type type;
|
||||
};
|
||||
};
|
||||
}
|
||||
}}
|
||||
|
||||
#endif
|
25
include/boost/fusion/container/set/limits.hpp
Normal file
25
include/boost/fusion/container/set/limits.hpp
Normal file
@ -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_SET_LIMITS_09162005_1103)
|
||||
#define FUSION_SET_LIMITS_09162005_1103
|
||||
|
||||
#include <boost/fusion/container/vector/limits.hpp>
|
||||
|
||||
#if !defined(FUSION_MAX_SET_SIZE)
|
||||
# define FUSION_MAX_SET_SIZE FUSION_MAX_VECTOR_SIZE
|
||||
#else
|
||||
# if FUSION_MAX_SET_SIZE < 3
|
||||
# undef FUSION_MAX_SET_SIZE
|
||||
# if (FUSION_MAX_VECTOR_SIZE > 10)
|
||||
# define FUSION_MAX_SET_SIZE 10
|
||||
# else
|
||||
# define FUSION_MAX_SET_SIZE FUSION_MAX_VECTOR_SIZE
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
71
include/boost/fusion/container/set/set.hpp
Normal file
71
include/boost/fusion/container/set/set.hpp
Normal file
@ -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_SET_09162005_1104)
|
||||
#define FUSION_SET_09162005_1104
|
||||
|
||||
#include <boost/fusion/support/sequence_base.hpp>
|
||||
#include <boost/fusion/support/category_of.hpp>
|
||||
#include <boost/fusion/support/detail/access.hpp>
|
||||
#include <boost/fusion/container/set/set_fwd.hpp>
|
||||
#include <boost/fusion/container/set/detail/lookup_key.hpp>
|
||||
#include <boost/fusion/container/set/detail/begin_impl.hpp>
|
||||
#include <boost/fusion/container/set/detail/end_impl.hpp>
|
||||
#include <boost/fusion/container/set/detail/at_key_impl.hpp>
|
||||
#include <boost/fusion/container/set/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 set_tag;
|
||||
struct fusion_sequence_tag;
|
||||
|
||||
template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_SET_SIZE, typename T)>
|
||||
struct set : sequence_base<set<BOOST_PP_ENUM_PARAMS(FUSION_MAX_SET_SIZE, T)> >
|
||||
{
|
||||
struct category : forward_traversal_tag, associative_sequence_tag {};
|
||||
|
||||
typedef set_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_SET_SIZE, T)>
|
||||
storage_type;
|
||||
|
||||
typedef typename storage_type::size size;
|
||||
|
||||
set()
|
||||
: data() {}
|
||||
|
||||
template <typename Sequence>
|
||||
set(Sequence const& rhs)
|
||||
: data(rhs) {}
|
||||
|
||||
#include <boost/fusion/container/set/detail/set_forward_ctor.hpp>
|
||||
#include <boost/fusion/container/set/detail/set_lookup.hpp>
|
||||
|
||||
template <typename T>
|
||||
set&
|
||||
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
|
24
include/boost/fusion/container/set/set_fwd.hpp
Normal file
24
include/boost/fusion/container/set/set_fwd.hpp
Normal file
@ -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_SET_FORWARD_09162005_1102)
|
||||
#define FUSION_SET_FORWARD_09162005_1102
|
||||
|
||||
#include <boost/fusion/container/set/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_SET_SIZE, typename T, void_)
|
||||
>
|
||||
struct set;
|
||||
}}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user