boostorg / charconv

C++11 compatible charconv
https://www.boost.org/doc/libs/master/libs/charconv/doc/html/charconv.html
Boost Software License 1.0
26 stars 15 forks source link

bit structures/bit_cast #59

Closed gpeterhoff closed 1 year ago

gpeterhoff commented 1 year ago

Hello Matt, I see you are implementing the bit structures twice: https://github.com/cppalliance/charconv/blob/develop/include/boost/charconv/detail/bit_layouts.hpp https://github.com/boostorg/math/blob/develop/include/boost/math/ccmath/signbit.hpp

I think it is better to do this only once, for example in boost::math::bits: bits.hpp.txt In detail I first provide various bit structures, no matter if they are needed or not. In bits the "normal" bit structures are available.

In https://github.com/boostorg/math/blob/develop/include/boost/math/ccmath/signbit.hpp you still implement BOOST_MATH_BIT_CAST. This is not necessary anymore, because Peter has adapted boost::core::bit_cast https://github.com/boostorg/core/blob/develop/include/boost/core/bit.hpp https://github.com/boostorg/core/issues/147 (not quite correct yet)

thx & regards Gero

mborland commented 1 year ago

I am unable to use your implementation, or the one from Boost.Math because this is a C++11 library and <boost/math/special_functions/detail/fp_traits.hpp> requires C++14. I could move the definitions to a standalone file in Boost.Math, but that is a heavy dependency for a few macros. I am not super worried about code duplication in this instance for a small number of well defined values that are unlikely to change.

gpeterhoff commented 1 year ago

Instead of we can use <boost/predef/other/endian.h> directly and in the bit structures:

struct X_bits {

if defined(BOOST_ENDIAN_LITTLE_BYTE_AVAILABLE)

else

endif

};

This makes more sense anyway and the code duplication can be omitted.