|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69191 - sandbox/endian_ext/boost/integer/endian
From: vicente.botet_at_[hidden]
Date: 2011-02-22 17:58:13
Author: viboes
Date: 2011-02-22 17:58:12 EST (Tue, 22 Feb 2011)
New Revision: 69191
URL: http://svn.boost.org/trac/boost/changeset/69191
Log:
Endian:
Text files modified:
sandbox/endian_ext/boost/integer/endian/endian.hpp | 5 +++
sandbox/endian_ext/boost/integer/endian/endian_conversion.hpp | 5 ++-
sandbox/endian_ext/boost/integer/endian/endian_pack.hpp | 46 +++++++++++++++++++--------------------
sandbox/endian_ext/boost/integer/endian/endian_view.hpp | 10 ++++----
4 files changed, 34 insertions(+), 32 deletions(-)
Modified: sandbox/endian_ext/boost/integer/endian/endian.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian.hpp 2011-02-22 17:58:12 EST (Tue, 22 Feb 2011)
@@ -60,12 +60,15 @@
endian_pack<E, T, n_bits, A> pack_;
public:
+ typedef E endian_type;
typedef T value_type;
+ BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
+ BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = A;
+
# ifndef BOOST_ENDIAN_NO_CTORS
endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
template <typename T2>
explicit endian(T2 val)
- //~ explicit endian(T val)
: pack_(val)
{
}
Modified: sandbox/endian_ext/boost/integer/endian/endian_conversion.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian_conversion.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian_conversion.hpp 2011-02-22 17:58:12 EST (Tue, 22 Feb 2011)
@@ -32,7 +32,7 @@
namespace boost {
namespace integer {
-
+namespace endianness {
template <typename EndianTarget, typename EndianSource, typename T>
inline void convert_to_from(T& r);
@@ -52,7 +52,7 @@
struct convert_to_from_seq_loop {
template <typename It, typename End>
static void apply(It& it, End& end) {
- boost::integer::convert_to_from_impl<
+ boost::integer::endianness::convert_to_from_impl<
typename mpl::deref<ItTarget>::type,
typename mpl::deref<ItSource>::type,
typename remove_reference<typename remove_cv<typename fusion::result_of::deref<It>::type>::type >::type
@@ -220,6 +220,7 @@
T>::apply(r);
}
+} // namespace endianness
} // namespace integer
} // namespace boost
Modified: sandbox/endian_ext/boost/integer/endian/endian_pack.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian_pack.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian_pack.hpp 2011-02-22 17:58:12 EST (Tue, 22 Feb 2011)
@@ -21,7 +21,7 @@
// Definition of native depending on BOOST_BIG_ENDIAN to big or little done by Vicente J. Botet Escriba.
// Change the definition of endian_pack using types instead of enum endianness done by Vicente J. Botet Escriba.
-// TODO: When a compiler supporting constexpr becomes available, try possible uses.
+
#define BOOST_ENDIAN_ALLOWS_UDT
#ifndef BOOST_INTEGER_ENDIAN_PACK_HPP
@@ -37,12 +37,10 @@
#include <boost/config.hpp>
#include <boost/type_traits/is_signed.hpp>
-//#include <climits>
#include <boost/integer_traits.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <boost/detail/scoped_enum_emulation.hpp>
-//~ #include <iosfwd>
#include <climits>
#include <algorithm>
@@ -58,7 +56,7 @@
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
# endif
-# if defined(BOOST_NO_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIAN_FORCE_PODNESS)
+# if defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_ENDIAN_NO_CTORS
# endif
@@ -75,9 +73,9 @@
{
typedef unrolled_byte_loops<T, n_bytes - 1, sign> next;
- static T load_big(const unsigned char* bytes)
+ static BOOST_CONSTEXPR T load_big(const unsigned char* bytes)
{ return *(bytes - 1) | (next::load_big(bytes - 1) << 8); }
- static T load_little(const unsigned char* bytes)
+ static BOOST_CONSTEXPR T load_little(const unsigned char* bytes)
{ return *bytes | (next::load_little(bytes + 1) << 8); }
static void store_big(char* bytes, T value)
@@ -95,9 +93,9 @@
template <typename T>
struct unrolled_byte_loops<T, 1, false>
{
- static T load_big(const unsigned char* bytes)
+ static BOOST_CONSTEXPR T load_big(const unsigned char* bytes)
{ return *(bytes - 1); }
- static T load_little(const unsigned char* bytes)
+ static BOOST_CONSTEXPR T load_little(const unsigned char* bytes)
{ return *bytes; }
static void store_big(char* bytes, T value)
{ *(bytes - 1) = static_cast<char>(value); }
@@ -109,9 +107,9 @@
template <typename T>
struct unrolled_byte_loops<T, 1, true>
{
- static T load_big(const unsigned char* bytes)
+ static BOOST_CONSTEXPR T load_big(const unsigned char* bytes)
{ return *reinterpret_cast<const signed char*>(bytes - 1); }
- static T load_little(const unsigned char* bytes)
+ static BOOST_CONSTEXPR T load_little(const unsigned char* bytes)
{ return *reinterpret_cast<const signed char*>(bytes); }
static void store_big(char* bytes, T value)
{ *(bytes - 1) = static_cast<char>(value); }
@@ -213,8 +211,8 @@
public:
typedef big_endian endian_type;
typedef T value_type;
- static const std::size_t width = n_bits;
- static const BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::unaligned;
+ BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
+ BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::unaligned;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
template <typename T2>
@@ -250,8 +248,8 @@
public:
typedef little_endian endian_type;
typedef T value_type;
- static const std::size_t width = n_bits;
- static const BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::unaligned;
+ BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
+ BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::unaligned;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian_pack(T val)
@@ -298,8 +296,8 @@
void retrieve(value_type* result) const
{ detail::reverse_copy<sizeof(value_type)>(result, m_value); }
public:
- static const std::size_t width = n_bits;
- static const BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::aligned;
+ BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
+ BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::aligned;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian_pack(T val) { store(val); }
@@ -322,8 +320,8 @@
public:
typedef native_endian endian_type;
typedef T value_type;
- static const std::size_t width = n_bits;
- static const BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::aligned;
+ BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
+ BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::aligned;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian_pack(T val) : m_value(val) { }
@@ -334,7 +332,7 @@
private:
T m_value;
};
-#else
+#else // defined(BOOST_ENDIAN_ALLOWS_UDT)
// aligned big endian specialization
template <typename T, std::size_t n_bits>
class endian_pack< big_endian, T, n_bits, alignment::aligned >
@@ -344,8 +342,8 @@
public:
typedef big_endian endian_type;
typedef T value_type;
- static const std::size_t width = n_bits;
- static const BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::aligned;
+ BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
+ BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::aligned;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
# ifdef BOOST_BIG_ENDIAN
@@ -375,8 +373,8 @@
public:
typedef little_endian endian_type;
typedef T value_type;
- static const std::size_t width = n_bits;
- static const BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::aligned;
+ BOOST_STATIC_CONSTEXPR std::size_t width = n_bits;
+ BOOST_STATIC_CONSTEXPR BOOST_SCOPED_ENUM(alignment) alignment_value = alignment::aligned;
# ifndef BOOST_ENDIAN_NO_CTORS
endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
# ifdef BOOST_LITTLE_ENDIAN
@@ -396,7 +394,7 @@
private:
T m_value;
};
-#endif
+#endif // defined(BOOST_ENDIAN_ALLOWS_UDT)
// naming convention typedefs ------------------------------------------------------//
Modified: sandbox/endian_ext/boost/integer/endian/endian_view.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian/endian_view.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian/endian_view.hpp 2011-02-22 17:58:12 EST (Tue, 22 Feb 2011)
@@ -18,8 +18,8 @@
#include <boost/type_traits/is_fundamental.hpp>
namespace boost {
-
namespace integer {
+namespace endianness {
template <typename EndianSource, typename T>
void convert_from(T& r);
@@ -27,7 +27,7 @@
void convert_to(T& r);
template <typename EndianTarget, typename EndianSource, typename T>
void convert_to_from(T& r);
-
+}
template <typename Endian, typename T,
bool IsFundamental = is_fundamental<T>::value,
bool IsSeq = fusion::traits::is_sequence<T>::value
@@ -79,12 +79,12 @@
endian_view(value_type& ref) : ref_(ref) {};
operator value_type() const {
value_type res=ref_;
- convert_from<Endian>(res);
+ endianness::convert_from<Endian>(res);
return res;
}
endian_view& operator=(value_type val) {
ref_=val;
- convert_to<Endian>(ref_);
+ endianness::convert_to<Endian>(ref_);
return *this;
}
endian_view& operator=(endian_view const& rhs) {
@@ -96,7 +96,7 @@
template <typename Endian2 >
endian_view& operator=(endian_view<Endian2,T,true,false> const& rhs) {
ref_=rhs.ref_;
- convert_to_from<Endian2,Endian>(ref_);
+ endianness::convert_to_from<Endian2,Endian>(ref_);
return *this;
}
};
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