summaryrefslogtreecommitdiff
path: root/include/ftl/enum.h
diff options
context:
space:
mode:
author Dominik Laskowski <domlaskowski@google.com> 2022-11-15 16:53:53 -0500
committer Dominik Laskowski <domlaskowski@google.com> 2022-11-22 16:04:41 -0500
commitdfeded73f45229558693e227bc1c9f52102ea0af (patch)
tree94b0e2ceb446c3b65fbadd8b5bf848cff8b7d36c /include/ftl/enum.h
parent345d32bcbf1fdeae6be3989fc96c7ea9c2ac3957 (diff)
FTL: Add mixins for type-safe wrappers
For now, allow mixing in construction, default construction, equality, ordering, incrementing, and addition. Bug: 185536303 Test: ftl_test Change-Id: I9017e124656ba0e7f13f378814c5b1c19a36655b
Diffstat (limited to 'include/ftl/enum.h')
-rw-r--r--include/ftl/enum.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/ftl/enum.h b/include/ftl/enum.h
index 82af1d6cf8..075d12bd17 100644
--- a/include/ftl/enum.h
+++ b/include/ftl/enum.h
@@ -92,7 +92,7 @@ inline constexpr bool is_scoped_enum_v = is_scoped_enum<T>::value;
// enum class E { A, B, C };
// static_assert(ftl::to_underlying(E::B) == 1);
//
-template <typename E>
+template <typename E, typename = std::enable_if_t<std::is_enum_v<E>>>
constexpr auto to_underlying(E v) {
return static_cast<std::underlying_type_t<E>>(v);
}