Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63130 - sandbox/endian_ext/boost/integer
From: vicente.botet_at_[hidden]
Date: 2010-06-20 08:05:36


Author: viboes
Date: 2010-06-20 08:05:35 EDT (Sun, 20 Jun 2010)
New Revision: 63130
URL: http://svn.boost.org/trac/boost/changeset/63130

Log:
* endian rename to endianness
* allow UDT for endian_pack

Text files modified:
   sandbox/endian_ext/boost/integer/endian.hpp | 172 +++++++++++++++++++++++++++++++++++++++
   sandbox/endian_ext/boost/integer/endian_binary_stream.hpp | 37 +++----
   sandbox/endian_ext/boost/integer/endian_conversion.hpp | 2
   sandbox/endian_ext/boost/integer/endian_pack.hpp | 127 ++++++++++++++++++++++++++++-
   4 files changed, 309 insertions(+), 29 deletions(-)

Modified: sandbox/endian_ext/boost/integer/endian.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian.hpp 2010-06-20 08:05:35 EDT (Sun, 20 Jun 2010)
@@ -41,6 +41,8 @@
 #include <boost/static_assert.hpp>
 #include <iosfwd>
 #include <climits>
+#include <limits>
+#include <cstddef>
 
 namespace boost
 {
@@ -61,7 +63,9 @@
         typedef T value_type;
 # ifndef BOOST_ENDIAN_NO_CTORS
         endian() BOOST_ENDIAN_DEFAULT_CONSTRUCT
- explicit endian(T val)
+ template <typename T2>
+ explicit endian(T2 val)
+ //~ explicit endian(T val)
             : pack_(val)
         {
         }
@@ -74,6 +78,8 @@
         {
           return T(pack_);
         }
+ const char* data() const { return pack_.data(); }
+
     };
         
   // naming convention typedefs ------------------------------------------------------//
@@ -172,6 +178,18 @@
     typedef endian< little_endian, uint64_t, 64, alignment::aligned > aligned_ulittle64_t;
 # endif
 
+ template<typename OSTREAM, typename E,
+ typename T, std::size_t N,
+ BOOST_SCOPED_ENUM(alignment) A>
+ OSTREAM&
+ operator<<(OSTREAM & os,
+ const endian< E,T,N,A > & aval) {
+ os << T(aval);
+ return os;
+
+ }
+
+
   } // namespace integer
 } // namespace boost
 
@@ -179,4 +197,156 @@
 # pragma pack(pop)
 #endif
 
