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

@ -25,7 +25,7 @@ namespace boost { namespace fusion {
template<typename Sequence>
struct apply
{
struct type : random_access_traversal_tag, associative_sequence_tag {};
struct type : random_access_traversal_tag, associative_tag {};
};
};
}

View File

@ -0,0 +1,30 @@
/*=============================================================================
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_EXAMPLE_EXTENSION_DETAIL_DEREF_DATA_IMPL_HPP
#define BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_DEREF_DATA_IMPL_HPP
namespace example
{
struct example_struct_iterator_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct deref_data_impl;
template<>
struct deref_data_impl<example::example_struct_iterator_tag>
: deref_impl<example::example_struct_iterator_tag>
{};
}
}}
#endif

View File

@ -0,0 +1,42 @@
/*=============================================================================
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_EXAMPLE_EXTENSION_DETAIL_KEY_OF_IMPL_HPP
#define BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_KEY_OF_IMPL_HPP
#include <boost/mpl/if.hpp>
namespace fields
{
struct name;
struct age;
}
namespace example
{
struct example_struct_iterator_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct key_of_impl;
template<>
struct key_of_impl<example::example_struct_iterator_tag>
{
template<typename It>
struct apply
: mpl::if_c<!It::index::value, fields::name, fields::age>
{};
};
}
}}
#endif

View File

@ -0,0 +1,30 @@
/*=============================================================================
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_EXAMPLE_EXTENSION_DETAIL_VALUE_OF_DATA_IMPL_HPP
#define BOOST_FUSION_EXAMPLE_EXTENSION_DETAIL_VALUE_OF_DATA_IMPL_HPP
namespace example
{
struct example_struct_iterator_tag;
}
namespace boost { namespace fusion {
namespace extension
{
template<typename Tag>
struct value_of_data_impl;
template<>
struct value_of_data_impl<example::example_struct_iterator_tag>
: value_of_impl<example::example_struct_iterator_tag>
{};
}
}}
#endif

View File

@ -9,6 +9,7 @@
#define BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/support/category_of.hpp>
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <boost/mpl/int.hpp>
#include <boost/type_traits/add_const.hpp>
@ -21,6 +22,9 @@
#include "./detail/distance_impl.hpp"
#include "./detail/value_of_impl.hpp"
#include "./detail/equal_to_impl.hpp"
#include "./detail/key_of_impl.hpp"
#include "./detail/value_of_data_impl.hpp"
#include "./detail/deref_data_impl.hpp"
namespace example
{
@ -32,8 +36,6 @@ namespace example
namespace boost { namespace fusion {
struct random_access_traversal_tag;
namespace traits
{
template<typename Struct, int Pos>
@ -52,7 +54,11 @@ namespace example {
BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3);
typedef Struct struct_type;
typedef boost::mpl::int_<Pos> index;
typedef boost::fusion::random_access_traversal_tag category;
struct category
: boost::fusion::random_access_traversal_tag
, boost::fusion::associative_tag
{};
example_struct_iterator(Struct& str)
: struct_(str) {}

View File

@ -56,6 +56,9 @@ int main()
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_key<example::example_struct, fields::name>::type, std::string>));
BOOST_MPL_ASSERT((boost::is_same<result_of::value_at_key<example::example_struct, fields::age>::type, int>));
BOOST_TEST(deref_data(begin(bert)) == "bert");
BOOST_TEST(deref_data(next(begin(bert))) == 99);
BOOST_TEST(size(bert) == 2);
return boost::report_errors();