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

Added float and double handling in gen_util.h #497

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions rd-cpp/src/rd_core_cpp/src/main/util/gen_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ size_t contentHashCode(C<T, A> const& list) noexcept
// TO-DO faster for integrals
}

template <typename T, typename = std::enable_if_t<std::is_integral<T>::value>>
template <typename T, typename = std::enable_if_t<std::is_arithmetic<T>::value>>
size_t contentDeepHashCode(T const& value) noexcept
{
return rd::hash<T>()(value);
Expand All @@ -31,22 +31,22 @@ template<class T>
using remove_all_t = std::remove_reference_t<std::remove_cv_t<T>>;

// optional and rd::Wrapper
template <class T, typename = std::enable_if_t<!std::is_integral<T>::value>>
template <class T, typename = std::enable_if_t<!std::is_arithmetic<T>::value>>
typename std::enable_if_t<std::is_same<decltype(T{}.has_value()), bool>::value, size_t> contentDeepHashCode(T const& value) noexcept
{
return rd::hash<remove_all_t<T>>()(value);
}

// containers
template <class T, typename = std::enable_if_t<!std::is_integral<T>::value>>
typename std::enable_if_t<std::is_integral<remove_all_t<decltype(*begin(T{}))>>::value, size_t> contentDeepHashCode(T const& value) noexcept
template <class T, typename = std::enable_if_t<!std::is_arithmetic<T>::value>>
typename std::enable_if_t<std::is_arithmetic<remove_all_t<decltype(*begin(T{}))>>::value, size_t> contentDeepHashCode(T const& value) noexcept
{
return contentHashCode(value);
}

// containers of non-integral types
template <class T, typename = std::enable_if_t<!std::is_integral<T>::value>>
typename std::enable_if_t<!std::is_integral<remove_all_t<decltype(*begin(T{}))>>::value, size_t> contentDeepHashCode(T const& value) noexcept
// containers of non-arithmetic types
template <class T, typename = std::enable_if_t<!std::is_arithmetic<T>::value>>
typename std::enable_if_t<!std::is_arithmetic<remove_all_t<decltype(*begin(T{}))>>::value, size_t> contentDeepHashCode(T const& value) noexcept
{
size_t result = 1;
for (auto const& x : value)
Expand Down
Loading