+#if 0
+namespace std {
+ template <typename E,
+ typename T,
+ size_t N
+ > class numeric_limits<boost::integer::endian<E,T,N,boost::integer::alignment::aligned> >
+ {
+ typedef T value_type;
+ public:
+
+ BOOST_STATIC_CONSTANT(bool, is_specialized = true);
+ static value_type min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return numeric_limits<value_type>::(min)(); }
+ static value_type max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return numeric_limits<value_type>::(max)(); }
+ BOOST_STATIC_CONSTANT(int, digits = numeric_limits<value_type>::digits);
+ BOOST_STATIC_CONSTANT(int, digits10 = numeric_limits<value_type>::digits10);
+ BOOST_STATIC_CONSTANT(bool, is_signed = numeric_limits<value_type>::is_signed);
+ BOOST_STATIC_CONSTANT(bool, is_integer = numeric_limits<value_type>::is_integer);
+ BOOST_STATIC_CONSTANT(bool, is_exact = numeric_limits<value_type>::is_exact);
+ BOOST_STATIC_CONSTANT(int, radix = numeric_limits<value_type>::radix);
+ static value_type epsilon() throw() { return numeric_limits<value_type>::epsilon(); };
+ static value_type round_error() throw() { return numeric_limits<value_type>::round_error(); };
+
+ BOOST_STATIC_CONSTANT(int, min_exponent = numeric_limits<value_type>::min_exponent);
+ BOOST_STATIC_CONSTANT(int, min_exponent10 = numeric_limits<value_type>::min_exponent10);
+ BOOST_STATIC_CONSTANT(int, max_exponent = numeric_limits<value_type>::max_exponent);
+ BOOST_STATIC_CONSTANT(int, max_exponent10 = numeric_limits<value_type>::max_exponent10);
+
+ BOOST_STATIC_CONSTANT(bool, has_infinity = numeric_limits<value_type>::has_infinity);
+ BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = numeric_limits<value_type>::has_quiet_NaN);
+ BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = numeric_limits<value_type>::has_signaling_NaN);
+ BOOST_STATIC_CONSTANT(bool, has_denorm = numeric_limits<value_type>::has_denorm);
+ BOOST_STATIC_CONSTANT(bool, has_denorm_loss = numeric_limits<value_type>::has_denorm_loss);
+ static value_type infinity() throw() { return numeric_limits<value_type>::infinity(); };
+ static value_type quiet_NaN() throw() { return numeric_limits<value_type>::quiet_NaN(); };
+ static value_type signaling_NaN() throw() { return numeric_limits<value_type>::signaling_NaN(); };
+ static value_type denorm_min() throw() { return numeric_limits<value_type>::denorm_min(); };
+
+ BOOST_STATIC_CONSTANT(bool, is_iec559 = numeric_limits<value_type>::is_iec559);
+ BOOST_STATIC_CONSTANT(bool, is_bounded = numeric_limits<value_type>::is_bounded);
+ BOOST_STATIC_CONSTANT(bool, is_modulo = numeric_limits<value_type>::is_modulo);
+
+ BOOST_STATIC_CONSTANT(bool, traps = numeric_limits<value_type>::traps);
+ BOOST_STATIC_CONSTANT(bool, tinyness_before = numeric_limits<value_type>::tinyness_before);
+ BOOST_STATIC_CONSTANT(float_round_style, round_style = numeric_limits<value_type>::round_style);
+
+ };
+
+namespace std {
+ template <typename E,
+ typename T,
+ size_t N
+ > class numeric_limits<boost::integer::endian<E,T,N,boost::integer::alignment::aligned> >
+ {
+ typedef T value_type;
+ public:
+
+ BOOST_STATIC_CONSTANT(bool, is_specialized = true);
+ static value_type min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return numeric_limits<value_type>::(min)(); }
+ static value_type max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return numeric_limits<value_type>::(max)(); }
+ BOOST_STATIC_CONSTANT(int, digits = numeric_limits<value_type>::digits);
+ BOOST_STATIC_CONSTANT(int, digits10 = numeric_limits<value_type>::digits10);
+ BOOST_STATIC_CONSTANT(bool, is_signed = numeric_limits<value_type>::is_signed);
+ BOOST_STATIC_CONSTANT(bool, is_integer = numeric_limits<value_type>::is_integer);
+ BOOST_STATIC_CONSTANT(bool, is_exact = numeric_limits<value_type>::is_exact);
+ BOOST_STATIC_CONSTANT(int, radix = numeric_limits<value_type>::radix);
+ static value_type epsilon() throw() { return numeric_limits<value_type>::epsilon(); };
+ static value_type round_error() throw() { return numeric_limits<value_type>::round_error(); };
+
+ BOOST_STATIC_CONSTANT(int, min_exponent = numeric_limits<value_type>::min_exponent);
+ BOOST_STATIC_CONSTANT(int, min_exponent10 = numeric_limits<value_type>::min_exponent10);
+ BOOST_STATIC_CONSTANT(int, max_exponent = numeric_limits<value_type>::max_exponent);
+ BOOST_STATIC_CONSTANT(int, max_exponent10 = numeric_limits<value_type>::max_exponent10);
+
+ BOOST_STATIC_CONSTANT(bool, has_infinity = numeric_limits<value_type>::has_infinity);
+ BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = numeric_limits<value_type>::has_quiet_NaN);
+ BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = numeric_limits<value_type>::has_signaling_NaN);
+ BOOST_STATIC_CONSTANT(bool, has_denorm = numeric_limits<value_type>::has_denorm);
+ BOOST_STATIC_CONSTANT(bool, has_denorm_loss = numeric_limits<value_type>::has_denorm_loss);
+ static value_type infinity() throw() { return numeric_limits<value_type>::infinity(); };
+ static value_type quiet_NaN() throw() { return numeric_limits<value_type>::quiet_NaN(); };
+ static value_type signaling_NaN() throw() { return numeric_limits<value_type>::signaling_NaN(); };
+ static value_type denorm_min() throw() { return numeric_limits<value_type>::denorm_min(); };
+
+ BOOST_STATIC_CONSTANT(bool, is_iec559 = numeric_limits<value_type>::is_iec559);
+ BOOST_STATIC_CONSTANT(bool, is_bounded = numeric_limits<value_type>::is_bounded);
+ BOOST_STATIC_CONSTANT(bool, is_modulo = numeric_limits<value_type>::is_modulo);
+
+ BOOST_STATIC_CONSTANT(bool, traps = numeric_limits<value_type>::traps);
+ BOOST_STATIC_CONSTANT(bool, tinyness_before = numeric_limits<value_type>::tinyness_before);
+ BOOST_STATIC_CONSTANT(float_round_style, round_style = numeric_limits<value_type>::round_style);
+
+ };
+
+
+namespace std {
+ template <typename E,
+ typename T,
+ size_t N
+ > class numeric_limits<boost::integer::endian<E,T,N,boost::integer::alignment::unaligned> >
+ {
+ typedef T value_type;
+ public:
+
+ BOOST_STATIC_CONSTANT(bool, is_specialized = true);
+ static value_type min BOOST_PREVENT_MACRO_SUBSTITUTION (){
+ return numeric_limits<value_type>::is_signed
+ ? low_bit_mask<value_type, N>::value
+ : 0;
+ }
+ static value_type max BOOST_PREVENT_MACRO_SUBSTITUTION (){
+ return numeric_limits<value_type>::is_signed
+ ?low_bit_mask<value_type, N-1>::value
+ :low_bit_mask<value_type, N>::value;
+ }
+ BOOST_STATIC_CONSTANT(int, digits = N);
+ BOOST_STATIC_CONSTANT(int, digits10 = 2<<N);
+ BOOST_STATIC_CONSTANT(bool, is_signed = numeric_limits<value_type>::is_signed);
+ BOOST_STATIC_CONSTANT(bool, is_integer = numeric_limits<value_type>::is_integer);
+ BOOST_STATIC_CONSTANT(bool, is_exact = numeric_limits<value_type>::is_exact);
+ BOOST_STATIC_CONSTANT(int, radix = numeric_limits<value_type>::radix);
+ static value_type epsilon() throw() { return numeric_limits<value_type>::epsilon(); };
+ static value_type round_error() throw() { return numeric_limits<value_type>::round_error(); };
+
+ BOOST_STATIC_CONSTANT(int, min_exponent = numeric_limits<value_type>::min_exponent);
+ BOOST_STATIC_CONSTANT(int, min_exponent10 = numeric_limits<value_type>::min_exponent10);
+ BOOST_STATIC_CONSTANT(int, max_exponent = numeric_limits<value_type>::max_exponent);
+ BOOST_STATIC_CONSTANT(int, max_exponent10 = numeric_limits<value_type>::max_exponent10);
+
+ BOOST_STATIC_CONSTANT(bool, has_infinity = numeric_limits<value_type>::has_infinity);
+ BOOST_STATIC_CONSTANT(bool, has_quiet_NaN = numeric_limits<value_type>::has_quiet_NaN);
+ BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = numeric_limits<value_type>::has_signaling_NaN);
+ BOOST_STATIC_CONSTANT(bool, has_denorm = numeric_limits<value_type>::has_denorm);
+ BOOST_STATIC_CONSTANT(bool, has_denorm_loss = numeric_limits<value_type>::has_denorm_loss);
+ static value_type infinity() throw() { return numeric_limits<value_type>::infinity(); };
+ static value_type quiet_NaN() throw() { return numeric_limits<value_type>::quiet_NaN(); };
+ static value_type signaling_NaN() throw() { return numeric_limits<value_type>::signaling_NaN(); };
+ static value_type denorm_min() throw() { return numeric_limits<value_type>::denorm_min(); };
+
+ BOOST_STATIC_CONSTANT(bool, is_iec559 = numeric_limits<value_type>::is_iec559);
+ BOOST_STATIC_CONSTANT(bool, is_bounded = numeric_limits<value_type>::is_bounded);
+ BOOST_STATIC_CONSTANT(bool, is_modulo = numeric_limits<value_type>::is_modulo);
+
+ BOOST_STATIC_CONSTANT(bool, traps = numeric_limits<value_type>::traps);
+ BOOST_STATIC_CONSTANT(bool, tinyness_before = numeric_limits<value_type>::tinyness_before);
+ BOOST_STATIC_CONSTANT(float_round_style, round_style = numeric_limits<value_type>::round_style);
+
+ };
+
+
+} // namespace std
+
+#endif
 #endif // BOOST_ENDIAN_HPP

