summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2022-02-15 20:43:43 +1100
committerMaxime Coste <mawww@kakoune.org>2022-02-15 20:43:43 +1100
commitb030fc4c07ad2bc76abb7377256924cd43dfab5b (patch)
tree862757128022ead5cd4a7d5eeb2e1ab81debf957 /src
parent33e81af0f3b6dff09903d2d3aaa36e7800941166 (diff)
parentd1ea2ffa600fd2a7b14e415b68ceedba3325c5db (diff)
Merge remote-tracking branch 'Screwtapello/validate_alpha-is-constexpr'
Diffstat (limited to 'src')
-rw-r--r--src/color.cc7
-rw-r--r--src/color.hh7
2 files changed, 6 insertions, 8 deletions
diff --git a/src/color.cc b/src/color.cc
index b355b9cf..dfe2e955 100644
--- a/src/color.cc
+++ b/src/color.cc
@@ -34,13 +34,6 @@ bool is_color_name(StringView color)
return contains(color_names, color);
}
-void Color::validate_alpha()
-{
- static_assert(RGB == 17);
- if (a < RGB)
- throw runtime_error("Colors alpha must be > 16");
-}
-
Color str_to_color(StringView color)
{
auto it = find_if(color_names, [&](const char* c){ return color == c; });
diff --git a/src/color.hh b/src/color.hh
index 943678ed..85babd98 100644
--- a/src/color.hh
+++ b/src/color.hh
@@ -1,6 +1,7 @@
#ifndef color_hh_INCLUDED
#define color_hh_INCLUDED
+#include "exception.hh"
#include "hash.hh"
#include "meta.hh"
#include "assert.hh"
@@ -55,7 +56,11 @@ struct Color
}
private:
- void validate_alpha();
+ constexpr void validate_alpha() {
+ static_assert(RGB == 17);
+ if (a < RGB)
+ throw runtime_error("Colors alpha must be > 16");
+ }
};
constexpr bool operator==(Color lhs, Color rhs)