diff --git a/arithmetic.html b/arithmetic.html index ea4f5ee..b8d739e 100644 --- a/arithmetic.html +++ b/arithmetic.html @@ -1,4 +1,4 @@ - + @@ -86,19 +86,25 @@ endian and little endian.

Boost endian integers provide the same full set of C++ assignment, arithmetic, and relational operators as C++ standard integral types, with the standard semantics.

-

Unary arithmetic operators are +, -, ~, -!, prefix and postfix -- and ++. Binary -arithmetic operators are +, +=, -, --=, *, *=, /, /=, -%/ %=, &, &=, |, |=, -^, ^=, <<, <<=, >>, ->>=. Binary relational operators are ==, !=, -<, <=, >, >=.

-

Automatic implicit conversion to the underlying value type is provided. A -conversion constructor from the underlying value type is provided.

+

Unary arithmetic operators are +, + -, ~, +!, plus both prefix and postfix -- and ++. Binary +arithmetic operators are +, +=, -, + +-=, *, *=, /, + /=, &, &=, + |, |=, +^, ^=, <<, <<=, +>>, and +>>=. Binary relational operators are ==, + !=, +<, <=, >, +and >=.

+

Implicit conversion to the underlying value type is provided. An implicit +constructor converting from the underlying value type is provided.

Example

The endian_example.cpp program writes a -binary file containing four byte big-endian and little-endian integers:

+binary file containing four-byte, big-endian and little-endian integers:

#include <iostream>
 #include <cstdio>