Modified: sandbox/endian_ext/boost/integer/endian_binary_stream.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian_binary_stream.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian_binary_stream.hpp 2010-06-20 08:05:35 EDT (Sun, 20 Jun 2010)
@@ -40,6 +40,18 @@
   {
      template< class T > struct is_endian { static const bool value = false; };
 
+ #if 1
+ template<typename E,
+ typename T,
+ std::size_t N,
+ BOOST_SCOPED_ENUM(alignment) A>
+ struct is_endian<endian_pack<E,T,N,A> > { static const bool value = true; };
+ template<typename E,
+ typename T,
+ std::size_t N,
+ BOOST_SCOPED_ENUM(alignment) A>
+ struct is_endian<endian<E,T,N,A> > { static const bool value = true; };
+ #else
      template<> struct is_endian<big8_t> { static const bool value = true; };
      template<> struct is_endian<big16_t> { static const bool value = true; };
      template<> struct is_endian<big24_t> { static const bool value = true; };
@@ -76,25 +88,6 @@
      template<> struct is_endian<ulittle56_t> { static const bool value = true; };
      template<> struct is_endian<ulittle64_t> { static const bool value = true; };
 
- #if 0
- template<> struct is_endian<native8_t> { static const bool value = true; };
- template<> struct is_endian<native16_t> { static const bool value = true; };
- template<> struct is_endian<native24_t> { static const bool value = true; };
- template<> struct is_endian<native32_t> { static const bool value = true; };
- template<> struct is_endian<native40_t> { static const bool value = true; };
- template<> struct is_endian<native48_t> { static const bool value = true; };
- template<> struct is_endian<native56_t> { static const bool value = true; };
- template<> struct is_endian<native64_t> { static const bool value = true; };
-
- template<> struct is_endian<unative8_t> { static const bool value = true; };
- template<> struct is_endian<unative16_t> { static const bool value = true; };
- template<> struct is_endian<unative24_t> { static const bool value = true; };
- template<> struct is_endian<unative32_t> { static const bool value = true; };
- template<> struct is_endian<unative40_t> { static const bool value = true; };
- template<> struct is_endian<unative48_t> { static const bool value = true; };
- template<> struct is_endian<unative56_t> { static const bool value = true; };
- template<> struct is_endian<unative64_t> { static const bool value = true; };
- #endif
  # if defined(BOOST_HAS_INT16_T)
      template<> struct is_endian<aligned_big16_t> { static const bool value = true; };
      template<> struct is_endian<aligned_ubig16_t> { static const bool value = true; };
@@ -115,12 +108,14 @@
      template<> struct is_endian<aligned_little64_t> { static const bool value = true; };
      template<> struct is_endian<aligned_ulittle64_t> { static const bool value = true; };
 # endif
-
+ #endif
+
      template < class Endian >
        inline typename boost::enable_if< is_endian<Endian>, std::ostream & >::type
          operator<=( std::ostream & os, const Endian & e )
      {
- return os.write( reinterpret_cast<const char*>(&e), sizeof(e) );
+ //~ return os.write( reinterpret_cast<const char*>(&e), sizeof(e) );
+ return os.write( e.data(), sizeof(e) );
      }
 
      template < class Endian >

Modified: sandbox/endian_ext/boost/integer/endian_conversion.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian_conversion.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian_conversion.hpp 2010-06-20 08:05:35 EDT (Sun, 20 Jun 2010)
@@ -13,7 +13,7 @@
 #ifndef BOOST_INTEGER_ENDIAN_CONVERT_HPP
 #define BOOST_INTEGER_ENDIAN_CONVERT_HPP
 
-#include <boost/endian/endian.hpp>
+#include <boost/endian/endianness.hpp>
 #include <boost/endian/domain_map.hpp>
 #include <boost/mpl/deref.hpp>
 #include <boost/mpl/next.hpp>

Modified: sandbox/endian_ext/boost/integer/endian_pack.hpp
==============================================================================
--- sandbox/endian_ext/boost/integer/endian_pack.hpp (original)
+++ sandbox/endian_ext/boost/integer/endian_pack.hpp 2010-06-20 08:05:35 EDT (Sun, 20 Jun 2010)
@@ -21,6 +21,7 @@
 // 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
 #define BOOST_INTEGER_ENDIAN_PACK_HPP
@@ -34,7 +35,6 @@
 #endif
 
 #include <boost/config.hpp>
-#include <boost/detail/endian.hpp>
 #include <boost/type_traits/is_signed.hpp>
 #include <boost/integer_traits.hpp>
 #include <boost/cstdint.hpp>
@@ -42,8 +42,9 @@
 #include <boost/detail/scoped_enum_emulation.hpp>
 //~ #include <iosfwd>
 #include <climits>
+#include <algorithm>
 
-# include <boost/endian/endian.hpp>
+# include <boost/endian/endianness.hpp>
 
 # if CHAR_BIT != 8
 # error Platforms with CHAR_BIT != 8 are not supported
@@ -148,6 +149,36 @@
         (static_cast<char*>(bytes), value);
     }
 
