Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63291 - in sandbox/SOC/2010/bit_masks/boost: bitfield integer
From: bbartmanboost_at_[hidden]
Date: 2010-06-24 13:13:20


Author: bbartman
Date: 2010-06-24 13:13:18 EDT (Thu, 24 Jun 2010)
New Revision: 63291
URL: http://svn.boost.org/trac/boost/changeset/63291

Log:
one small step closer to being able to being able to only use one reference type
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/bitfield/bitfield.hpp | 4 ++++
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 21 ++++++++-------------
   2 files changed, 12 insertions(+), 13 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/bitfield/bitfield.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/bitfield/bitfield.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/bitfield/bitfield.hpp 2010-06-24 13:13:18 EDT (Thu, 24 Jun 2010)
@@ -73,6 +73,10 @@
     #endif
 
     namespace detail {
+ // allows the user to make an explicit call to the copy constructor when
+ // the types that are convertible conflict with one another.
+ struct foce_copy { };
+
         template <bool is_signed, typename value_type
                 , typename storage_type, unsigned int WIDTH, unsigned int SIGN_MASK>
         struct bitfield_complete_signed;

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp 2010-06-24 13:13:18 EDT (Thu, 24 Jun 2010)
@@ -346,7 +346,7 @@
          * storage_type.
          */
         typedef typename integer::bitfield<
- unsigned_storage_type,
+ storage_type,
             MaskInfo::offset::value,
             MaskInfo::offset::value + MaskInfo::field_width::value - 1,
             return_type
@@ -354,8 +354,8 @@
 
 
         /** Reference constructor. */
- bitfield_ref(storage_type& ref)
- :_ref( *reinterpret_cast<unsigned_storage_type*>(&ref) )
+ explicit bitfield_ref(storage_type& ref)
+ :_ref( ref )
         { }
 
 
@@ -398,17 +398,14 @@
     struct const_bitfield_ref {
     private:
         typedef bitfield_ref<MaskInfo> _self;
- typedef typename make_unsigned<
- storage_type
- >::type const unsigned_storage_type;
     public:
- typedef typename MaskInfo::return_type return_type;
+ typedef typename MaskInfo::return_type return_type;
 
         /** Internals bitfield type for extracting individual fields from
          * within the storage_type.
          */
         typedef typename integer::bitfield<
- unsigned_storage_type,
+ const storage_type,
             MaskInfo::offset::value,
             MaskInfo::offset::value + MaskInfo::field_width::value - 1,
             return_type
@@ -416,15 +413,15 @@
 
 
         /** Reference constructor. */
- const_bitfield_ref(storage_type const& ref)
- :_ref( *reinterpret_cast<unsigned_storage_type*>(&ref) )
+ explicit const_bitfield_ref(storage_type const& ref)
+ :_ref( ref )
         { }
 
         /** copy constructor.
          * This is because references are copy constructible.
          */
         const_bitfield_ref( bitfield_ref<MaskInfo> const& x)
- :_ref( x.ref )
+ :_ref( x.ref)
         { }
         
         /** Implicit conversion operator
@@ -455,8 +452,6 @@
         :_data( x.data() )
     { }
 
-
-
     /** Assignment from an integer
      * Allows for the user to assign a type which they wish for this type to
      * access.


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