Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62886 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/details/bft lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-06-12 19:20:39


Author: bbartman
Date: 2010-06-12 19:20:38 EDT (Sat, 12 Jun 2010)
New Revision: 62886
URL: http://svn.boost.org/trac/boost/changeset/62886

Log:
working on implementing get function now moving to the testing of the get functions
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 93 +++++++++++++++++++++++++++++++++++++++
   sandbox/SOC/2010/bit_masks/boost/integer/details/bft/stack_allocation_policy.hpp | 4
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_interface_test.cpp | 43 ++++++++++++++++++
   3 files changed, 136 insertions(+), 4 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-12 19:20:38 EDT (Sat, 12 Jun 2010)
@@ -8,6 +8,11 @@
 #define BOOST_BITFIELD_TUPLE_HPP
 #include <boost/integer/details/bitfield_tuple_impl.hpp>
 #include <boost/bitfield/bitfield.hpp>
+#include <boost/integer/details/bft/name_lookup.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/mpl/deref.hpp>
+#include <boost/type_traits.hpp>
 
 namespace boost {
 
@@ -167,10 +172,94 @@
 
 
     /** Get function interfaces.
- * These provide access into the tuple.
+ * These provide access into the tuple via "reference".
+ * If an invalid index or name is provided then then the user will cause
+ * look up failure.
      */
     //@{
-
+ template <typename Name>
+ inline typename disable_if<
+ is_same <
+ typename mpl::find_if<
+ members,
+ details::match_name<
+ mpl::_1,
+ Name
+ >
+ >::type,
+ typename mpl::end<
+ members
+ >::type
+ >,
+ bit_ref<
+ typename mpl::deref<
+ typename mpl::find_if<
+ members,
+ details::match_name<
+ mpl::_1,
+ Name
+ >
+ >::type
+ >::type
+ >
+ >::type
+ get() {
+ typedef bit_ref<
+ typename mpl::deref<
+ typename mpl::find_if<
+ members,
+ details::match_name<
+ mpl::_1,
+ Name
+ >
+ >::type
+ >::type
+ > reference_info;
+ return reference_info( this->get_data() );
+ }
+
+
+ template <typename Name>
+ inline typename disable_if<
+ is_same <
+ typename mpl::find_if<
+ members,
+ details::match_name<
+ mpl::_1,
+ Name
+ >
+ >::type,
+ typename mpl::end<
+ members
+ >::type
+ >,
+ bit_ref<
+ typename mpl::deref<
+ typename mpl::find_if<
+ members,
+ details::match_name<
+ mpl::_1,
+ Name
+ >
+ >::type
+ >::type
+ > const
+ >::type
+ get() const {
+ typedef bit_ref<
+ typename mpl::deref<
+ typename mpl::find_if<
+ members,
+ details::match_name<
+ mpl::_1,
+ Name
+ >
+ >::type
+ >::type
+ > const reference_info;
+ return reference_info( this->get_data() );
+ }
+
     //@}
 };
 

Modified: sandbox/SOC/2010/bit_masks/boost/integer/details/bft/stack_allocation_policy.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/details/bft/stack_allocation_policy.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bft/stack_allocation_policy.hpp 2010-06-12 19:20:38 EDT (Sat, 12 Jun 2010)
@@ -40,8 +40,8 @@
      * Returns a copy of _data.
      */
     //@{
- T const get_data() const { return _data; }
- T get_data() { return _data; }
+ T const& get_data() const { return _data; }
+ T& get_data() { return _data; }
     //@}
 
     T _data;

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-12 19:20:38 EDT (Sat, 12 Jun 2010)
@@ -0,0 +1,43 @@
+// Copyright 2010 Brian Bartman.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#include <boost/integer/bitfield_tuple.hpp>
+#include <boost/assert.hpp>
+
+
+using namespace boost;
+struct red;
+struct green;
+struct pink;
+struct blue;
+struct salmon;
+
+
+
+
+int main() {
+
+
+ // tesitng so I can learn to use mpl::find_if
+ // for looking up while useing the get<> function in side bitfield_tuple.
+ typedef mpl::find_if<
+ test_vect,
+ details::match_name<
+ mpl::_1,
+ red
+ >
+ >::type temp_located;
+
+ BOOST_MPL_ASSERT_NOT((
+ is_same<
+ temp_located,
+ mpl::end<
+ test_vect
+ >::type
+ >
+ ));
+ 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