+ ///////////////////////
+ template<std::size_t L> inline
+ void unrolled_reverse_copy(char* dst, const char* src) {
+ *dst = *src;
+ unrolled_reverse_copy<L-1>(dst+1, src-1);
+ } // unrolled_reverse_copy
+
+ template<> inline void unrolled_reverse_copy<1>(char* dst, const char* src)
+ { *dst = *src; }
+
+ template<> inline void unrolled_reverse_copy<0>(char*, const char*) { }
+
+ template<std::size_t L, bool>
+ struct reverse_copy_helper {
+ static void copy(char* dst, const char* src)
+ { std::reverse_copy(src, src+L, dst); }
+ };
+
+ template<std::size_t L>
+ struct reverse_copy_helper<L, true> {
+ static void copy(char* dst, const char* src)
+ { unrolled_reverse_copy<L>(dst, src+(L-1)); }
+ };
+
+ template<std::size_t L> inline
+ void reverse_copy(void* dst, const void* src) {
+ reverse_copy_helper< L, (L<=16) >::copy(static_cast<char*>(dst),
+ static_cast<const char*>(src));
+ }
+
   } // namespace detail
 
   namespace integer
@@ -178,10 +209,15 @@
     {
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
       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;
 # ifndef BOOST_ENDIAN_NO_CTORS
         endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
- explicit endian_pack(T val)
+ template <typename T2>
+ explicit endian_pack(T2 val)
+ //~ explicit endian_pack(T val)
         {
 # ifdef BOOST_ENDIAN_LOG
           if ( endian_log )
@@ -199,7 +235,8 @@
 # endif
           return detail::load_big_endian<T, n_bits/8>(m_value);
         }
- private:
+ const char* data() const { return m_value; }
+ private:
               char m_value[n_bits/8];
     };
 
