summaryrefslogtreecommitdiff
path: root/asl/option.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/option.hpp')
-rw-r--r--asl/option.hpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/asl/option.hpp b/asl/option.hpp
index eb6a91c..f7a3eab 100644
--- a/asl/option.hpp
+++ b/asl/option.hpp
@@ -5,6 +5,7 @@
#include "asl/maybe_uninit.hpp"
#include "asl/functional.hpp"
#include "asl/annotations.hpp"
+#include "asl/hash.hpp"
namespace asl
{
@@ -485,9 +486,24 @@ public:
{
return has_value() ? ASL_MOVE(*this) : invoke(ASL_FWD(f));
}
+
+ template<typename H>
+ requires (!uniquely_represented<option>) && hashable<T>
+ friend H AslHashValue(H h, const option& opt)
+ {
+ if (!opt.has_value())
+ {
+ return H::combine(ASL_MOVE(h), 0);
+ }
+ return H::combine(ASL_MOVE(h), 1, opt.value());
+ }
};
template<typename T>
+requires has_niche<T> && uniquely_represented<T>
+struct is_uniquely_represented<option<T>> : true_type {};
+
+template<typename T>
option(T) -> option<T>;
} // namespace asl