Skip to content

Commit

Permalink
Fixed (hopefully) axis == integral and joker comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Domagoj Šarić committed Aug 3, 2023
1 parent 0c34146 commit 6afa7f7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions include/kwk/settings/axis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
#include <kwk/detail/traits.hpp>
#include <kwk/detail/stdfix.hpp>
#include <kwk/utility/joker.hpp>
#include <concepts>
#include <type_traits>
#include <ostream>

namespace kwk { struct joker; }

namespace kwk::__
{
struct type_;

template<auto ID> constexpr bool is_implicit { false };
template<std::integral auto ID> constexpr bool is_implicit<ID>{ ID < 0 };

Expand Down Expand Up @@ -103,9 +106,13 @@ namespace kwk::__
return axis_<ID,decltype(v)>{v};
}

template <typename T>
KWK_PURE constexpr bool operator ==(T const v) const noexcept requires(!concepts::axis<T>) { return value == v; }
KWK_PURE constexpr bool operator ==(joker ) const noexcept { return std::same_as<content_type, joker>; }
template <typename T> requires( !concepts::axis<T> )
KWK_PURE constexpr bool operator ==(T const v) const noexcept
requires requires{ { (Content const){} == v } -> std::convertible_to<bool>; } // poorman's std::equality_comparable_with<T, content_type>
{ return value == v; }

// test whether an axis has an unspecified (runtime) value
KWK_PURE constexpr bool operator==( joker ) const noexcept { return std::same_as<content_type, joker> || requires{ requires std::same_as<typename content_type::keyword_type, __::type_>; }; }

KWK_PURE explicit constexpr operator Content () const noexcept { return value; }
KWK_PURE constexpr Content operator*() const noexcept { return value; }
Expand Down

0 comments on commit 6afa7f7

Please sign in to comment.