|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62394 - sandbox/SOC/2010/bits_and_ints/boost/integer
From: muriloufg_at_[hidden]
Date: 2010-06-02 17:35:46
Author: murilov
Date: 2010-06-02 17:35:45 EDT (Wed, 02 Jun 2010)
New Revision: 62394
URL: http://svn.boost.org/trac/boost/changeset/62394
Log:
Moved the implementations file from boost/integer/detail to boost/integer. Changed the layout of sign_extend function and static_sign_extend template.
Added:
sandbox/SOC/2010/bits_and_ints/boost/integer/bit_reversal.hpp
- copied unchanged from r62384, /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/bit_reversal.hpp
sandbox/SOC/2010/bits_and_ints/boost/integer/sign_extend.hpp
- copied, changed from r62384, /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/sign_extend.hpp
sandbox/SOC/2010/bits_and_ints/boost/integer/static_bit_reversal.hpp
- copied unchanged from r62385, /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/static_bit_reversal.hpp
sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp
- copied, changed from r62384, /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/static_sign_extend.hpp
sandbox/SOC/2010/bits_and_ints/boost/integer/utils.hpp
- copied, changed from r62384, /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/utils.hpp
Text files modified:
sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp | 2 +-
sandbox/SOC/2010/bits_and_ints/boost/integer/sign_extend.hpp | 13 ++++++-------
sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp | 11 +++++------
sandbox/SOC/2010/bits_and_ints/boost/integer/utils.hpp | 2 ++
4 files changed, 14 insertions(+), 14 deletions(-)
Modified: sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/bits_and_ints.hpp 2010-06-02 17:35:45 EDT (Wed, 02 Jun 2010)
@@ -11,7 +11,7 @@
#define BOOST_BITS_AND_INTS
// sign_extends and static_sign_extends
-//#include "utils.hpp"
+#include "detail/utils.hpp"
#include "detail/sign_extend.hpp"
#include "detail/static_sign_extend.hpp"
#include "detail/bit_reversal.hpp"
Copied: sandbox/SOC/2010/bits_and_ints/boost/integer/sign_extend.hpp (from r62384, /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/sign_extend.hpp)
==============================================================================
--- /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/sign_extend.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/sign_extend.hpp 2010-06-02 17:35:45 EDT (Wed, 02 Jun 2010)
@@ -15,16 +15,15 @@
namespace boost
{
-
-typedef intmax_t Raw;
-// Extend data represented in 'b' bits to sizeof(T)*8 bits
+// Extend data represented in `bits' bits to
+// sizeof(IntegralType) * 8 bits
template <typename IntegralType>
-inline Raw sign_extend(IntegralType data, unsigned b)
+inline IntegralType sign_extend(IntegralType data, std::size_t bits)
{
- data = data & ((Raw(1) << b) - 1);
- Raw const m = (Raw(1) << (b - 1));
- return (data ^ m) - m;
+ data = data & ((IntegralType(1) << bits) - 1);
+ IntegralType const mask = (IntegralType(1) << (bits - 1));
+ return (data ^ mask) - mask;
}
} // boost
Copied: sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp (from r62384, /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/static_sign_extend.hpp)
==============================================================================
--- /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/static_sign_extend.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/static_sign_extend.hpp 2010-06-02 17:35:45 EDT (Wed, 02 Jun 2010)
@@ -10,21 +10,20 @@
#ifndef BOOST_STATIC_SIGN_EXTEND_INCLUDED
#define BOOST_STATIC_SIGN_EXTEND_INCLUDED
-#include <boost/cstdint.hpp> // for intmax_t
+#include <boost/cstdint.hpp>
namespace boost
{
// Compile-time version of sign_extend
-template<typename IntegralType, Raw raw, unsigned B>
+template<typename IntegralType, IntegralType raw, std::size_t Bits>
struct static_sign_extend
{
- typedef IntegralType T;
private:
- BOOST_STATIC_CONSTANT(T, shift = (T(1) << (B - 1)));
- BOOST_STATIC_CONSTANT(T, m = ((T(1) << B) - 1));
+ BOOST_STATIC_CONSTANT(IntegralType, shift = (IntegralType(1) << (Bits - 1)));
+ BOOST_STATIC_CONSTANT(IntegralType, mask = ((IntegralType(1) << Bits) - 1));
public:
- BOOST_STATIC_CONSTANT(Raw, value = ((raw & m) ^ shift) - shift);
+ BOOST_STATIC_CONSTANT(IntegralType, value = ((raw & mask) ^ shift) - shift);
}; // boost::static_sign_extend
} // boost
Copied: sandbox/SOC/2010/bits_and_ints/boost/integer/utils.hpp (from r62384, /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/utils.hpp)
==============================================================================
--- /sandbox/SOC/2010/bits_and_ints/boost/integer/detail/utils.hpp (original)
+++ sandbox/SOC/2010/bits_and_ints/boost/integer/utils.hpp 2010-06-02 17:35:45 EDT (Wed, 02 Jun 2010)
@@ -10,6 +10,8 @@
#ifndef BOOST_INTEGER_UTILS_INCLUDED
#define BOOST_INTEGER_UTILS_INCLUDED
+#include <boost/cstdint.hpp>
+
/*
* Some utilities to handle integers.
*/
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