Skip to content

Instantly share code, notes, and snippets.

@hkaiser
Forked from gonidelis/is_sentinel_for.hpp
Created June 5, 2020 12:50
Show Gist options
  • Save hkaiser/05a9215d0ac2a07a1d74840553ee93be to your computer and use it in GitHub Desktop.
Save hkaiser/05a9215d0ac2a07a1d74840553ee93be to your computer and use it in GitHub Desktop.
#include <hpx/type_support/always_void.hpp>
#include <utility>
namespace hpx { namespace traits {
///////////////////////////////////////////////////////////////////////////
namespace detail {
template <typename T, typename U, typename Enable = void>
struct equality_result
{
};
template <typename T, typename U>
struct equality_result<T, U,
typename util::always_void<decltype(
std::declval<const T&>() == std::declval<const U&>())>::type>
{
using type =
decltype(std::declval<const T&>() == std::declval<const U&>());
};
template <typename T, typename U, typename Enable = void>
struct inequality_result
{
};
template <typename T, typename U>
struct inequality_result<T, U,
typename util::always_void<decltype(
std::declval<const T&>() != std::declval<const U&>())>::type>
{
using type =
decltype(std::declval<const T&>() != std::declval<const U&>());
};
} // namespace detail
template <typename Iter, typename Sent, typename Enable = void>
struct is_sentinel_for : std::false_type
{
};
template <typename Iter, typename Sent>
struct is_sentinel_for<Iter, Sent,
typename util::always_void<typename detail::equality_result<Iter, Sent>::type,
typename detail::inequality_result<Iter, Sent>::type>::type>
: std::true_type
{
};
}} // namespace hpx::traits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment