Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56910 - in sandbox/bitfield/libs/integer/doc: . html html/toward_boost_bitfield/appendices html/toward_boost_bitfield/users_guide
From: vicente.botet_at_[hidden]
Date: 2009-10-16 07:10:14


Author: viboes
Date: 2009-10-16 07:10:13 EDT (Fri, 16 Oct 2009)
New Revision: 56910
URL: http://svn.boost.org/trac/boost/changeset/56910

Log:
TBoost.Bitfield:
* Review version
Added:
   sandbox/bitfield/libs/integer/doc/index.html (contents, props changed)
Text files modified:
   sandbox/bitfield/libs/integer/doc/bitfield.qbk | 79 ++++++++++++++++++++++++++++++++
   sandbox/bitfield/libs/integer/doc/html/index.html | 2
   sandbox/bitfield/libs/integer/doc/html/toward_boost_bitfield/appendices/todo.html | 95 ++++++++++++++++++++++++++++++++++++++++
   sandbox/bitfield/libs/integer/doc/html/toward_boost_bitfield/users_guide/getting_started.html | 4
   4 files changed, 175 insertions(+), 5 deletions(-)

Modified: sandbox/bitfield/libs/integer/doc/bitfield.qbk
==============================================================================
--- sandbox/bitfield/libs/integer/doc/bitfield.qbk (original)
+++ sandbox/bitfield/libs/integer/doc/bitfield.qbk 2009-10-16 07:10:13 EDT (Fri, 16 Oct 2009)
@@ -9,8 +9,6 @@
     [quickbook 1.4]
     [authors [Botet Escriba, Vicente J.]]
     [copyright 2009 Vicente J. Botet Escriba]
