fusion: merge of associative iterators/views and the new fold interface

[SVN r58618]
This commit is contained in:
Christopher Schmidt
2010-01-01 22:00:21 +00:00
parent b605617c4f
commit cda74605fc
379 changed files with 28481 additions and 2185 deletions

View File

@ -45,6 +45,7 @@ namespace boost { namespace fusion {
sequence_base<deque<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)> >
{
typedef deque_tag fusion_tag;
typedef bidirectional_traversal_tag category;
typedef typename detail::deque_keyed_values<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)>::type base;
typedef typename detail::deque_initial_size<BOOST_PP_ENUM_PARAMS(FUSION_MAX_DEQUE_SIZE, T)>::type size;
typedef mpl::int_<size::value> next_up;

View File

@ -1,49 +0,0 @@
/*=============================================================================
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

View File

@ -1,56 +1,43 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_BEGIN_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_BEGIN_IMPL_HPP
namespace boost { namespace fusion
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
struct map_tag;
template <typename>
struct begin_impl;
namespace extension
template <>
struct begin_impl<map_tag>
{
template <typename Tag>
struct begin_impl;
template <>
struct begin_impl<map_tag>
template <typename Seq>
struct apply
{
template <typename Sequence>
struct apply
typedef
basic_iterator<
map_iterator_tag
, typename Seq::category
, Seq
, 0
>
type;
static type
call(Seq& seq)
{
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());
}
};
return type(seq,0);
}
};
}
}}
};
}}}
#endif

View File

@ -0,0 +1,48 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_MAP_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_DATA_IMPL_HPP
#include <boost/fusion/iterator/value_of.hpp>
#include <boost/fusion/iterator/deref.hpp>
#include <boost/fusion/support/detail/access.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/mpl/eval_if.hpp>
#include <boost/mpl/identity.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename result_of::value_of<It>::type::second_type data;
typedef typename
mpl::eval_if<
is_const<typename It::seq_type>
, detail::cref_result<mpl::identity<data> >
, detail::ref_result<mpl::identity<data> >
>::type
type;
static type
call(It const& it)
{
return deref(it).second;
}
};
};
}}}
#endif

View File

@ -0,0 +1,45 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_MAP_DETAIL_DEREF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_DEREF_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_impl;
template <>
struct deref_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::at<
typename mpl::if_<
is_const<typename It::seq_type>
, typename It::seq_type::storage_type const
, typename It::seq_type::storage_type
>::type
, typename It::index
>::type
type;
static type
call(It const& it)
{
return at<typename It::index>(it.seq->get_data());
}
};
};
}}}
#endif

View File

@ -1,53 +1,43 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>
#ifndef BOOST_FUSION_CONTAINER_MAP_DETAIL_END_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_END_IMPL_HPP
namespace boost { namespace fusion
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
struct map_tag;
template <typename>
struct end_impl;
namespace extension
template <>
struct end_impl<map_tag>
{
template <typename Tag>
struct end_impl;
template <>
struct end_impl<map_tag>
template <typename Seq>
struct apply
{
template <typename Sequence>
struct apply
typedef
basic_iterator<
map_iterator_tag
, typename Seq::category
, Seq
, Seq::size::value
>
type;
static type
call(Seq& seq)
{
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());
}
};
return type(seq,0);
}
};
}
}}
};
}}}
#endif

View File

@ -0,0 +1,32 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_MAP_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_KEY_OF_IMPL_HPP
#include <boost/fusion/container/map/detail/value_of_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
value_of_impl<map_iterator_tag>::
template apply<It>::type::first_type
type;
};
};
}}}
#endif

View File

@ -1,99 +0,0 @@
/*=============================================================================
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

View File

@ -1,128 +0,0 @@
/*=============================================================================
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)

View File

@ -1,33 +0,0 @@
/*=============================================================================
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

View File

@ -0,0 +1,32 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_DATA_IMPL_HPP
#include <boost/fusion/container/map/detail/value_of_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
value_of_impl<map_iterator_tag>::
template apply<It>::type::second_type
type;
};
};
}}}
#endif

View File

@ -0,0 +1,39 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_MAP_DETAIL_VALUE_OF_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_impl;
template <>
struct value_of_impl<map_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::value_at<
typename mpl::if_<
is_const<typename It::seq_type>
, typename It::seq_type::storage_type const
, typename It::seq_type::storage_type
>::type
, typename It::index
>::type
type;
};
};
}}}
#endif

View File

@ -11,11 +11,13 @@
#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/map/detail/value_of_impl.hpp>
#include <boost/fusion/container/map/detail/deref_data_impl.hpp>
#include <boost/fusion/container/map/detail/deref_impl.hpp>
#include <boost/fusion/container/map/detail/key_of_impl.hpp>
#include <boost/fusion/container/map/detail/value_of_data_impl.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/bool.hpp>
@ -23,13 +25,12 @@
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 {};
struct category : forward_traversal_tag, associative_tag {};
typedef map_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
@ -49,7 +50,6 @@ namespace boost { namespace fusion
: 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&

View File

@ -13,6 +13,8 @@
namespace boost { namespace fusion
{
struct void_;
struct map_tag;
struct map_iterator_tag;
template <
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(

View File

@ -1,49 +0,0 @@
/*=============================================================================
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

View File

@ -1,56 +1,43 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_BEGIN_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_BEGIN_IMPL_HPP
namespace boost { namespace fusion
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
struct set_tag;
template <typename>
struct begin_impl;
namespace extension
template <>
struct begin_impl<set_tag>
{
template <typename Tag>
struct begin_impl;
template <>
struct begin_impl<set_tag>
template <typename Seq>
struct apply
{
template <typename Sequence>
struct apply
typedef
basic_iterator<
set_iterator_tag
, typename Seq::category
, Seq
, 0
>
type;
static type
call(Seq& seq)
{
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());
}
};
return type(seq,0);
}
};
}
}}
};
}}}
#endif

View File

@ -0,0 +1,24 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_SET_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_DATA_IMPL_HPP
#include <boost/fusion/container/set/detail/deref_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_data_impl;
template <>
struct deref_data_impl<set_iterator_tag>
: deref_impl<set_iterator_tag>
{};
}}}
#endif

View File

@ -0,0 +1,45 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_SET_DETAIL_DEREF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_DEREF_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/at.hpp>
#include <boost/type_traits/is_const.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct deref_impl;
template <>
struct deref_impl<set_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::at<
typename mpl::if_<
is_const<typename It::seq_type>
, typename It::seq_type::storage_type const
, typename It::seq_type::storage_type
>::type
, typename It::index
>::type
type;
static type
call(It const& it)
{
return at<typename It::index>(it.seq->get_data());
}
};
};
}}}
#endif

View File

@ -1,53 +1,43 @@
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
Copyright (c) 2009 Christopher Schmidt
Distributed under the Boost Software License, Version 1.0. (See accompanying
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>
#ifndef BOOST_FUSION_CONTAINER_SET_DETAIL_END_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_END_IMPL_HPP
namespace boost { namespace fusion
#include <boost/fusion/iterator/basic_iterator.hpp>
namespace boost { namespace fusion { namespace extension
{
struct set_tag;
template <typename>
struct end_impl;
namespace extension
template <>
struct end_impl<set_tag>
{
template <typename Tag>
struct end_impl;
template <>
struct end_impl<set_tag>
template <typename Seq>
struct apply
{
template <typename Sequence>
struct apply
typedef
basic_iterator<
set_iterator_tag
, typename Seq::category
, Seq
, Seq::size::value
>
type;
static type
call(Seq& seq)
{
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());
}
};
return type(seq,0);
}
};
}
}}
};
}}}
#endif

View File

@ -0,0 +1,24 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_SET_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_KEY_OF_IMPL_HPP
#include <boost/fusion/container/set/detail/value_of_data_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct key_of_impl;
template <>
struct key_of_impl<set_iterator_tag>
: value_of_impl<set_iterator_tag>
{};
}}}
#endif

View File

@ -1,93 +0,0 @@
/*=============================================================================
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

View File

@ -1,128 +0,0 @@
/*=============================================================================
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)

View File

@ -1,35 +0,0 @@
/*=============================================================================
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

View File

@ -0,0 +1,24 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_DATA_IMPL_HPP
#include <boost/fusion/container/set/detail/value_of_data_impl.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_data_impl;
template <>
struct value_of_data_impl<set_iterator_tag>
: value_of_impl<set_iterator_tag>
{};
}}}
#endif

View File

@ -0,0 +1,34 @@
/*=============================================================================
Copyright (c) 2009 Christopher Schmidt
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_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_IMPL_HPP
#define BOOST_FUSION_CONTAINER_SET_DETAIL_VALUE_OF_IMPL_HPP
#include <boost/fusion/sequence/intrinsic/value_at.hpp>
namespace boost { namespace fusion { namespace extension
{
template <typename>
struct value_of_impl;
template <>
struct value_of_impl<set_iterator_tag>
{
template <typename It>
struct apply
{
typedef typename
result_of::value_at<
typename It::seq_type::storage_type
, typename It::index
>::type
type;
};
};
}}}
#endif

View File

@ -11,11 +11,13 @@
#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/set/detail/value_of_impl.hpp>
#include <boost/fusion/container/set/detail/deref_data_impl.hpp>
#include <boost/fusion/container/set/detail/deref_impl.hpp>
#include <boost/fusion/container/set/detail/key_of_impl.hpp>
#include <boost/fusion/container/set/detail/value_of_data_impl.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/bool.hpp>
@ -23,13 +25,12 @@
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 {};
struct category : forward_traversal_tag, associative_tag {};
typedef set_tag fusion_tag;
typedef fusion_sequence_tag tag; // this gets picked up by MPL
@ -49,7 +50,6 @@ namespace boost { namespace fusion
: 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&

View File

@ -13,6 +13,8 @@
namespace boost { namespace fusion
{
struct void_;
struct set_tag;
struct set_iterator_tag;
template <
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(