Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62407 - sandbox/SOC/2010/bit_masks/lib/integer/doc
From: bbartmanboost_at_[hidden]
Date: 2010-06-03 12:09:32


Author: bbartman
Date: 2010-06-03 12:09:31 EDT (Thu, 03 Jun 2010)
New Revision: 62407
URL: http://svn.boost.org/trac/boost/changeset/62407

Log:
completed first draft of documentation for integral_mask type
Text files modified:
   sandbox/SOC/2010/bit_masks/lib/integer/doc/integral_mask.qbk | 30 +++++++++++++++++++++++++++++-
   1 files changed, 29 insertions(+), 1 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/lib/integer/doc/integral_mask.qbk
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/doc/integral_mask.qbk (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/doc/integral_mask.qbk 2010-06-03 12:09:31 EDT (Thu, 03 Jun 2010)
@@ -3,7 +3,8 @@
 [h3 Description]
 The `integral_mask` type is the most basic mask type. It is used to abstract all
 masks back to a simple integral type. This type is used similar to an
-`integral_constant` type from the boost.type_traits library.
+`integral_constant` type from the boost.type_traits library. The `integral_mask`
+template is located in the following header file: <boost/integer/integral_mask.hpp>.
 
 
 [h3 Template Signature]
@@ -40,6 +41,33 @@
 [h3 Examples]
 Examples and use cases related to the `integral_mask` type.
 
+Exaple:
+``
+#include <boost/integer/integral_mask.hpp>
+using namespace boost;
+
+int main() {
+ int bits = 255;
+
+ typedef integral_mask<int, 16> mask;
+ // mask has the folling binary value
+ // 0000 0000 0000 0000 0000 0000 0001 0110
+
+ // bits has binary value of:
+ // 0000 0000 0000 0000 0000 0000 0010 0101
+
+ // the following is a bitwise and operation
+ // which is done to bits using the integral_mask type
+ int new_bits = bits & mask();
+
+ // Resulting value of new_bits:
+ // 0000 0000 0000 0000 0000 0000 0000 0100
+ return 0;
+}
+``
+The implicit cast operator allows for simplicity, clairity of code. In the
+above example `mask()` could be replaced with `mask::value` to achieve the same
+result. The same applies to all other bitwise operators.
 
 [endsect]
 


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