@@ -209,7 +246,10 @@
     {
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
       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;
 # ifndef BOOST_ENDIAN_NO_CTORS
         endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
         explicit endian_pack(T val)
@@ -230,6 +270,7 @@
 # endif
           return detail::load_little_endian<T, n_bits/8>(m_value);
         }
+ const char* data() const { return m_value; }
       private:
               char m_value[n_bits/8];
     };
@@ -238,6 +279,60 @@
     // Specializations that mimic built-in integer types.
     // These typically have the same alignment as the underlying types.
 
+#if defined(BOOST_ENDIAN_ALLOWS_UDT)
+ // aligned endian specialization
+ template <typename E, typename T, std::size_t n_bits>
+ class endian_pack< E, T, n_bits, alignment::aligned >
+ {
+ BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
+ BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
+ public:
+ typedef E endian_type;
+ typedef T value_type;
+ private:
+ void store(const value_type& v)
+ { detail::reverse_copy<sizeof(value_type)>(m_value, &v); }
+
+ 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;
+# ifndef BOOST_ENDIAN_NO_CTORS
+ endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
+ explicit endian_pack(T val) { store(val); }
+# endif
+ endian_pack & operator=(T val) { store(val); return *this; }
+ operator T() const { value_type rval; retrieve(&rval); return rval; }
+ //~ const char* data() const { return reinterpret_cast<const char *>(&m_value); }
+ const char* data() const { return m_value; }
+ private:
+ //~ T m_value;
+ char m_value[sizeof(value_type)];
+ };
+
+ // aligned native endian specialization
+ template <typename T, std::size_t n_bits>
+ class endian_pack< native_endian, T, n_bits, alignment::aligned >
+ {
+ BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
+ BOOST_STATIC_ASSERT( sizeof(T) == n_bits/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;
+# ifndef BOOST_ENDIAN_NO_CTORS
+ endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
+ explicit endian_pack(T val) : m_value(val) { }
+# endif
+ endian_pack & operator=(T val) { m_value = val; return *this; }
+ operator T() const { return m_value; }
+ const char* data() const { return reinterpret_cast<const char *>(&m_value); }
+ private:
+ T m_value;
+ };
+#else
     // aligned big endian specialization
     template <typename T, std::size_t n_bits>
     class endian_pack< big_endian, T, n_bits, alignment::aligned >
@@ -245,11 +340,14 @@
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
         BOOST_STATIC_ASSERT( sizeof(T) == n_bits/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;
 # ifndef BOOST_ENDIAN_NO_CTORS
         endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
 # ifdef BOOST_BIG_ENDIAN
- endian_pack(T val) : m_value(val) { }
+ explicit endian_pack(T val) : m_value(val) { }
 # else
         explicit endian_pack(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); }
 # endif
@@ -261,6 +359,7 @@
         endian_pack & operator=(T val) { detail::store_big_endian<T, sizeof(T)>(&m_value, val); return *this; }
         operator T() const { return detail::load_big_endian<T, sizeof(T)>(&m_value); }
 # endif
+ const char* data() const { return reinterpret_cast<const char *>(&m_value); }
       private:
               T m_value;
     };
