|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62336 - in sandbox/SOC/2010/bit_masks: boost/integer lib/integer/test
From: bbartmanboost_at_[hidden]
Date: 2010-05-30 16:38:23
Author: bbartman
Date: 2010-05-30 16:38:22 EDT (Sun, 30 May 2010)
New Revision: 62336
URL: http://svn.boost.org/trac/boost/changeset/62336
Log:
Started work on bit_mask_group however having named types might hurt a little. that is going to be slightly harder to deal with then I expect.
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bit_mask_group.hpp | 55 ++++++++++++++++++++++++++++++++++-----
sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_group_test.cpp | 2
2 files changed, 49 insertions(+), 8 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-05-30 16:38:22 EDT (Sun, 30 May 2010)
@@ -9,7 +9,7 @@
#include <boost/integer/compound_mask.hpp>
-// #include <boost/mpl/vector.hpp>
+#include <boost/mpl/vector.hpp>
#include <boost/mpl/if.hpp>
@@ -22,13 +22,47 @@
struct null_mask { };
typedef null_mask unused_parameter;
+/** This is a metafunction which is used for filling an mpl::vector with
+ * types which arn't of type unused parameter.
+ */
template <typename T, typename TypeVector>
-struct add_to_vector{
- template <typename NewT, typename NewTypeVector>
- struct rebind {
+struct add_to_vector {
+
+ typedef add_to_vector< T, TypeVector> type;
+ typedef T type_added;
+ typedef typename mpl::push_back<TypeVector, T>::type vector_type;
+
+
+ // adds to the back of the vector and calls this meta function again.
+ template <typename NewT>
+ struct add {
+ typedef add_to_vector< NewT, vector_type> type;
};
+
+
};
+
+/** Specialization for unused parameters.
+ * This is the case where the parameter wasn't used by the user and is instead
+ * going to be ignored, however its behavior is going to similar to that of
+ * the more general form above.
+ */
+template <typename TypeVector>
+struct add_to_vector< unused_parameter, TypeVector > {
+ typedef add_to_vector< unused_parameter, TypeVector> type;
+ typedef unused_parameter type_added;
+ typedef TypeVector vector_type;
+
+ // fake adding the parameter to the TypeVector instead do nothing.
+ template <typename NewT>
+ struct add {
+ typedef add_to_vector<NewT, TypeVector> type;
+ };
+};
+
}
+
+
template < typename Mask0,
typename Mask1 = details::unused_parameter,
typename Mask2 = details::unused_parameter,
@@ -41,10 +75,17 @@
typename Mask9 = details::unused_parameter
>
struct bit_mask_group
- // if they are the same then do nothing? if they arn't the same
- // that means that I located a mask or something to be part of
- // the mask group.
+ :details::add_to_vector<Mask1,mpl::vector<Mask0> >::
+ template add<Mask2>::type::
+ template add<Mask3>::type::
+ template add<Mask4>::type::
+ template add<Mask5>::type::
+ template add<Mask6>::type::
+ template add<Mask7>::type::
+ template add<Mask8>::type::
+ template add<Mask9>::type::vector_type
{
+
// typedef typename mpl::if_<
// is_same<Mask1,typename details::unused_parameter>,
// Mask1,
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_group_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_group_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bit_mask_group_test.cpp 2010-05-30 16:38:22 EDT (Sun, 30 May 2010)
@@ -9,6 +9,6 @@
int main() {
-
+ typedef bit_mask_group< low_bits<int,9>, bit_mask<int,3,9> > testing_type1;
return 0;
}
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