@@ -128,10 +134,10 @@ namespace
 
 int main(int, char* [])
 {
-  BOOST_STATIC_ASSERT(sizeof(header) == 16U);  // reality check
-  
   header h;
 
+  BOOST_STATIC_ASSERT(sizeof(h) == 16U);  // reality check
+  
   h.file_code   = 0x01020304;
   h.file_length = sizeof(header);
   h.version     = 1;
@@ -181,14 +187,14 @@ is some other value, compilation will result in an #error. This
 restriction is in place because the design, implementation, testing, and 
 documentation has only considered issues related to 8-bit bytes, and there have 
 been no real-world use cases presented for other sizes.

-

In C++03, endian does not meet the requirements for POD types +

In C++03, endian_arithmetic does not meet the requirements for POD types because it has constructors, private data members, and a base class. This means that common use cases are relying on unspecified behavior in that the C++ Standard does not guarantee memory layout for non-POD types. This has not been a -problem in practice since all known C++ compilers do layout memory as if +problem in practice since all known C++ compilers lay out memory as if endian were a POD type. In C++11, it is possible to specify the -default constructor as trivial, and private data members and base classes will -no longer disqualify a type from being a POD. Thus under C++11, endian +default constructor as trivial, and private data members and base classes no longer disqualify a type from being a POD +type. Thus under C++11, endian_arithmetic will no longer be relying on unspecified behavior.

Feature set

    @@ -196,7 +202,7 @@ will no longer be relying on unspecified behavior.

  • Signed | unsigned
  • Unaligned | aligned
  • Integer | floating point
  • -
  • 1-8 byte (unaligned) | 2, 4, 8 byte (aligned)
  • +
  • 1-8 byte (unaligned) | 1, 2, 4, 8 byte (aligned)
  • Choice of value type

Enums and typedefs

@@ -213,7 +219,7 @@ enum class align {no, yes};
class endian_arithmetic;
-

Typedefs, such as big_int32_ut, provide convenient naming +

Typedefs, such as big_int32_t, provide convenient naming conventions for common use cases:

@@ -225,112 +231,112 @@ conventions for common use cases:

- + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + @@ -347,14 +353,14 @@ requirements vary between hardware architectures and because alignment may be affected by compiler switches or pragmas. For example, alignment of an 64-bit integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types are only available on architectures with 8, 16, 32, and 64-bit integer types.

-

Recommendation: Prefer unaligned endian types.

+

Recommendation: Prefer unaligned arithmetic types.

Recommendation: Protect yourself against alignment ills. For example:

static_assert(sizeof(containing_struct) == 12, "sizeof(containing_struct) is wrong"); 
-

Note: One-byte big and little buffer types -never actually reverse endianness. They are provided to enable generic code, and +

Note: Note: One-byte arithmetic types +have identical layout on all platforms, so they never actually reverse endianness. They are provided to enable generic code, and to improve code readability and searchability.

Class template endian_arithmetic

An endian is an integer byte-holder with user-specified @@ -427,109 +433,109 @@ usual operations on integers are supplied.

// typedefs - // aligned big endian floating point types - typedef endian<order::big, float, 32, align::yes> big_float32_t; - typedef endian<order::big, double, 64, align::yes> big_float64_t; - - // aligned little endian floating point types - typedef endian<order::little, float, 32, align::yes> little_float32_t; - typedef endian<order::little, double, 64, align::yes> little_float64_t; - + // unaligned big endian signed integer types + typedef endian<order::big, int_least8_t, 8> big_int8_t; + typedef endian<order::big, int_least16_t, 16> big_int16_t; + typedef endian<order::big, int_least32_t, 24> big_int24_t; + typedef endian<order::big, int_least32_t, 32> big_int32_t; + typedef endian<order::big, int_least64_t, 40> big_int40_t; + typedef endian<order::big, int_least64_t, 48> big_int48_t; + typedef endian<order::big, int_least64_t, 56> big_int56_t; + typedef endian<order::big, int_least64_t, 64> big_int64_t; + + // unaligned big endian unsigned integer types + typedef endian<order::big, uint_least8_t, 8> big_uint8_t; + typedef endian<order::big, uint_least16_t, 16> big_uint16_t; + typedef endian<order::big, uint_least32_t, 24> big_uint24_t; + typedef endian<order::big, uint_least32_t, 32> big_uint32_t; + typedef endian<order::big, uint_least64_t, 40> big_uint40_t; + typedef endian<order::big, uint_least64_t, 48> big_uint48_t; + typedef endian<order::big, uint_least64_t, 56> big_uint56_t; + typedef endian<order::big, uint_least64_t, 64> big_uint64_t; + // unaligned big endian floating point types - typedef endian<order::big, float, 32, align::no> big_float32_ut; - typedef endian<order::big, double, 64, align::no> big_float64_ut; + typedef endian<order::big, float, 32> big_float32_t; + typedef endian<order::big, double, 64> big_float64_t; + + // unaligned little endian signed integer types + typedef endian<order::little, int_least8_t, 8> little_int8_t; + typedef endian<order::little, int_least16_t, 16> little_int16_t; + typedef endian<order::little, int_least32_t, 24> little_int24_t; + typedef endian<order::little, int_least32_t, 32> little_int32_t; + typedef endian<order::little, int_least64_t, 40> little_int40_t; + typedef endian<order::little, int_least64_t, 48> little_int48_t; + typedef endian<order::little, int_least64_t, 56> little_int56_t; + typedef endian<order::little, int_least64_t, 64> little_int64_t; + + // unaligned little endian unsigned integer types + typedef endian<order::little, uint_least8_t, 8> little_uint8_t; + typedef endian<order::little, uint_least16_t, 16> little_uint16_t; + typedef endian<order::little, uint_least32_t, 24> little_uint24_t; + typedef endian<order::little, uint_least32_t, 32> little_uint32_t; + typedef endian<order::little, uint_least64_t, 40> little_uint40_t; + typedef endian<order::little, uint_least64_t, 48> little_uint48_t; + typedef endian<order::little, uint_least64_t, 56> little_uint56_t; + typedef endian<order::little, uint_least64_t, 64> little_uint64_t; // unaligned little endian floating point types - typedef endian<order::little, float, 32, align::no> little_float32_ut; - typedef endian<order::little, double, 64, align::no> little_float64_ut; - + typedef endian<order::little, float, 32, align::no> little_float32_t; + typedef endian<order::little, double, 64, align::no> little_float64_t; + + // unaligned native endian signed integer types + typedef implementation-defined_int8_t native_int8_t; + typedef implementation-defined_int16_t native_int16_t; + typedef implementation-defined_int24_t native_int24_t; + typedef implementation-defined_int32_t native_int32_t; + typedef implementation-defined_int40_t native_int40_t; + typedef implementation-defined_int48_t native_int48_t; + typedef implementation-defined_int56_t native_int56_t; + typedef implementation-defined_int64_t native_int64_t; + + // unaligned native endian unsigned integer types + typedef implementation-defined_uint8_t native_uint8_t; + typedef implementation-defined_uint16_t native_uint16_t; + typedef implementation-defined_uint24_t native_uint24_t; + typedef implementation-defined_uint32_t native_uint32_t; + typedef implementation-defined_uint40_t native_uint40_t; + typedef implementation-defined_uint48_t native_uint48_t; + typedef implementation-defined_uint56_t native_uint56_t; + typedef implementation-defined_uint64_t native_uint64_t; + // aligned big endian signed integer types - typedef endian<order::big, int8_t, 8, align::yes> big_int8_t; - typedef endian<order::big, int16_t, 16, align::yes> big_int16_t; - typedef endian<order::big, int32_t, 32, align::yes> big_int32_t; - typedef endian<order::big, int64_t, 64, align::yes> big_int64_t; + typedef endian<order::big, int8_t, 8, align::yes> big_int8_at; + typedef endian<order::big, int16_t, 16, align::yes> big_int16_at; + typedef endian<order::big, int32_t, 32, align::yes> big_int32_at; + typedef endian<order::big, int64_t, 64, align::yes> big_int64_at; // aligned big endian unsigned integer types - typedef endian<order::big, uint8_t, 8, align::yes> big_uint8_t; - typedef endian<order::big, uint16_t, 16, align::yes> big_uint16_t; - typedef endian<order::big, uint32_t, 32, align::yes> big_uint32_t; - typedef endian<order::big, uint64_t, 64, align::yes> big_uint64_t; + typedef endian<order::big, uint8_t, 8, align::yes> big_uint8_at; + typedef endian<order::big, uint16_t, 16, align::yes> big_uint16_at; + typedef endian<order::big, uint32_t, 32, align::yes> big_uint32_at; + typedef endian<order::big, uint64_t, 64, align::yes> big_uint64_at; + + // aligned big endian floating point types + typedef endian<order::big, float, 32, align::yes> big_float32_at; + typedef endian<order::big, double, 64, align::yes> big_float64_at; // aligned little endian signed integer types - typedef endian<order::little, int8_t, 8, align::yes> little_int8_t; - typedef endian<order::little, int16_t, 16, align::yes> little_int16_t; - typedef endian<order::little, int32_t, 32, align::yes> little_int32_t; - typedef endian<order::little, int64_t, 64, align::yes> little_int64_t; + typedef endian<order::little, int8_t, 8, align::yes> little_int8_at; + typedef endian<order::little, int16_t, 16, align::yes> little_int16_at; + typedef endian<order::little, int32_t, 32, align::yes> little_int32_at; + typedef endian<order::little, int64_t, 64, align::yes> little_int64_at; // aligned little endian unsigned integer types - typedef endian<order::little, uint8_t, 8, align::yes> little_uint8_t; - typedef endian<order::little, uint16_t, 16, align::yes> little_uint16_t; - typedef endian<order::little, uint32_t, 32, align::yes> little_uint32_t; - typedef endian<order::little, uint64_t, 64, align::yes> little_uint64_t; + typedef endian<order::little, uint8_t, 8, align::yes> little_uint8_at; + typedef endian<order::little, uint16_t, 16, align::yes> little_uint16_at; + typedef endian<order::little, uint32_t, 32, align::yes> little_uint32_at; + typedef endian<order::little, uint64_t, 64, align::yes> little_uint64_at; + + // aligned little endian floating point types + typedef endian<order::little, float, 32, align::yes> little_float32_at; + typedef endian<order::little, double, 64, align::yes> little_float64_at; // aligned native endian typedefs are not provided because // <cstdint> types are superior for that use case - // unaligned big endian signed integer types - typedef endian<order::big, int_least8_t, 8> big_int8_ut; - typedef endian<order::big, int_least16_t, 16> big_int16_ut; - typedef endian<order::big, int_least32_t, 24> big_int24_ut; - typedef endian<order::big, int_least32_t, 32> big_int32_ut; - typedef endian<order::big, int_least64_t, 40> big_int40_ut; - typedef endian<order::big, int_least64_t, 48> big_int48_ut; - typedef endian<order::big, int_least64_t, 56> big_int56_ut; - typedef endian<order::big, int_least64_t, 64> big_int64_ut; - - // unaligned big endian unsigned integer types - typedef endian<order::big, uint_least8_t, 8> big_uint8_ut; - typedef endian<order::big, uint_least16_t, 16> big_uint16_ut; - typedef endian<order::big, uint_least32_t, 24> big_uint24_ut; - typedef endian<order::big, uint_least32_t, 32> big_uint32_ut; - typedef endian<order::big, uint_least64_t, 40> big_uint40_ut; - typedef endian<order::big, uint_least64_t, 48> big_uint48_ut; - typedef endian<order::big, uint_least64_t, 56> big_uint56_ut; - typedef endian<order::big, uint_least64_t, 64> big_uint64_ut; - - // unaligned little endian signed integer types - typedef endian<order::little, int_least8_t, 8> little_int8_ut; - typedef endian<order::little, int_least16_t, 16> little_int16_ut; - typedef endian<order::little, int_least32_t, 24> little_int24_ut; - typedef endian<order::little, int_least32_t, 32> little_int32_ut; - typedef endian<order::little, int_least64_t, 40> little_int40_ut; - typedef endian<order::little, int_least64_t, 48> little_int48_ut; - typedef endian<order::little, int_least64_t, 56> little_int56_ut; - typedef endian<order::little, int_least64_t, 64> little_int64_ut; - - // unaligned little endian unsigned integer types - typedef endian<order::little, uint_least8_t, 8> little_uint8_ut; - typedef endian<order::little, uint_least16_t, 16> little_uint16_ut; - typedef endian<order::little, uint_least32_t, 24> little_uint24_ut; - typedef endian<order::little, uint_least32_t, 32> little_uint32_ut; - typedef endian<order::little, uint_least64_t, 40> little_uint40_ut; - typedef endian<order::little, uint_least64_t, 48> little_uint48_ut; - typedef endian<order::little, uint_least64_t, 56> little_uint56_ut; - typedef endian<order::little, uint_least64_t, 64> little_uint64_ut; - - // unaligned native endian signed integer types - typedef implementation-defined_int8_t native_int8_ut; - typedef implementation-defined_int16_t native_int16_ut; - typedef implementation-defined_int24_t native_int24_ut; - typedef implementation-defined_int32_t native_int32_ut; - typedef implementation-defined_int40_t native_int40_ut; - typedef implementation-defined_int48_t native_int48_ut; - typedef implementation-defined_int56_t native_int56_ut; - typedef implementation-defined_int64_t native_int64_ut; - - // unaligned native endian unsigned integer types - typedef implementation-defined_uint8_t native_uint8_ut; - typedef implementation-defined_uint16_t native_uint16_ut; - typedef implementation-defined_uint24_t native_uint24_ut; - typedef implementation-defined_uint32_t native_uint32_ut; - typedef implementation-defined_uint40_t native_uint40_ut; - typedef implementation-defined_uint48_t native_uint48_ut; - typedef implementation-defined_uint56_t native_uint56_ut; - typedef implementation-defined_uint64_t native_uint64_ut; - } // namespace endian } // namespace boost

The implementation-defined text above is either @@ -540,11 +546,11 @@ platform.

endian() = default;  // C++03: endian(){}
-

Effects: Constructs an object of type endian<E, T, n_bits, A>.

+

Effects: Constructs an uninitialized object of type endian_arithmetic<E, T, n_bits, A>.

endian(T v);
-

Effects: Constructs an object of type endian<E, T, n_bits, A>.

+

Effects: Constructs an object of type endian_arithmetic<E, T, n_bits, A>.

Postcondition: x == v, where x is the constructed object.

@@ -613,8 +619,7 @@ programming.

Why bother with the aligned endian types? Aligned integer operations may be faster (as much as 10 to 20 times faster) if the endianness and alignment of the type matches the endianness and alignment requirements of the machine. The code, -however, is -likely to be somewhat less portable than with the unaligned types.

+however, will be somewhat less portable than with the unaligned types.

Why provide the arithmetic operations? Providing a full set of operations reduces program clutter and makes code both easier to write and to read. Consider incrementing a variable in a record. It is very convenient to write:

@@ -688,7 +693,7 @@ differs from endian representation size. Vicente Botet and other reviewers suggested supporting floating point types.


Last revised: -17 February, 2015

+23 February, 2015

© Copyright Beman Dawes, 2006-2009, 2013

Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt

diff --git a/buffers.html b/buffers.html index a1f98f9..173ab14 100644 --- a/buffers.html +++ b/buffers.html @@ -1,4 +1,4 @@ - + @@ -184,7 +184,7 @@ will no longer be relying on unspecified behavior.

  • Signed | unsigned
  • Unaligned | aligned
  • Integer | floating point
  • -
  • 1-8 byte (unaligned) | 2, 4, 8 byte (aligned)
  • +
  • 1-8 byte (unaligned) | 1, 2, 4, 8 byte (aligned)
  • Choice of value type
  • Enums and typedefs

    @@ -201,7 +201,7 @@ enum class align {no, yes}; class endian_buffer; -

    Typedefs, such as big_int32_buf_ut, provide convenient naming +

    Typedefs, such as big_int32_buf_t, provide convenient naming conventions for common use cases:

    Sizes in bits (n)
    big_intn_utbig_intn_t no big signed 8,16,24,32,40,48,56,64
    big_uintn_utnobigunsigned8,16,24,32,40,48,56,64
    big_floatn_utnobigsigned32,64
    little_intn_utnolittlesigned8,16,24,32,40,48,56,64
    little_uintn_utnolittleunsigned8,16,24,32,40,48,56,64
    little_floatn_utnolittlesigned32,64
    native_intn_utnonativesigned8,16,24,32,40,48,56,64
    native_uintn_utnonativeunsigned8,16,24,32,40,48,56,64
    native_floatn_utnonativesigned32,64
    big_intn_tyesbigsigned8,16,32,64
    big_uintn_tnobigunsigned8,16,24,32,40,48,56,64
    big_floatn_tnobigsigned32,64
    little_intn_tnolittlesigned8,16,24,32,40,48,56,64
    little_uintn_tnolittleunsigned8,16,24,32,40,48,56,64
    little_floatn_tnolittlesigned32,64
    native_intn_tnonativesigned8,16,24,32,40,48,56,64
    native_uintn_tnonativeunsigned8,16,24,32,40,48,56,64
    native_floatn_tnonativesigned32,64
    big_intn_atyesbigsigned8,16,32,64
    big_uintn_at yes big unsigned 8,16,32,64
    big_floatn_tbig_floatn_at yes big signed 32,64
    little_intn_tlittle_intn_at yes little signed 8,16,32,64
    little_uintn_tlittle_uintn_at yes little unsigned 8,16,32,64
    little_floatn_tlittle_floatn_at yes little signed 32,64
    native_floatn_tnative_floatn_at yes native signed
    @@ -213,112 +213,112 @@ conventions for common use cases:

    - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -336,7 +336,7 @@ affected by compiler switches or pragmas. For example, alignment of an 64-bit integer may be to a 32-bit boundary on a 32-bit machine and to a 64-bit boundary on a 64-bit machine. Furthermore, aligned types are only available on architectures with 8, 16, 32, and 64-bit integer types.

    -

    Recommendation: Prefer unaligned endian types.

    +

    Recommendation: Prefer unaligned buffer types.

    Recommendation: Protect yourself against alignment ills. For example:

    @@ -398,105 +398,109 @@ usual operations on integers are supplied.

    // typedefs - // aligned big endian floating point buffers - typedef endian_buffer<order::big, float, 32, align::yes> big_float32_buf_t; - typedef endian_buffer<order::big, double, 64, align::yes> big_float64_buf_t; + // unaligned big endian signed integer buffers + typedef endian_buffer<order::big, int_least8_t, 8> big_int8_buf_t; + typedef endian_buffer<order::big, int_least16_t, 16> big_int16_buf_t; + typedef endian_buffer<order::big, int_least32_t, 24> big_int24_buf_t; + typedef endian_buffer<order::big, int_least32_t, 32> big_int32_buf_t; + typedef endian_buffer<order::big, int_least64_t, 40> big_int40_buf_t; + typedef endian_buffer<order::big, int_least64_t, 48> big_int48_buf_t; + typedef endian_buffer<order::big, int_least64_t, 56> big_int56_buf_t; + typedef endian_buffer<order::big, int_least64_t, 64> big_int64_buf_t; - // aligned little endian floating point buffers - typedef endian_buffer<order::little, float, 32, align::yes> little_float32_buf_t; - typedef endian_buffer<order::little, double, 64, align::yes> little_float64_buf_t; + // unaligned big endian unsigned integer buffers + typedef endian_buffer<order::big, uint_least8_t, 8> big_uint8_buf_t; + typedef endian_buffer<order::big, uint_least16_t, 16> big_uint16_buf_t; + typedef endian_buffer<order::big, uint_least32_t, 24> big_uint24_buf_t; + typedef endian_buffer<order::big, uint_least32_t, 32> big_uint32_buf_t; + typedef endian_buffer<order::big, uint_least64_t, 40> big_uint40_buf_t; + typedef endian_buffer<order::big, uint_least64_t, 48> big_uint48_buf_t; + typedef endian_buffer<order::big, uint_least64_t, 56> big_uint56_buf_t; + typedef endian_buffer<order::big, uint_least64_t, 64> big_uint64_buf_t; // unaligned big endian floating point buffers - typedef endian_buffer<order::big, float, 32, align::no> big_float32_buf_ut; - typedef endian_buffer<order::big, double, 64, align::no> big_float64_buf_ut; + typedef endian_buffer<order::big, float, 32> big_float32_buf_t; + typedef endian_buffer<order::big, double, 64> big_float64_buf_t; + + // unaligned little endian signed integer buffers + typedef endian_buffer<order::little, int_least8_t, 8> little_int8_buf_t; + typedef endian_buffer<order::little, int_least16_t, 16> little_int16_buf_t; + typedef endian_buffer<order::little, int_least32_t, 24> little_int24_buf_t; + typedef endian_buffer<order::little, int_least32_t, 32> little_int32_buf_t; + typedef endian_buffer<order::little, int_least64_t, 40> little_int40_buf_t; + typedef endian_buffer<order::little, int_least64_t, 48> little_int48_buf_t; + typedef endian_buffer<order::little, int_least64_t, 56> little_int56_buf_t; + typedef endian_buffer<order::little, int_least64_t, 64> little_int64_buf_t; + + // unaligned little endian unsigned integer buffers + typedef endian_buffer<order::little, uint_least8_t, 8> little_uint8_buf_t; + typedef endian_buffer<order::little, uint_least16_t, 16> little_uint16_buf_t; + typedef endian_buffer<order::little, uint_least32_t, 24> little_uint24_buf_t; + typedef endian_buffer<order::little, uint_least32_t, 32> little_uint32_buf_t; + typedef endian_buffer<order::little, uint_least64_t, 40> little_uint40_buf_t; + typedef endian_buffer<order::little, uint_least64_t, 48> little_uint48_buf_t; + typedef endian_buffer<order::little, uint_least64_t, 56> little_uint56_buf_t; + typedef endian_buffer<order::little, uint_least64_t, 64> little_uint64_buf_t; // unaligned little endian floating point buffers - typedef endian_buffer<order::little, float, 32, align::no> little_float32_buf_ut; - typedef endian_buffer<order::little, double, 64, align::no> little_float64_buf_ut; - + typedef endian_buffer<order::little, float, 32> little_float32_buf_t; + typedef endian_buffer<order::little, double, 64> little_float64_buf_t; + + // unaligned native endian signed integer types + typedef implementation-defined_int8_buf_t native_int8_buf_t; + typedef implementation-defined_int16_buf_t native_int16_buf_t; + typedef implementation-defined_int24_buf_t native_int24_buf_t; + typedef implementation-defined_int32_buf_t native_int32_buf_t; + typedef implementation-defined_int40_buf_t native_int40_buf_t; + typedef implementation-defined_int48_buf_t native_int48_buf_t; + typedef implementation-defined_int56_buf_t native_int56_buf_t; + typedef implementation-defined_int64_buf_t native_int64_buf_t; + + // unaligned native endian unsigned integer types + typedef implementation-defined_uint8_buf_t native_uint8_buf_t; + typedef implementation-defined_uint16_buf_t native_uint16_buf_t; + typedef implementation-defined_uint24_buf_t native_uint24_buf_t; + typedef implementation-defined_uint32_buf_t native_uint32_buf_t; + typedef implementation-defined_uint40_buf_t native_uint40_buf_t; + typedef implementation-defined_uint48_buf_t native_uint48_buf_t; + typedef implementation-defined_uint56_buf_t native_uint56_buf_t; + typedef implementation-defined_uint64_buf_t native_uint64_buf_t; + // aligned big endian signed integer buffers - typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_t; - typedef endian_buffer<order::big, int32_t, 32, align::yes> big_int32_buf_t; - typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_t; + typedef endian_buffer<order::big, int8_t, 8, align::yes> big_int8_buf_at; + typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_at; + typedef endian_buffer<order::big, int32_t, 32, align::yes> big_int32_buf_at; + typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_at; // aligned big endian unsigned integer buffers - typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_uint16_buf_t; - typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_t; - typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_t; + typedef endian_buffer<order::big, uint8_t, 8, align::yes> big_uint8_buf_at; + typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_uint16_buf_at; + typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_at; + typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_at; + + // aligned big endian floating point buffers + typedef endian_buffer<order::big, float, 32, align::yes> big_float32_buf_at; + typedef endian_buffer<order::big, double, 64, align::yes> big_float64_buf_at; // aligned little endian signed integer buffers - typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_t; - typedef endian_buffer<order::little, int32_t, 32, align::yes> little_int32_buf_t; - typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_t; + typedef endian_buffer<order::little, int8_t, 8, align::yes> little_int8_buf_at; + typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_at; + typedef endian_buffer<order::little, int32_t, 32, align::yes> little_int32_buf_at; + typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_at; // aligned little endian unsigned integer buffers - typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_uint16_buf_t; - typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_t; - typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_t; + typedef endian_buffer<order::little, uint8_t, 8, align::yes> little_uint8_buf_at; + typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_uint16_buf_at; + typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_at; + typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_at; + // aligned little endian floating point buffers + typedef endian_buffer<order::little, float, 32, align::yes> little_float32_buf_at; + typedef endian_buffer<order::little, double, 64, align::yes> little_float64_buf_at; + // aligned native endian typedefs are not provided because // <cstdint> types are superior for this use case - // unaligned big endian signed integer buffers - typedef endian_buffer<order::big, int_least8_t, 8> big_int8_buf_ut; - typedef endian_buffer<order::big, int_least16_t, 16> big_int16_buf_ut; - typedef endian_buffer<order::big, int_least32_t, 24> big_int24_buf_ut; - typedef endian_buffer<order::big, int_least32_t, 32> big_int32_buf_ut; - typedef endian_buffer<order::big, int_least64_t, 40> big_int40_buf_ut; - typedef endian_buffer<order::big, int_least64_t, 48> big_int48_buf_ut; - typedef endian_buffer<order::big, int_least64_t, 56> big_int56_buf_ut; - typedef endian_buffer<order::big, int_least64_t, 64> big_int64_buf_ut; - - // unaligned big endian unsigned integer buffers - typedef endian_buffer<order::big, uint_least8_t, 8> big_uint8_buf_ut; - typedef endian_buffer<order::big, uint_least16_t, 16> big_uint16_buf_ut; - typedef endian_buffer<order::big, uint_least32_t, 24> big_uint24_buf_ut; - typedef endian_buffer<order::big, uint_least32_t, 32> big_uint32_buf_ut; - typedef endian_buffer<order::big, uint_least64_t, 40> big_uint40_buf_ut; - typedef endian_buffer<order::big, uint_least64_t, 48> big_uint48_buf_ut; - typedef endian_buffer<order::big, uint_least64_t, 56> big_uint56_buf_ut; - typedef endian_buffer<order::big, uint_least64_t, 64> big_uint64_buf_ut; - - // unaligned little endian signed integer buffers - typedef endian_buffer<order::little, int_least8_t, 8> little_int8_buf_ut; - typedef endian_buffer<order::little, int_least16_t, 16> little_int16_buf_ut; - typedef endian_buffer<order::little, int_least32_t, 24> little_int24_buf_ut; - typedef endian_buffer<order::little, int_least32_t, 32> little_int32_buf_ut; - typedef endian_buffer<order::little, int_least64_t, 40> little_int40_buf_ut; - typedef endian_buffer<order::little, int_least64_t, 48> little_int48_buf_ut; - typedef endian_buffer<order::little, int_least64_t, 56> little_int56_buf_ut; - typedef endian_buffer<order::little, int_least64_t, 64> little_int64_buf_ut; - - // unaligned little endian unsigned integer buffers - typedef endian_buffer<order::little, uint_least8_t, 8> little_uint8_buf_ut; - typedef endian_buffer<order::little, uint_least16_t, 16> little_uint16_buf_ut; - typedef endian_buffer<order::little, uint_least32_t, 24> little_uint24_buf_ut; - typedef endian_buffer<order::little, uint_least32_t, 32> little_uint32_buf_ut; - typedef endian_buffer<order::little, uint_least64_t, 40> little_uint40_buf_ut; - typedef endian_buffer<order::little, uint_least64_t, 48> little_uint48_buf_ut; - typedef endian_buffer<order::little, uint_least64_t, 56> little_uint56_buf_ut; - typedef endian_buffer<order::little, uint_least64_t, 64> little_uint64_buf_ut; - - // unaligned native endian signed integer types - typedef implementation-defined_int8_buf_ut native_int8_buf_ut; - typedef implementation-defined_int16_buf_ut native_int16_buf_ut; - typedef implementation-defined_int24_buf_ut native_int24_buf_ut; - typedef implementation-defined_int32_buf_ut native_int32_buf_ut; - typedef implementation-defined_int40_buf_ut native_int40_buf_ut; - typedef implementation-defined_int48_buf_ut native_int48_buf_ut; - typedef implementation-defined_int56_buf_ut native_int56_buf_ut; - typedef implementation-defined_int64_buf_ut native_int64_buf_ut; - - // unaligned native endian unsigned integer types - typedef implementation-defined_uint8_buf_ut native_uint8_buf_ut; - typedef implementation-defined_uint16_buf_ut native_uint16_buf_ut; - typedef implementation-defined_uint24_buf_ut native_uint24_buf_ut; - typedef implementation-defined_uint32_buf_ut native_uint32_buf_ut; - typedef implementation-defined_uint40_buf_ut native_uint40_buf_ut; - typedef implementation-defined_uint48_buf_ut native_uint48_buf_ut; - typedef implementation-defined_uint56_buf_ut native_uint56_buf_ut; - typedef implementation-defined_uint64_buf_ut native_uint64_buf_ut; - } // namespace endian } // namespace boost

    The implementation-defined text in typedefs above is either @@ -546,7 +550,7 @@ boost::endian::endian_reverse.

    value_type value() const noexcept;
    -

    Returns: endian_value, converted to value_type +

    Returns: endian_value, converted to value_type, if required, and having the endianness of the native platform.

    Remarks: If Align is align::yes then endianness conversion, if required, is performed by @@ -659,7 +663,7 @@ any Boost object libraries.


    Last revised: -17 February, 2015

    +23 February, 2015

    © Copyright Beman Dawes, 2006-2009, 2013

    Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt

    diff --git a/index.html b/index.html index b651d6c..45a74fa 100644 --- a/index.html +++ b/index.html @@ -1,4 +1,4 @@ - + @@ -219,7 +219,7 @@ intrinsics as a source of performance issues.

    Sizes in bits (n)
    big_intn_buf_utbig_intn_buf_t no big signed 8,16,24,32,40,48,56,64
    big_uintn_buf_utbig_uintn_buf_t no big unsigned 8,16,24,32,40,48,56,64
    big_floatn_buf_utbig_floatn_buf_t no big signed 32,64
    little_intn_buf_utlittle_intn_buf_t no little signed 8,16,24,32,40,48,56,64
    little_uintn_buf_utlittle_uintn_buf_t no little unsigned 8,16,24,32,40,48,56,64
    little_floatn_buf_utlittle_floatn_buf_t no little signed 32,64
    native_intn_buf_utnative_intn_buf_t no native signed 8,16,24,32,40,48,56,64
    native_uintn_buf_utnative_uintn_buf_t no native unsigned 8,16,24,32,40,48,56,64
    native_floatn_buf_utnative_floatn_buf_t no native signed 32,64
    big_intn_buf_tbig_intn_buf_at yes big signed 8,16,32,64
    big_uintn_buf_tbig_uintn_buf_at yes big unsigned 8,16,32,64
    big_floatn_buf_tbig_floatn_buf_at yes big signed 32,64
    little_intn_buf_tlittle_intn_buf_at yes little signed 8,16,32,64
    little_uintn_buf_tlittle_uintn_buf_at yes little unsigned 8,16,32,64
    little_floatn_buf_tlittle_floatn_buf_at yes little signed 32,64
    native_floatn_buf_tnative_floatn_buf_at yes native signed
    -
    big_int32_t x;
    +    
    big_int32_at x;
     
     ... read into x from a file ...
     
    @@ -273,7 +273,7 @@ spent doing I/O will determine the speed of this application.

    -
    big_int32_t x;
    +    
    big_int32_at x;
     
     ... read into x from a file ...
     
    @@ -395,7 +395,7 @@ I/O formats? 

    Using the unaligned integer types with a size tailored to the application's needs is a minor secondary use that saves internal or external memory space. For -example, using big_int40_buf_ut or big_int40_ut in a +example, using big_int40_buf_t or big_int40_t in a large array saves a lot of space compared to one of the 64-bit types.

    Why bother with binary I/O? Why not just use C++ Standard Library stream @@ -489,12 +489,8 @@ review

  • The endian arithmetic type aliases have been renamed, using a naming pattern that is consistent for both integer and floating point, and a consistent set of aliases supplied for the endian buffer types.
  • -
  • The aligned-type alias names now have the _t suffix, for - consistency with the standard library integer type aliases and because use of - aligned types is much more common than unaligned types.
  • -
  • The unaligned-type alias names now have the _ut suffix. This - is short, yet stands out enough to alert the reader than unusual types are - involved.
  • +
  • The unaligned-type alias names still have the _t suffix, but + the aligned-type alias names now have an _at suffix..
  • endian_reverse() overloads for int8_t and uint8_t have been added for improved generality. (Pierre Talbot)
  • Overloads of endian_reverse_inplace() have been replaced with a single @@ -593,7 +589,7 @@ Blechmann, Tim Moore, tymofey, Tomas Puverle, Vincente Botet, Yuval Ronen and Vitaly Budovsk. Apologies if anyone has been missed.


    Last revised: -17 February, 2015

    +23 February, 2015

    © Copyright Beman Dawes, 2011, 2013

    Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt