|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62458 - in sandbox/SOC/2010/bit_masks/boost/integer: . details
From: bbartmanboost_at_[hidden]
Date: 2010-06-05 18:14:55
Author: bbartman
Date: 2010-06-05 18:14:53 EDT (Sat, 05 Jun 2010)
New Revision: 62458
URL: http://svn.boost.org/trac/boost/changeset/62458
Log:
completed porting into fusion now moving on to the testing of fusion integration with bit_mask_group sequence
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp | 6
sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_group_impl.hpp | 250 +++++++++++++++++++++++++++++++++++++--
2 files changed, 240 insertions(+), 16 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp 2010-06-05 18:14:53 EDT (Sat, 05 Jun 2010)
@@ -15,7 +15,7 @@
#include <boost/mpl/insert.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/at.hpp>
-
+#include <boost/mpl/void.hpp>
@@ -37,8 +37,8 @@
// TODO: move this into a sperate file
namespace details {
-struct null_mask { };
-typedef null_mask unused_parameter;
+
+typedef mpl::void_ unused_parameter;
/** This is a metafunction which is used for filling an mpl::vector with
* types which arn't of type unused parameter.
Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_group_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_group_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bit_mask_group_impl.hpp 2010-06-05 18:14:53 EDT (Sat, 05 Jun 2010)
@@ -5,11 +5,13 @@
#ifndef BOOST_BIT_MASK_GROUP_IMPL_HPP
#define BOOST_BIT_MASK_GROUP_IMPL_HPP
-
#include <boost/fusion/support/tag_of_fwd.hpp>
#include <boost/fusion/include/tag_of_fwd.hpp>
#include <boost/fusion/support/iterator_base.hpp>
#include <boost/fusion/support/category_of.hpp>
+#include <boost/type_traits.hpp>
+#include <boost/mpl/minus.hpp>
+#include <boost/mpl/size.hpp>
/** This is used for creating an extention into the boost fusion library for
* the bit_mask_group.
@@ -52,19 +54,19 @@
/** This is my sequence for iteration over the items in bit_mask_group. */
-template<typename Struct, int Pos>
+template<typename MaskGroup, int Pos>
struct bit_mask_group_iterator
- : boost::fusion::iterator_base< bit_mask_group_iterator<Struct, Pos> >
+ : boost::fusion::iterator_base< bit_mask_group_iterator<MaskGroup, Pos> >
{
// TODO: At a later time add preconditions for the iterator.
// BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3);
- typedef Struct struct_type;
+ typedef MaskGroup mask_group;
typedef boost::mpl::int_<Pos> index;
typedef boost::fusion::random_access_traversal_tag category;
- bit_mask_group_iterator(Struct& str) { }
+ // bit_mask_group_iterator(Struct& str) { }
- Struct& struct_;
+ // Struct& struct_;
};
namespace details {
@@ -79,30 +81,252 @@
namespace boost { namespace fusion { namespace traits {
template<>
- template <typename Struct, int Pos>
- struct tag_of< boost::bit_mask_group_iterator<Struct,Pos> > {
+ template <typename MaskGroup, int Pos>
+ struct tag_of< boost::bit_mask_group_iterator<MaskGroup,Pos> > {
typedef boost::details::bit_mask_group_iterator_tag type;
};
}}} // end boost::fusion::traits
namespace boost { namespace fusion { namespace extension {
-template<typename T>
+
+template<typename>
struct value_at_impl;
template <>
-struct value_at_impl<details::bit_mask_group_iterator_tag> {
+struct value_at_impl< boost::details::bit_mask_group_iterator_tag > {
+ template<typename Iterator>
+ struct apply;
+
+ template<typename MaskGroup, int Pos>
+ struct apply< boost::bit_mask_group_iterator<MaskGroup, Pos> > {
+ typedef typename MaskGroup::template get_by_index<Pos>::type type;
+ };
+};
+
+template <typename>
+struct deref_impl;
+
+template<>
+struct deref_impl<boost::details::bit_mask_group_iterator_tag >
+{
template<typename Iterator>
struct apply;
+ template<typename MaskGroup, int Pos>
+ struct apply< boost::bit_mask_group_iterator<MaskGroup,Pos> > {
+ typedef typename MaskGroup::template get_by_index<Pos>::type mask_type;
+
+ static typename mask_type::value_type
+ call(boost::bit_mask_group_iterator<MaskGroup,Pos> const&) {
+ return mask_type::value;
+ }
+ };
+};
+
+template <typename>
+struct next_impl;
+
+template<>
+struct next_impl< boost::details::bit_mask_group_iterator_tag > {
+
+ template<typename Iterator>
+ struct apply {
+ typedef typename Iterator::mask_group mask_group;
+ typedef typename Iterator::index index;
+ typedef boost::bit_mask_group_iterator<
+ mask_group,
+ index::value + 1
+ > type;
+
+ static type call(Iterator const&) {
+ return type();
+ }
+ };
+};
+
+template <typename>
+struct prior_impl;
+
+template <>
+struct prior_impl< boost::details::bit_mask_group_iterator_tag > {
+ template <typename Iterator>
+ struct apply {
+ typedef typename Iterator::mask_group mask_group;
+ typedef typename Iterator::index index;
+ typedef typename boost::bit_mask_group_iterator<
+ mask_group,
+ index::value-1
+ > type;
+
+ static type call(Iterator const&) {
+ return type();
+ }
+ };
+};
+
+template <typename>
+struct advance_impl;
+
+template <>
+struct advance_impl< boost::details::bit_mask_group_iterator_tag > {
+
+ template <typename Iterator, typename N>
+ struct apply {
+ typedef typename Iterator::mask_group mask_group;
+ typedef typename Iterator::index index;
+ typedef typename boost::bit_mask_group_iterator<
+ mask_group,
+ index::value+N::value
+ > type;
+
+ static type
+ call(Iterator const&) {
+ return type();
+ }
+ };
+};
+
+template <typename>
+struct distance_impl;
- template<typename Struct, int Pos>
- struct apply<boost::bit_mask_group_iterator<Struct,Pos> > {
- typedef typename Struct::template get_by_index<Pos>::type type;
+template <>
+struct distance_impl< boost::details::bit_mask_group_iterator_tag > {
+ template <typename First, typename Last>
+ struct apply
+ : mpl::minus< typename Last::index, typename First::index>
+ {
+ static typename mpl::minus<
+ typename Last::index,
+ typename First::index
+ >::type
+ call(First const&, Last const&) {
+ typedef typename mpl::minus<
+ typename Last::index,
+ typename First::index
+ >::type result;
+
+ return result();
+ }
};
};
+template <typename>
+struct equal_to_impl;
+
+template <>
+struct equal_to_impl< boost::details::bit_mask_group_iterator_tag > {
+ template <typename I1, typename I2>
+ struct apply
+ : is_same<
+ typename I1::identity,
+ typename I2::identity
+ >::type
+ { };
+};
+
+template<typename>
+struct is_sequence_impl;
+
+template<>
+struct is_sequence_impl< boost::details::bit_mask_group_tag > {
+ template<typename T>
+ struct apply : mpl::true_ { };
+};
+
+template <typename>
+struct is_view_impl;
+
+template <>
+struct is_view_impl< boost::details::bit_mask_group_tag > {
+ template <typename Sequence>
+ struct apply : mpl::false_ { };
+};
+
+template<typename>
+struct begin_impl;
+
+template<>
+struct begin_impl< boost::details::bit_mask_group_tag > {
+ template<typename MaskGroup>
+ struct apply {
+ typedef boost::bit_mask_group_iterator<MaskGroup, 0> type;
+ static type call(MaskGroup&) {
+ return type();
+ }
+ };
+};
+
+
+template<typename>
+struct size_impl;
+
+template<>
+struct size_impl< boost::details::bit_mask_group_tag > {
+ template<typename MaskGroup>
+ struct apply
+ : mpl::size< typename MaskGroup::mask_vector >
+ { };
+};
+
+template<typename>
+struct value_at_impl;
+
+template <>
+struct value_at_impl< boost::details::bit_mask_group_tag > {
+ template <typename MaskGroup, typename N>
+ struct apply {
+ typedef typename MaskGroup::
+ template get_by_index<
+ N::value
+ >::type
+ type;
+ };
+};
+
+
+template<typename>
+struct at_impl;
+
+template<>
+struct at_impl< boost::details::bit_mask_group_tag > {
+ template <typename MaskGroup, typename N>
+ struct apply {
+ typedef typename MaskGroup::
+ template get_by_index<
+ N::value
+ >::type
+ type;
+ static typename type::value_type call(MaskGroup&) {
+ return type::value;
+ }
+ };
+};
+
+
+template<typename>
+struct at_key_impl;
+
+template<>
+struct at_key_impl< boost::details::bit_mask_group_tag > {
+
+ template<typename MaskGroup, typename Key>
+ struct apply {
+ typedef typename MaskGroup::
+ template get_by_name<
+ Key
+ >::type
+ type;
+
+ static typename type::value_type call(MaskGroup&) {
+ return type::value;
+ }
+ };
+};
+
+
}}} // end boost::fusion::extention
#endif
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk