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

Use fp_traits_non_native directly in eos-portable-archive #40057

Merged
merged 1 commit into from Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions CondFormats/Serialization/interface/eos/portable_iarchive.hpp
Expand Up @@ -371,13 +371,13 @@ namespace eos {
/**
* \brief Load floating point types.
*
* We simply rely on fp_traits to set the bit pattern from the (unsigned)
* We simply rely on fp_traits_non_native to set the bit pattern from the (unsigned)
* integral type that was stored in the stream. Francois Mauger provided
* standardized behaviour for special values like inf and NaN, that need to
* be serialized in his application.
*
* \note by Johan Rade (author of the floating point utilities library):
* Be warned that the math::detail::fp_traits<T>::type::get_bits() function
* Be warned that the math::detail::fp_traits_non_native<T,U>::get_bits() function
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @guitargeek is this comment still true with fp_traits_non_native ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, yes, because before fp_traits<T> was resolving to fp_traits_non_native::type anyway, so is must come from there (fp_traits_non_native is the only fp_traits implementation that has a get_bits member, fp_traits_native doesn't have it)

* is *not* guaranteed to give you all bits of the floating point number. It
* will give you all bits if and only if there is an integer type that has
* the same size as the floating point you are copying from. It will not
Expand All @@ -397,7 +397,8 @@ namespace eos {
*/
template <typename T>
typename boost::enable_if<boost::is_floating_point<T> >::type load(T& t, dummy<3> = 0) {
typedef typename fp::detail::fp_traits<T>::type traits;
typedef typename fp::detail::size_to_precision<sizeof(T), ::std::is_floating_point<T>::value>::type precision;
typedef typename fp::detail::fp_traits_non_native<T, precision> traits;

// if you end here there are three possibilities:
// 1. you're serializing a long double which is not portable
Expand Down
7 changes: 4 additions & 3 deletions CondFormats/Serialization/interface/eos/portable_oarchive.hpp
Expand Up @@ -353,13 +353,13 @@ namespace eos {
/**
* \brief Save floating point types.
*
* We simply rely on fp_traits to extract the bit pattern into an (unsigned)
* We simply rely on fp_traits_non_native to extract the bit pattern into an (unsigned)
* integral type and store that into the stream. Francois Mauger provided
* standardized behaviour for special values like inf and NaN, that need to
* be serialized in his application.
*
* \note by Johan Rade (author of the floating point utilities library):
* Be warned that the math::detail::fp_traits<T>::type::get_bits() function
* Be warned that the math::detail::fp_traits_non_native<T,U>::get_bits() function
* is *not* guaranteed to give you all bits of the floating point number. It
* will give you all bits if and only if there is an integer type that has
* the same size as the floating point you are copying from. It will not
Expand All @@ -379,7 +379,8 @@ namespace eos {
*/
template <typename T>
typename boost::enable_if<boost::is_floating_point<T> >::type save(const T& t, dummy<3> = 0) {
typedef typename fp::detail::fp_traits<T>::type traits;
typedef typename fp::detail::size_to_precision<sizeof(T), ::std::is_floating_point<T>::value>::type precision;
typedef typename fp::detail::fp_traits_non_native<T, precision> traits;

// if the no_infnan flag is set we must throw here
if (get_flags() & no_infnan && !fp::isfinite(t))
Expand Down