|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64021 - sandbox/bitfield/boost/integer
From: vicente.botet_at_[hidden]
Date: 2010-07-14 15:50:37
Author: viboes
Date: 2010-07-14 15:50:36 EDT (Wed, 14 Jul 2010)
New Revision: 64021
URL: http://svn.boost.org/trac/boost/changeset/64021
Log:
* Fix warnings
Text files modified:
sandbox/bitfield/boost/integer/bitfield.hpp | 41 +++++++++++++++++++++++++--------------
1 files changed, 26 insertions(+), 15 deletions(-)
Modified: sandbox/bitfield/boost/integer/bitfield.hpp
==============================================================================
--- sandbox/bitfield/boost/integer/bitfield.hpp (original)
+++ sandbox/bitfield/boost/integer/bitfield.hpp 2010-07-14 15:50:36 EDT (Wed, 14 Jul 2010)
@@ -1,9 +1,9 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Emile Cormier 2006.
-// (C) Copyright Vicente J. Botet Escriba 2008-2009.
-// Distributed under the Boost Software License, Version 1.0.
-// (See accompanying file LICENSE_1_0.txt or
+// (C) Copyright Emile Cormier 2006.
+// (C) Copyright Vicente J. Botet Escriba 2008-2009.
+// 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)
//
// See http://www.boost.org/libs/integer for documentation.
@@ -21,7 +21,7 @@
//#include <netinet/in.h>
namespace boost { namespace integer {
-
+
template <typename T>
struct bitfield_value_type {
typedef T type;
@@ -84,9 +84,9 @@
struct bitfield_complete_signed<true, value_type, storage_type, WIDTH> {
static value_type convert(storage_type val, storage_type SIGN_MASK) {
if( (val>>(WIDTH-1))!=0) {
- return (val | SIGN_MASK);
+ return static_cast<value_type>(val | SIGN_MASK);
} else {
- return val;
+ return static_cast<value_type>(val);
}
}
};
@@ -94,11 +94,17 @@
template <typename value_type, typename storage_type, unsigned int WIDTH>
struct bitfield_complete_signed<false, value_type, storage_type, WIDTH> {
static value_type convert(storage_type val, storage_type) {
- return val;
+ return static_cast<value_type>(val);
+ }
+ };
+ template <typename storage_type, unsigned int WIDTH>
+ struct bitfield_complete_signed<false, bool, storage_type, WIDTH> {
+ static bool convert(storage_type val, storage_type) {
+ return val!=0;
}
};
}
-
+
//------------------------------------------------------------------------------
/*!
Used to easily manipulate groups of bits the same way as does C bitfields,
@@ -133,8 +139,8 @@
\param STORAGE_TYPE Unsigned integer type of the word occupied by the bitfield
\param F Position of the first bit (0 is the least significant bit)
\param L Position of the last bit (0 is the least significant bit)
- \param VALUE_TYPE Value type of the bitfield itself
- \param REFERENCE_TYPE Reference type of the word occupied by the bitfield
+ \param VALUE_TYPE Value type of the bitfield itself
+ \param REFERENCE_TYPE Reference type of the word occupied by the bitfield
*/
@@ -154,9 +160,9 @@
public:
//! storage type of the bitfield support
typedef STORAGE_TYPE storage_type;
- //! Value type of the bitfield itself
+ //! Value type of the bitfield itself
typedef VALUE_TYPE value_type;
- //! Reference type of the bitfield itself
+ //! Reference type of the bitfield itself
typedef REFERENCE_TYPE reference_type;
private:
@@ -211,7 +217,7 @@
typedef bitfield_bit_proxy<this_type> bit_reference_type;
typedef bitfield_bit_proxy<const this_type> bit_const_reference_type;
-
+
//! private because a reference is nedeed
bitfield();
@@ -235,7 +241,7 @@
template <VALUE_TYPE V>
struct static_value_to_storage {
static const storage_type value = ((storage_type(V) & VAL_MASK) << LASTD);
- };
+ };
//! explicit constructor from a reference
explicit bitfield(storage_type& field) : field_(field) {
}
@@ -297,6 +303,11 @@
static storage_type val_mask() {return VAL_MASK;}
static storage_type field_mask() {return FIELD_MASK;}
+ bitfield& operator=(bitfield const& rhs) {
+ if (this == &rhs) return;
+ field_ = rhs.field_;
+ }
+
//! Arithmetic-assign operators
bitfield& operator++() {*this += 1; return *this;}
value_type operator++(int) {value_type ret(*this); ++*this; return ret;}
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