- [id boost.bitfield]
- [dirname integer]
     [purpose Bitfield portable traits]
     [license
         Distributed under the Boost Software License, Version 1.0.
@@ -713,6 +711,83 @@
 
 [heading For later releases]
 
+[*Add bitfields group]
+
+Used to easily manipulate groups of bitfields the same way as does C bitfields, but in a portable manner. Example declaration:
+
+ struct Rgb565
+ {
+ struct red {};
+ struct green {};
+ struct blue {};
+ typedef bitfields<mpl::vector<
+ member<unsigned char, red, 5>,
+ member<unsigned char, green, 6>,
+ member<unsigned char, blue, 5>
+ > > type;
+ };
+
+Example usage:
+
+ Rgb565::type r = make_bitfields<Rgb565::type, 1,2,3>;
+
+ // Write to a bitfield.
+ r.get<Rgb565::red>() = 23;
+ //or
+ r.set<Rgb565::red>(23);
+
+ // Read from a bitfield
+ Rgb565::at<Rgb565::blue>::value_type b = r.get<Rgb565::blue>();
+
+
+Other posibility could be to use unamed bitfields whic are accessed as tuples.
+
+ typedef bitfields_group<mpl::vector_c<5,6,5> > Rgb565;
+ Rgb565 r;
+
+ r.get<0>() = 23;
+ // or
+ r.set<0>(23);
+
+ // Read from a bitfield
+ Rgb565::at<2>::value_type b = r.get<2>();
+
+
+[*Add pointer_plus_bits]
+
+Based on
+
+* The article of Joaquin [@http://bannalia.blogspot.com/2008/11/optimizing-red-black-tree-color-bits.html Optimizing red-black tree color bits],
+* the implementation of Ion [@http://www.boost.org/boost/boost/intrusive/pointer_plus_bits.hpp pointer_plus_bits from Boost.Intrusive ], and
+* [@https://llvm.org/svn/llvm-project/llvm/trunk/include/llvm/ADT/PointerIntPair.h Clang's QualType smart pointer]
+
+This class will allows to use the unsused bits of a pointer to reduce the size of the nodes containing pointers and bits and sometimes improving also the performances.
+
+I have not reached yet the interface I would like to have. For the moment we can do
+
+ typedef pointer_plus_bits<int*,1,bool>::type pint_and_bool;
+
+ int i=0;
+ pint_and_bool v1;
+ ASSERT_EQUALS(v1.pointer(),0);
+ ASSERT_EQUALS(v1.small_int(),false);
+ pint_and_bool v2(&i, true);
+ ASSERT_EQUALS(v2.pointer(),&i);
+ ASSERT_EQUALS(v2.small_int(),true);
+ v1.pointer()=v2.pointer();
+ v1.small_int()=true;
+ ASSERT_EQUALS(v1.pointer(),&i);
+ ASSERT_EQUALS(v1.small_int(),true);
+
+ typedef pointer_plus_bits<
+ pointer_plus_bits<int*,1,bool>::type
+ ,1, bool>::type pint_and_bool_bool
+ pint_and_bool_bool v1;
+ ASSERT_EQUALS(v1.small_int(),false);
+ ASSERT_EQUALS(v1.pointer().get_pointer(),0);
+ ASSERT_EQUALS(v1.get_pointer().get_pointer(),0);
+ ASSERT_EQUALS(v1.get_pointer().small_int(),false);
+
 
 [endsect]
 [endsect]

Modified: sandbox/bitfield/libs/integer/doc/html/index.html
==============================================================================
--- sandbox/bitfield/libs/integer/doc/html/index.html (original)
+++ sandbox/bitfield/libs/integer/doc/html/index.html 2009-10-16 07:10:13 EDT (Fri, 16 Oct 2009)
@@ -87,7 +87,7 @@
 </table></div>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: October 05, 2009 at 16:42:56 GMT</small></p></td>
+<td align="left"><p><small>Last revised: October 16, 2009 at 11:08:10 GMT</small></p></td>
 <td align="right"><div class="copyright-footer"></div></td>
 </tr></table>
 <hr>

Modified: sandbox/bitfield/libs/integer/doc/html/toward_boost_bitfield/appendices/todo.html
==============================================================================
--- sandbox/bitfield/libs/integer/doc/html/toward_boost_bitfield/appendices/todo.html (original)
+++ sandbox/bitfield/libs/integer/doc/html/toward_boost_bitfield/appendices/todo.html 2009-10-16 07:10:13 EDT (Fri, 16 Oct 2009)
@@ -42,6 +42,101 @@
         <a href="todo.html#toward_boost_bitfield.appendices.todo.for_later_releases">For
         later releases</a>
       </h4>
+<p>
+ <span class="bold"><strong>Add bitfields group</strong></span>
+ </p>
+<p>
+ Used to easily manipulate groups of bitfields the same way as does C bitfields,
+ but in a portable manner. Example declaration:
+ </p>
+<pre class="programlisting"><span class="keyword">struct</span> <span class="identifier">Rgb565</span>
+<span class="special">{</span>
+ <span class="keyword">struct</span> <span class="identifier">red</span> <span class="special">{};</span>
+ <span class="keyword">struct</span> <span class="identifier">green</span> <span class="special">{};</span>
+ <span class="keyword">struct</span> <span class="identifier">blue</span> <span class="special">{};</span>
+ <span class="keyword">typedef</span> <span class="identifier">bitfields</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span>
+ <span class="identifier">member</span><span class="special">&lt;</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">,</span> <span class="identifier">red</span><span class="special">,</span> <span class="number">5</span><span class="special">&gt;,</span>
+ <span class="identifier">member</span><span class="special">&lt;</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">,</span> <span class="identifier">green</span><span class="special">,</span> <span class="number">6</span><span class="special">&gt;,</span>
+ <span class="identifier">member</span><span class="special">&lt;</span><span class="keyword">unsigned</span> <span class="keyword">char</span><span class="special">,</span> <span class="identifier">blue</span><span class="special">,</span> <span class="number">5</span><span class="special">&gt;</span>
+ <span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">type</span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<p>
+ Example usage:
+ </p>
+<pre class="programlisting"><span class="identifier">Rgb565</span><span class="special">::</span><span class="identifier">type</span> <span class="identifier">r</span> <span class="special">=</span> <span class="identifier">make_bitfields</span><span class="special">&lt;</span><span class="identifier">Rgb565</span><span class="special">::</span><span class="identifier">type</span><span class="special">,</span> <span class="number">1</span><span class="special">,</span><span class="number">2</span><span class="special">,</span><span class="number">3</span><span class="special">&gt;;</span>
+
+<span class="comment">// Write to a bitfield.
+</span><span class="identifier">r</span><span class="special">.</span><span class="identifier">get</span><span class="special">&lt;</span><span class="identifier">Rgb565</span><span class="special">::</span><span class="identifier">red</span><span class="special">&gt;()</span> <span class="special">=</span> <span class="number">23</span><span class="special">;</span>
+<span class="comment">//or
+</span><span class="identifier">r</span><span class="special">.</span><span class="identifier">set</span><span class="special">&lt;</span><span class="identifier">Rgb565</span><span class="special">::</span><span class="identifier">red</span><span class="special">&gt;(</span><span class="number">23</span><span class="special">);</span>
+
+<span class="comment">// Read from a bitfield
+</span><span class="identifier">Rgb565</span><span class="special">::</span><span class="identifier">at</span><span class="special">&lt;</span><span class="identifier">Rgb565</span><span class="special">::</span><span class="identifier">blue</span><span class="special">&gt;::</span><span class="identifier">value_type</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">get</span><span class="special">&lt;</span><span class="identifier">Rgb565</span><span class="special">::</span><span class="identifier">blue</span><span class="special">&gt;();</span>
+</pre>
+<p>
+ Other posibility could be to use unamed bitfields whic are accessed as tuples.
+ </p>
+<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">bitfields_group</span><span class="special">&lt;</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">vector_c</span><span class="special">&lt;</span><span class="number">5</span><span class="special">,</span><span class="number">6</span><span class="special">,</span><span class="number">5</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">Rgb565</span><span class="special">;</span>
+<span class="identifier">Rgb565</span> <span class="identifier">r</span><span class="special">;</span>
+
+<span class="identifier">r</span><span class="special">.</span><span class="identifier">get</span><span class="special">&lt;</span><span class="number">0</span><span class="special">&gt;()</span> <span class="special">=</span> <span class="number">23</span><span class="special">;</span>
+<span class="comment">// or
+</span><span class="identifier">r</span><span class="special">.</span><span class="identifier">set</span><span class="special">&lt;</span><span class="number">0</span><span class="special">&gt;(</span><span class="number">23</span><span class="special">);</span>
+
+<span class="comment">// Read from a bitfield
+</span><span class="identifier">Rgb565</span><span class="special">::</span><span class="identifier">at</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;::</span><span class="identifier">value_type</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">r</span><span class="special">.</span><span class="identifier">get</span><span class="special">&lt;</span><span class="number">2</span><span class="special">&gt;();</span>
+</pre>
+<p>
+ <span class="bold"><strong>Add pointer_plus_bits</strong></span>
+ </p>
+<p>
+ Based on
+ </p>
+<div class="itemizedlist"><ul type="disc">
+<li>
+ The article of Joaquin <a href="http://bannalia.blogspot.com/2008/11/optimizing-red-black-tree-color-bits.html" target="_top">Optimizing
+ red-black tree color bits</a>,
+ </li>
+<li>
+ the implementation of Ion <a href="http://www.boost.org/boost/boost/intrusive/pointer_plus_bits.hpp" target="_top">pointer_plus_bits
+ from Boost.Intrusive </a>, and
+ </li>
+<li><a href="https://llvm.org/svn/llvm-project/llvm/trunk/include/llvm/ADT/PointerIntPair.h" target="_top">Clang's
+ QualType smart pointer</a></li>
+</ul></div>
+<p>
+ This class will allows to use the unsused bits of a pointer to reduce the
+ size of the nodes containing pointers and bits and sometimes improving also
+ the performances.
+ </p>
+<p>
+ I have not reached yet the interface I would like to have. For the moment
+ we can do
+ </p>
+<pre class="programlisting"><span class="keyword">typedef</span> <span class="identifier">pointer_plus_bits</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">*,</span><span class="number">1</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">pint_and_bool</span><span class="special">;</span>
+
+<span class="keyword">int</span> <span class="identifier">i</span><span class="special">=</span><span class="number">0</span><span class="special">;</span>
+<span class="identifier">pint_and_bool</span> <span class="identifier">v1</span><span class="special">;</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v1</span><span class="special">.</span><span class="identifier">pointer</span><span class="special">(),</span><span class="number">0</span><span class="special">);</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v1</span><span class="special">.</span><span class="identifier">small_int</span><span class="special">(),</span><span class="keyword">false</span><span class="special">);</span>
+<span class="identifier">pint_and_bool</span> <span class="identifier">v2</span><span class="special">(&amp;</span><span class="identifier">i</span><span class="special">,</span> <span class="keyword">true</span><span class="special">);</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v2</span><span class="special">.</span><span class="identifier">pointer</span><span class="special">(),&amp;</span><span class="identifier">i</span><span class="special">);</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v2</span><span class="special">.</span><span class="identifier">small_int</span><span class="special">(),</span><span class="keyword">true</span><span class="special">);</span>
+<span class="identifier">v1</span><span class="special">.</span><span class="identifier">pointer</span><span class="special">()=</span><span class="identifier">v2</span><span class="special">.</span><span class="identifier">pointer</span><span class="special">();</span>
+<span class="identifier">v1</span><span class="special">.</span><span class="identifier">small_int</span><span class="special">()=</span><span class="keyword">true</span><span class="special">;</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v1</span><span class="special">.</span><span class="identifier">pointer</span><span class="special">(),&amp;</span><span class="identifier">i</span><span class="special">);</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v1</span><span class="special">.</span><span class="identifier">small_int</span><span class="special">(),</span><span class="keyword">true</span><span class="special">);</span>
+
+<span class="keyword">typedef</span> <span class="identifier">pointer_plus_bits</span><span class="special">&lt;</span>
+ <span class="identifier">pointer_plus_bits</span><span class="special">&lt;</span><span class="keyword">int</span><span class="special">*,</span><span class="number">1</span><span class="special">,</span><span class="keyword">bool</span><span class="special">&gt;::</span><span class="identifier">type</span>
+ <span class="special">,</span><span class="number">1</span><span class="special">,</span> <span class="keyword">bool</span><span class="special">&gt;::</span><span class="identifier">type</span> <span class="identifier">pint_and_bool_bool</span>
+<span class="identifier">pint_and_bool_bool</span> <span class="identifier">v1</span><span class="special">;</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v1</span><span class="special">.</span><span class="identifier">small_int</span><span class="special">(),</span><span class="keyword">false</span><span class="special">);</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v1</span><span class="special">.</span><span class="identifier">pointer</span><span class="special">().</span><span class="identifier">get_pointer</span><span class="special">(),</span><span class="number">0</span><span class="special">);</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v1</span><span class="special">.</span><span class="identifier">get_pointer</span><span class="special">().</span><span class="identifier">get_pointer</span><span class="special">(),</span><span class="number">0</span><span class="special">);</span>
+<span class="identifier">ASSERT_EQUALS</span><span class="special">(</span><span class="identifier">v1</span><span class="special">.</span><span class="identifier">get_pointer</span><span class="special">().</span><span class="identifier">small_int</span><span class="special">(),</span><span class="keyword">false</span><span class="special">);</span>
+</pre>
 </div>
 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
 <td align="left"></td>

