Skip to content

Commit

Permalink
Merge pull request #40057 from guitargeek/serialization_1
Browse files Browse the repository at this point in the history
Use `fp_traits_non_native` directly in eos-portable-archive
  • Loading branch information
cmsbuild committed Nov 28, 2022
2 parents d6cfe02 + 8c9d152 commit 992df75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions CondFormats/Serialization/interface/eos/portable_iarchive.hpp
Original file line number Diff line number Diff line change
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
* 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
Original file line number Diff line number Diff line change
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

0 comments on commit 992df75

Please sign in to comment.