@@ -272,11 +371,14 @@
         BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
         BOOST_STATIC_ASSERT( sizeof(T) == n_bits/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;
 # ifndef BOOST_ENDIAN_NO_CTORS
         endian_pack() BOOST_ENDIAN_DEFAULT_CONSTRUCT
 # ifdef BOOST_LITTLE_ENDIAN
- endian_pack(T val) : m_value(val) { }
+ explicit endian_pack(T val) : m_value(val) { }
 # else
         explicit endian_pack(T val) { detail::store_little_endian<T, sizeof(T)>(&m_value, val); }
 # endif
@@ -288,9 +390,11 @@
         endian_pack & operator=(T val) { detail::store_little_endian<T, sizeof(T)>(&m_value, val); return *this; }
         operator T() const { return detail::load_little_endian<T, sizeof(T)>(&m_value); }
     #endif
+ const char* data() const { return reinterpret_cast<const char *>(&m_value); }
       private:
               T m_value;
     };
+#endif
 
   // naming convention typedefs ------------------------------------------------------//
 
@@ -388,6 +492,17 @@
     typedef endian_pack< little_endian, uint64_t, 64, alignment::aligned > aligned_ulittle64_pt;
 # endif
     
+ template<typename OSTREAM, typename E,
+ typename T, std::size_t N,
+ BOOST_SCOPED_ENUM(alignment) A>
+ OSTREAM&
+ operator<<(OSTREAM & os,
+ const endian_pack< E,T,N,A > & aval) {
+ os << T(aval);
+ return os;
+
+ }
+
   } // namespace integer
 } // namespace boost
 


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