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

Fix C++20 compatibility for filtered_hash #608

Open
wants to merge 1 commit into
base: main
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
16 changes: 4 additions & 12 deletions Rx/v2/src/rxcpp/rx-util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -996,22 +996,16 @@ struct filtered_hash<T, typename std::enable_if<rxu::is_string<T>::value>::type>
};
template <class T>
struct filtered_hash<T, typename std::enable_if<std::is_convertible<T, std::chrono::duration<typename T::rep, typename T::period>>::value>::type> {
using argument_type = T;
using result_type = std::size_t;

result_type operator()(argument_type const & dur) const
std::size_t operator()(T const & dur) const
{
return std::hash<typename argument_type::rep>{}(dur.count());
return std::hash<typename T::rep>{}(dur.count());
}
};
template <class T>
struct filtered_hash<T, typename std::enable_if<std::is_convertible<T, std::chrono::time_point<typename T::clock, typename T::duration>>::value>::type> {
using argument_type = T;
using result_type = std::size_t;

result_type operator()(argument_type const & tp) const
std::size_t operator()(T const & tp) const
{
return std::hash<typename argument_type::rep>{}(tp.time_since_epoch().count());
return std::hash<typename T::rep>{}(tp.time_since_epoch().count());
}
};

Expand All @@ -1022,8 +1016,6 @@ struct is_hashable
template<typename T>
struct is_hashable<T,
typename rxu::types_checked_from<
typename filtered_hash<T>::result_type,
typename filtered_hash<T>::argument_type,
typename rxu::callable_result<filtered_hash<T>, T>::type>::type>
: std::true_type {};

Expand Down