Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62974 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/details lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-06-15 11:31:55


Author: bbartman
Date: 2010-06-15 11:31:55 EDT (Tue, 15 Jun 2010)
New Revision: 62974
URL: http://svn.boost.org/trac/boost/changeset/62974

Log:
working on creating const reference types, hit small road block (bitfield doesn't have a constructor for const ref of the stroage type, now moving on to get the tuple working with boost.fusion
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 56 +++++++++++++++++++++++++++++++++++-----
   sandbox/SOC/2010/bit_masks/boost/integer/details/bitfield_tuple_impl.hpp | 46 --------------------------------
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp | 20 ++++++++++---
   3 files changed, 65 insertions(+), 57 deletions(-)

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-15 11:31:55 EDT (Tue, 15 Jun 2010)
@@ -16,6 +16,8 @@
 #include <boost/mpl/at.hpp>
 #include <boost/mpl/less.hpp>
 #include <boost/mpl/size.hpp>
+#include <string>
+
 
 
 namespace boost {
@@ -85,6 +87,14 @@
             :_ref( *reinterpret_cast<unsigned_storage_type*>(&ref) )
         { }
 
+ /** const Reference constructor.
+ * Because the bit_ref is an abstraction of a reference then it also
+ * must behave like a reference type.
+ */
+ bit_ref(storage_type const& ref)
+ :_ref( *reinterpret_cast<unsigned_storage_type const*>(&ref) )
+ { }
+
         /** copy constructor.
          * This is because references are copy construtible.
          */
@@ -241,8 +251,8 @@
>
>::type
>::type
- > const
- >::type
+ >
+ >::type const
     get() const {
          typedef bit_ref<
             typename mpl::deref<
@@ -260,6 +270,33 @@
 
     template <std::size_t Index>
     inline typename enable_if<
+ typename mpl::less<
+ mpl::size_t<
+ Index
+ >,
+ mpl::size<
+ members
+ >
+ >,
+ bit_ref<
+ typename mpl::at_c<
+ members,
+ Index
+ >::type
+ >
+ >::type
+ get() {
+ typedef bit_ref<
+ typename mpl::at_c<
+ members,
+ Index
+ >::type
+ > reference_info;
+ return reference_info(_data);
+ }
+
+ template <std::size_t Index>
+ inline typename enable_if<
             typename mpl::less<
                 mpl::size_t<
                     Index
@@ -268,17 +305,22 @@
                     members
>
>,
- typename bit_ref<
+ bit_ref<
                 typename mpl::at_c<
                     members,
                     Index
>::type
+ >
+ >::type const
+ get() const {
+ typedef bit_ref<
+ typename mpl::at_c<
+ members,
+ Index
>::type
- >::type
- get() {
-
+ > const reference_info;
+ return reference_info( _data );
     }
-
     //@}
 
 private:

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bitfield_tuple_impl.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bitfield_tuple_impl.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bitfield_tuple_impl.hpp 2010-06-15 11:31:55 EDT (Tue, 15 Jun 2010)
@@ -15,7 +15,6 @@
 #include <boost/integer/bit_width.hpp>
 
 // std includes
-#include <string>
 #include <cstddef>
 
 // Other boost includes.
@@ -119,31 +118,6 @@
 
     typedef typename storage_policy::storage_type storage_type;
 
- // this is only defined if the storage type is a type that is not the
- // storage_policy_stack which makes this class simple use a stack to
- // allocate its storage. This leaves an option for the user to select an
- // allocator.
- typedef typename mpl::if_<
- is_same<
- typename storage_policy::alloc,
- storage_policy_stack
- >,
- typename mpl::void_,
- storage_policy
- >::type allocator;
-
- // get the template to be used as base class so that the bitfield_tuple
- // class itself can inherit from it.
- typedef typename mpl::if_<
- is_same<
- allocator,
- mpl::void_
- >,
- stack_alloc_base_policy<storage_type>,
- allocator_wraper_base_policy< storage_type, allocator >
- >::type allocation_base_policy;
-
-
 
 
     // Precondition: storage_type must not be an array type.
@@ -162,26 +136,8 @@
         bit_width< storage_type >::value
     ));
 
- /** Meta-calculations used for enabling and disabling functionality based
- * on the allocation policy, number of members, endianness of storage type
- * signedness of internal storage type and other such things.
- * The main reason for creating a class such as this is that it makes
- * the readability of bitfield_tupe higher.
- * This will also allow me to quickly deduce whether or not two bft types
- * are equivilant based on a simple set of concepts about the type itself.
- *
- */
- typedef typename is_same<
- allocator,
- mpl::void_
- >::type is_allocator_allocated;
-
- typedef typename is_same<
- typename storage_policy::alloc,
- storage_policy_stack
- >::type is_stack_allocated;
-
 };
+
 }} // end boost::details
 
 #undef BOOST_BFT_ARG_PROCESSING

Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp 2010-06-15 11:31:55 EDT (Tue, 15 Jun 2010)
@@ -9,6 +9,7 @@
 
 
 using namespace boost;
+
 struct red;
 struct green;
 struct pink;
@@ -21,10 +22,6 @@
     storage<std::size_t>,
     member<int, salmon, 16>
> test_tuple;
-template <typename T>
-void const_interface_testing(T const& x) {
-
-}
 
 
 int main() {
@@ -38,9 +35,22 @@
         BOOST_ASSERT((test_1.get<red>() == 14));
         BOOST_ASSERT(( test_1.get<salmon>() == 6));
 
+/* BOOST_ASSERT((
+ const_cast<
+ test_tuple const&
+ >(test_1).get<salmon>() == 6
+ ));
+*/
+ // XXX fix this at a later time maybe in a subsequent draft of the
+ // data structure.
         // testing negative values
- test_1.get<salmon>() = -6;
+ // test_1.get<salmon>() = -6;
         //BOOST_ASSERT(( test_1.get<salmon>() == -6));
     }
+ {
+
+ }
     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