Modified: sandbox/bitfield/libs/integer/doc/html/toward_boost_bitfield/users_guide/getting_started.html
==============================================================================
--- sandbox/bitfield/libs/integer/doc/html/toward_boost_bitfield/users_guide/getting_started.html (original)
+++ sandbox/bitfield/libs/integer/doc/html/toward_boost_bitfield/users_guide/getting_started.html 2009-10-16 07:10:13 EDT (Fri, 16 Oct 2009)
@@ -66,7 +66,7 @@
           in your compiler include path.
         </p>
 <a name="toward_boost_bitfield.users_guide.getting_started.install.requirements"></a><h5>
-<a name="id4759738"></a>
+<a name="id4759737"></a>
           <a href="getting_started.html#toward_boost_bitfield.users_guide.getting_started.install.requirements">Requirements</a>
         </h5>
 <p>
@@ -75,7 +75,7 @@
           version in SVN trunk (even if older version should works also).
         </p>
 <a name="toward_boost_bitfield.users_guide.getting_started.install.exceptions_safety"></a><h5>
-<a name="id4759771"></a>
+<a name="id4759770"></a>
           <a href="getting_started.html#toward_boost_bitfield.users_guide.getting_started.install.exceptions_safety">Exceptions
           safety</a>
         </h5>

Added: sandbox/bitfield/libs/integer/doc/index.html
==============================================================================
--- (empty file)
+++ sandbox/bitfield/libs/integer/doc/index.html 2009-10-16 07:10:13 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=html/index.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+../../doc/html/integer.html
+</body>
+</html>


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