Make endian_arithmetic's data member public when BOOST_ENDIAN_NO_CTORS is defined; add test

This commit is contained in:
Peter Dimov
2020-10-06 19:34:40 +03:00
parent 9f122a913c
commit 7832a88828
3 changed files with 41 additions and 0 deletions

View File

@ -182,6 +182,13 @@ class endian_arithmetic
private:
typedef endian_buffer<Order, T, n_bits, Align> buffer_type;
#ifdef BOOST_ENDIAN_NO_CTORS
public:
#else
private:
#endif
buffer_type buf_;
public:

View File

@ -111,3 +111,4 @@ run-ni endian_reverse_test5.cpp ;
run packed_buffer_test.cpp ;
run arithmetic_buffer_test.cpp ;
run packed_arithmetic_test.cpp ;

View File

@ -0,0 +1,33 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if !defined(__GNUC__)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE( "Skipping test because __GNUC__ is not defined" )
int main() {}
#else
#define BOOST_ENDIAN_FORCE_PODNESS
#define BOOST_ENDIAN_NO_CTORS
#include <boost/endian/arithmetic.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::endian;
struct X
{
big_uint16_t a;
double b;
little_uint16_t c;
} __attribute__((packed));
int main()
{
BOOST_TEST_EQ( sizeof( X ), 12 );
return boost::report_errors();
}
#endif