Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r64469 - in sandbox/SOC/2010/bit_masks: . boost/integer/bitfield_tuple lib/integer/test lib/integer/test/bft_testing
From: bbartmanboost_at_[hidden]
Date: 2010-07-30 12:12:01


Author: bbartman
Date: 2010-07-30 12:12:00 EDT (Fri, 30 Jul 2010)
New Revision: 64469
URL: http://svn.boost.org/trac/boost/changeset/64469

Log:
get free function interface test completeD
Added:
   sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_free_function_test.cpp (contents, props changed)
Text files modified:
   sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple/get_free_function.hpp | 27 +++++++++++++++++++++++----
   sandbox/SOC/2010/bit_masks/lib/integer/test/Jamfile.v2 | 1 +
   sandbox/SOC/2010/bit_masks/notes.txt | 20 ++++++++++++++++++++
   3 files changed, 44 insertions(+), 4 deletions(-)

Modified: sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple/get_free_function.hpp
==============================================================================
--- sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple/get_free_function.hpp (original)
+++ sandbox/SOC/2010/bit_masks/boost/integer/bitfield_tuple/get_free_function.hpp 2010-07-30 12:12:00 EDT (Fri, 30 Jul 2010)
@@ -7,13 +7,32 @@
 #ifndef BOOST_BITFIELD_TUPLE_GET_FREE_FUNCTION_HPP
 #define BOOST_BITFIELD_TUPLE_GET_FREE_FUNCTION_HPP
 #include <cstddef>
+#include "element.hpp"
 
+namespace boost { namespace bitfields {
 
-namespace boost {
-namespace bitfields {
+template <std::size_t Index, typename BitfieldTuple>
+inline typename element<BitfieldTuple,Index>::type get(BitfieldTuple& bft) {
+ return bft.get<Index>();
+}
+
+template <typename Name, typename BitfieldTuple>
+inline typename element_n<BitfieldTuple,Name>::type get(BitfieldTuple& bft) {
+ return bft.get<Name>();
+}
+
+template <std::size_t Index, typename BitfieldTuple>
+inline typename element<const BitfieldTuple,Index>::type
+get(BitfieldTuple const& bft) {
+ return bft.get<Index>();
+}
+
+template <typename Name, typename BitfieldTuple>
+inline typename element_n<const BitfieldTuple,Name>::type
+get(BitfieldTuple const& bft) {
+ return bft.get<Name>();
+}
 
-// template <std::size_t Index, typename BitfieldTuple>
-//
 }} // boost::bitfields
 
 #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-07-30 12:12:00 EDT (Fri, 30 Jul 2010)
@@ -69,5 +69,6 @@
         [ run bft_testing/clz_ctz_test.cpp ]
         [ run bft_testing/element_test.cpp ]
         [ run bft_testing/element_n_test.cpp ]
+ [ run bft_testing/get_free_function_test.cpp ]
     ;
 

Added: sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_free_function_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2010/bit_masks/lib/integer/test/bft_testing/get_free_function_test.cpp 2010-07-30 12:12:00 EDT (Fri, 30 Jul 2010)
@@ -0,0 +1,71 @@
+// 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/detail/lightweight_test.hpp>
+
+
+using namespace boost;
+using namespace boost::bitfields;
+
+struct red;
+struct green;
+struct pink;
+struct blue;
+struct salmon;
+
+typedef bitfield_tuple<
+ member<char,red,4>,
+ member<unsigned char, green,5>,
+ storage<std::size_t>,
+ member<int, salmon, 16>
+> test_tuple;
+
+
+int main() {
+
+ // testing look up interface
+ {
+ test_tuple test_1;
+ bitfields::get<green>(test_1) = 15;
+ get<red>(test_1) = 3;
+ get<salmon>(test_1) = 6;
+ BOOST_TEST((get<green>(test_1) == 15));
+ BOOST_TEST((get<red>(test_1) == 3));
+ BOOST_TEST((get<salmon>(test_1) == 6));
+
+ BOOST_TEST( get<salmon>(const_cast<test_tuple const&>(test_1)) == 6 );
+ BOOST_TEST( get<green>(const_cast<test_tuple const&>(test_1)) == 15 );
+ BOOST_TEST( get<red>(const_cast<test_tuple const&>(test_1)) == 3 );
+
+ }
+
+ // get using an index.
+ {
+ test_tuple test_2;
+ get<0>(test_2) = 3;
+ get<1>(test_2) = 14;
+ get<2>(test_2) = 6;
+ BOOST_TEST(get<0>(test_2) == 3);
+ BOOST_TEST(get<1>(test_2) == 14);
+ BOOST_TEST(get<2>(test_2) == 6);
+
+ BOOST_TEST(get<2>(const_cast<test_tuple const&>(test_2)) == 6);
+ BOOST_TEST(get<0>(const_cast<test_tuple const&>(test_2)) == 3);
+ BOOST_TEST(get<1>(const_cast<test_tuple const&>(test_2)) == 14);
+ }
+
+ // negative value testing
+ {
+ test_tuple test_3;
+ get<0>(test_3) = -1;
+ BOOST_TEST(( get<0>(test_3) == -1 ));
+ }
+
+ return boost::report_errors();
+}
+
+

Modified: sandbox/SOC/2010/bit_masks/notes.txt
==============================================================================
--- sandbox/SOC/2010/bit_masks/notes.txt (original)
+++ sandbox/SOC/2010/bit_masks/notes.txt 2010-07-30 12:12:00 EDT (Fri, 30 Jul 2010)
@@ -125,4 +125,24 @@
 * make_bitfield_tuple - Do testing similar to the variadic template parameter
     tests, testing to make sure that this works for all cases.
 --------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+ MSVC warnings
+--------------------------------------------------------------------------------
+high_bit_mask_test.cpp(30) : warning C4127: conditional expression is constant
+bitfield_orignal.hpp(90) : warning C4244: 'return' : conversion from 'unsigned int' to 'unsigned char', possible loss of data
+bitfield_orignal.hpp(80) : warning C4244: 'return' : conversion from 'unsigned int' to 'char', possible loss of data
+bitfield_orignal.hpp(82) : warning C4244: 'return' : conversion from 'unsigned int' to 'char', possible loss of data
+bitfield_orignal.hpp(196) : warning C4245: 'initializing' : conversion from 'int' to 'const unsigned char', signed/unsigned mismatch
+bits_mask.hpp(34) : warning C4293: '<<' : shift count negative or too big, undefined behavior
+high_bits_mask.hpp(30) : warning C4305: 'initializing' : truncation from 'const boost::mpl::size_t<N>::value_type' to 'const unsigned char'
+integral_wrapper.hpp(72) : warning C4307: '+' : integral constant overflow
+integral_wrapper.hpp(73) : warning C4307: '-' : integral constant overflow
+bits_mask.hpp(37) : warning C4307: '+' : integral constant overflow
+policy_creation_detail.hpp(76) : warning C4309: 'specialization' : truncation of constant value
+bitfield_orignal.hpp(179) : warning C4309: 'specialization' : truncation of constant value
+bitfield_orignal.hpp(90) : warning C4800: 'unsigned char' : forcing value to bool 'true' or 'false' (performance warning)
+--------------------------------------------------------------------------------
+
+
     return boost::report_errors();


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