|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62211 - sandbox/SOC/2010/bit_masks
From: bbartmanboost_at_[hidden]
Date: 2010-05-25 14:40:43
Author: bbartman
Date: 2010-05-25 14:40:43 EDT (Tue, 25 May 2010)
New Revision: 62211
URL: http://svn.boost.org/trac/boost/changeset/62211
Log:
working on different interface ideas for both compile time runtime and a mixture of the two for differing bit mask and set operations.
Text files modified:
sandbox/SOC/2010/bit_masks/notes.txt | 59 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
Modified: sandbox/SOC/2010/bit_masks/notes.txt
==============================================================================
--- sandbox/SOC/2010/bit_masks/notes.txt (original)
+++ sandbox/SOC/2010/bit_masks/notes.txt 2010-05-25 14:40:43 EDT (Tue, 25 May 2010)
@@ -108,3 +108,62 @@
that is the goal for that psudo-data structure (psudo-data structure as it isn't
really intended to be instanced and doesn't store any actual data, just ICEs
(Integral Constant Expressions NOT Internal Compiler Errors.)).
+
+
+------- Interface Ides for test, set, clear and flip ---------
+
+
+Thoughts from standard bitset's set member function.
+
+What it does is take size_t, bool and if bool is true it sets all bits in the
+expression. So it would be best to have meta-functions (one which specializes on
+true) to do the exact same thing for a bit_mask on compile time.
+
+
+
+
+Compile time interface only.
+
+For operations on masks try what Andrew suggested:
+Functors for the different operations so the following would work for
+compile time.
+
+
+
+ Compile time set_bit meta-function
+
+// this would need to have a specialization for SetAll where set all is = to true.
+the setting of all bits is simply a shift to the right or left = to the width of
+the mask in bits then calling the ~ operator on the thing.
+
+
+// assuming T is some mask type.
+template <typename T, unsigned int N, bool SetAll = false >
+struct set_bit
+ :integral_mask< T::value_type, T::value >// <--- this will do all of the internal
+ // work as far as keeping types + value etc...
+{ };
+
+
+ Compile time test_bit meta-function
+
+This meta function should take one mask and an integral value and check to see
+of the bit value at the position indicated by the integral value is set or not.
+This meta-function will evaluate to true or false if the bit is or isn't false.
+
+template <typename T, unsigned int N>
+struct test_bit
+ :integral_constant< bool, (T::value & (low_bits<T::value_type,1>::value << N) >
+{ };
+
+
+ Compile time flip_bit meta-function
+
+template <typename T, unsigned int N = std::numeric_limits<unsigned int>::max >
+struct flip_bits
+
+compile time + runtime interface.
+
+
+runtime only interface.
+
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