Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bit structures/bit_cast #59

Closed
gpeterhoff opened this issue Jun 5, 2023 · 2 comments
Closed

bit structures/bit_cast #59

gpeterhoff opened this issue Jun 5, 2023 · 2 comments

Comments

@gpeterhoff
Copy link

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
boostorg/core#147 (not quite correct yet)

thx & regards
Gero

@mborland
Copy link
Member

mborland commented Jun 5, 2023

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.

@mborland mborland closed this as completed Jun 5, 2023
@gpeterhoff
Copy link
Author

Instead of <fp_traits.hpp> 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants