From b015a164f8544f4075e1c961b4c6fd1cd8b622bb Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 15 Oct 2019 02:26:58 +0300 Subject: [PATCH] Add floating point typedefs to arithmetic.hpp; rename double64 to float64 in buffers.hpp --- include/boost/endian/arithmetic.hpp | 14 ++++++++++++++ include/boost/endian/buffers.hpp | 10 +++++----- test/buffer_test.cpp | 18 +++++++++--------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/include/boost/endian/arithmetic.hpp b/include/boost/endian/arithmetic.hpp index 5e77c99..eb68a77 100644 --- a/include/boost/endian/arithmetic.hpp +++ b/include/boost/endian/arithmetic.hpp @@ -97,6 +97,12 @@ namespace endian typedef endian_arithmetic little_uint32_at; typedef endian_arithmetic little_uint64_at; + // aligned floating point types + typedef endian_arithmetic big_float32_at; + typedef endian_arithmetic big_float64_at; + typedef endian_arithmetic little_float32_at; + typedef endian_arithmetic little_float64_at; + // aligned native endian typedefs are not provided because // types are superior for this use case @@ -182,6 +188,14 @@ namespace endian typedef little_uint64_t native_uint64_t; # endif + // unaligned floating point types + typedef endian_arithmetic big_float32_t; + typedef endian_arithmetic big_float64_t; + typedef endian_arithmetic little_float32_t; + typedef endian_arithmetic little_float64_t; + typedef endian_arithmetic native_float32_t; + typedef endian_arithmetic native_float64_t; + //---------------------------------- end synopsis ------------------------------------// template big_float32_buf_at; - typedef endian_buffer big_double64_buf_at; + typedef endian_buffer big_float64_buf_at; typedef endian_buffer little_float32_buf_at; - typedef endian_buffer little_double64_buf_at; + typedef endian_buffer little_float64_buf_at; // aligned native endian typedefs are not provided because // types are superior for this use case @@ -193,11 +193,11 @@ namespace endian // unaligned floating point buffers typedef endian_buffer big_float32_buf_t; - typedef endian_buffer big_double64_buf_t; + typedef endian_buffer big_float64_buf_t; typedef endian_buffer little_float32_buf_t; - typedef endian_buffer little_double64_buf_t; + typedef endian_buffer little_float64_buf_t; typedef endian_buffer native_float32_buf_t; - typedef endian_buffer native_double64_buf_t; + typedef endian_buffer native_float64_buf_t; // Stream inserter template ( 0x0102030405060708ULL, 0xFE02030405060708ULL ); test_buffer_type( +1.5f, -3.14f ); - test_buffer_type( +1.5, -3.14 ); + test_buffer_type( +1.5, -3.14 ); test_buffer_type< little_int8_buf_at>( 0x01, -0x01 ); test_buffer_type( 0x0102, -0x0102 ); @@ -209,7 +209,7 @@ namespace test_buffer_type( 0x0102030405060708ULL, 0xFE02030405060708ULL ); test_buffer_type( +1.5f, -3.14f ); - test_buffer_type( +1.5, -3.14 ); + test_buffer_type( +1.5, -3.14 ); test_buffer_type< big_int8_buf_t>( 0x01, -0x01 ); test_buffer_type( 0x0102, -0x0102 ); @@ -221,7 +221,7 @@ namespace test_buffer_type( 0x0102030405060708LL, -0x0102030405060708LL ); test_buffer_type( +1.5f, -3.14f ); - test_buffer_type( +1.5, -3.14 ); + test_buffer_type( +1.5, -3.14 ); test_buffer_type< little_uint8_buf_t>( 0x01, 0xFE ); test_buffer_type( 0x0102, 0xFE02 ); @@ -233,7 +233,7 @@ namespace test_buffer_type( 0x0102030405060708ULL, 0xFE02030405060708ULL ); test_buffer_type( +1.5f, -3.14f ); - test_buffer_type( +1.5, -3.14 ); + test_buffer_type( +1.5, -3.14 ); std::cout << "test construction and assignment complete" << std::endl; }