Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64227 - sandbox/SOC/2010/bit_masks/boost/integer/detail/bft
From: bbartmanboost_at_[hidden]
Date: 2010-07-21 14:55:21


Author: bbartman
Date: 2010-07-21 14:55:19 EDT (Wed, 21 Jul 2010)
New Revision: 64227
URL: http://svn.boost.org/trac/boost/changeset/64227

Log:
created better policy framework for reference type
Added:
   sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/proxy_reference_policy.hpp (contents, props changed)

Added: sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/proxy_reference_policy.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bit_masks/boost/integer/detail/bft/proxy_reference_policy.hpp 2010-07-21 14:55:19 EDT (Wed, 21 Jul 2010)
@@ -0,0 +1,87 @@
+// 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_PROXY_REFERENCE_POLICY_HPP
+#define BOOST_BITFIELD_TUPLE_PROXY_REFERENCE_POLICY_HPP
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/is_pod.hpp>
+#include <boost/mpl/void.hpp>
+#include <boost/mpl/logical.hpp>
+#include <boost/mpl/if.hpp>
+
+namespace boost { namespace detail {
+
+template <
+ typename StorageType,
+ typename Policy
+>
+struct policy_wrapper {
+ typedef StorageType storage_type;
+ typedef Policy field_policy;
+ typedef typename field_policy::value_type value_type;
+
+ policy_wrapper(storage_type& storage)
+ :_field( storage )
+ { }
+
+ void set(value_type rhs) {
+ _field = field_policy::template apply<storage_type>::set(_field, rhs);
+ }
+
+ value_type get() const {
+ return field_policy::template apply<storage_type>::get( _field );
+ }
+
+private:
+ storage_type& _field;
+};
+
+/** This is the policy which is going to be used for calculating the correct
+ * policy for retrieving the data from inside of teh bitfield_tuple
+ * this is instead of the bitfield being the policy.
+ */
+template <
+ typename StorageType,
+ typename Offset,
+ typename Width,
+ typename ValueType,
+ typename Policy
+>
+struct select_packing_policy {
+ // this is where the correct storage and retrieval policy is
+ // selected based on the arguments supplied.
+ typedef typename mpl::if_<
+ is_same<
+ Policy,
+ mpl::void_
+ >,
+ typename mpl::if_<
+ is_pod<StorageType>,
+ ::boost::integer::bitfield<
+ StorageType,
+ Offset::value,
+ Offset::value
+ +
+ Width::value - 1,
+ ValueType
+ >,
+ ::boost::integer::bitfield<
+ StorageType,
+ Offset::value,
+ Offset::value
+ +
+ Width::value - 1,
+ ValueType
+ >
+ >::type,
+ policy_wrapper< StorageType, Policy >
+ >::type type;
+};
+
+
+}} // end boost::detial
+
+#endif


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