|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63294 - in sandbox/SOC/2010/bit_masks: boost/integer boost/integer/details/bft lib/integer/test lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-06-24 14:58:07
Author: bbartman
Date: 2010-06-24 14:58:06 EDT (Thu, 24 Jun 2010)
New Revision: 63294
URL: http://svn.boost.org/trac/boost/changeset/63294
Log:
working on fixing internal reference type issues.
Added:
sandbox/SOC/2010/bit_masks/boost/integer/details/bft/reference_builder.hpp (contents, props changed)
sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/reference_builder_test.cpp (contents, props changed)
Text files modified:
sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple.hpp | 33 ++++++++++++++++++++++++++++-----
sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 | 2 ++
2 files changed, 30 insertions(+), 5 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-24 14:58:06 EDT (Thu, 24 Jun 2010)
@@ -17,6 +17,7 @@
#include <boost/mpl/at.hpp>
#include <boost/mpl/less.hpp>
#include <boost/mpl/size.hpp>
+#include <boost/integer/details/bft/reference_builder.hpp>
#include <boost/integer/details/bft/ext/bitfield_tuple_fusion_includes.hpp>
#include <boost/integer/details/fusion_ext_includes.hpp>
@@ -327,6 +328,31 @@
typedef typename _base::field_vector members;
typedef typename _base::storage_type storage_type;
typedef typename _base::offset bits_used;
+
+
+ /** Second revision of the proxy reference type this one deal better
+ * with const qualifiers and reduce the number of reference types from
+ * two to one.
+ */
+ template <typename BitfieldElement>
+ struct bitfield_reference {
+ private:
+ typedef bitfield_reference<BitfieldElement> _self;
+ public:
+
+ /*typedef typename integer::bitfield<
+ storage_type,
+ MaskInfo::offset::value,
+ MaskInfo::offset::value + MaskInfo::field_width::value - 1,
+ return_type
+ > field_type;
+
+
+ private:
+ field_type field_;
+ */
+ };
+
/** Proxy type returned by get functions.
* This serves as the go between things within this class.
@@ -335,9 +361,6 @@
struct bitfield_ref {
private:
typedef bitfield_ref<MaskInfo> _self;
- typedef typename make_unsigned<
- storage_type
- >::type unsigned_storage_type;
public:
typedef typename MaskInfo::return_type return_type;
@@ -363,7 +386,7 @@
* This is because references are copy constructible.
*/
bitfield_ref( bitfield_ref<MaskInfo> const& x)
- :_ref( x._ref )
+ :_ref( x._ref)
{ }
/** Implicit conversion operator
@@ -503,7 +526,7 @@
members
>::type
>
- >::type type;
+ >::type type;
};
/** Get function interfaces.
Added: sandbox/SOC/2010/bit_masks/boost/integer/details/bft/reference_builder.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bit_masks/boost/integer/details/bft/reference_builder.hpp 2010-06-24 14:58:06 EDT (Thu, 24 Jun 2010)
@@ -0,0 +1,116 @@
+// 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)
+
+
+#ifndef BOOST_BITFIELD_TUPLE_REFERENCE_BUILDER_HPP
+#define BOOST_BITFIELD_TUPLE_REFERENCE_BUILDER_HPP
+#include <boost/static_assert.hpp>
+
+
+
+/** The meta functions contained within this file are meant to aid in the
+ * locating the correct value within member and deducing the correct constness
+ * and returning the correct reference type which will allow for only one
+ * reference type class within bitfield_tuple.
+ */
+namespace boost { namespace detials {
+
+
+
+/** Checks to see if a name exists.
+ * returns mpl::true_ or mpl::false_
+ */
+template <typename BitfieldTuple, typename Name>
+struct name_exists {
+ typedef typename mpl::not_<
+ is_same <
+ typename ::boost::mpl::find_if<
+ typename BitfieldTuple::members,
+ details::match_name<
+ mpl::_1,
+ Name
+ >
+ >::type,
+ typename mpl::end<
+ typename BitfieldTuple::members
+ >::type
+ >
+ >::type type;
+};
+
+/** Returns an element by which has a given name. */
+template <typename BitfieldTuple, typename Name>
+struct find_by_element_name {
+
+ BOOST_STATIC_ASSERT(( name_exists<BitfieldTuple,Name>::type::value ));
+
+ typedef typename mpl::deref<
+ typename mpl::find_if<
+ typename BitfieldTuple::members,
+ details::match_name<
+ mpl::_1,
+ Name
+ >
+ >::type
+ >::type type;
+};
+
+/** Returns an element from members within bitfield_tuple
+ * at a given index.
+ */
+template <typename BitfieldTuple, std::size_t Index>
+struct find_by_element_index {
+
+ BOOST_STATIC_ASSERT((
+ mpl::size<typename BitfieldTuple::members>::value
+ >
+ Index
+ ));
+
+ typedef typename mpl::at_c<
+ typename BitfieldTuple::members,
+ Index
+ >::type type;
+};
+
+
+
+
+/** Used for building the proxy reference types based on a given name.
+ * The CV qualifiers refer to CV qualifiers which are applied to another type
+ * then used by then used for the creation of a reference type that has the
+ * correct qualifiers. This will take most or all of the guess work out of
+ * creating reference types when needed.
+ */
+template <typename BitfieldTuple, typename Name, typename CVQualifiers>
+struct make_reference_type_by_name {
+
+ typedef typename find_by_element_name<BitfieldTuple,Name>::type bft_element;
+ // apply qualifiers from CVQualifiers to the bft_element type
+ // this will allow me to pass the qualifiers into the newly created reference
+ // type then unpack them and apply them to the rest of the internal types
+ // correctly.
+
+ typedef typename mpl::if_<
+ typename is_const<CVQualifiers>::type,
+ typename add_const<bft_element>::type,
+ bft_element
+ >::type bft_element_c_qualifier_applied;
+
+ typedef typename mpl::if_<
+ typename is_volatile<CVQualifiers>::type,
+ typename add_volatile<bft_element_c_qualifier_applied>::type,
+ bft_element_c_qualifier_applied
+ >::type bft_element_v_qualifier_applied;
+
+ // typedef
+ // volatile
+};
+
+
+
+}} // end boost::details
+
+#endif
Modified: sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2
==============================================================================
--- sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 (original)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 2010-06-24 14:58:06 EDT (Thu, 24 Jun 2010)
@@ -44,5 +44,7 @@
[ run bft_testing/template_expansion_marco_test.cpp ]
[ run bft_testing/variadic_sequence_testing.cpp ]
[ run bft_testing/align_test.cpp ]
+ [ run bft_testing/reference_builder_test.cpp ]
+
;
Added: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/reference_builder_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/reference_builder_test.cpp 2010-06-24 14:58:06 EDT (Thu, 24 Jun 2010)
@@ -0,0 +1,17 @@
+// 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;
+
+
+int main() {
+
+ 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