Merge remote-tracking branch 'Screwtapello/validate_alpha-is-constexpr'
This commit is contained in:
commit
b030fc4c07
|
@ -34,13 +34,6 @@ bool is_color_name(StringView color)
|
||||||
return contains(color_names, 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)
|
Color str_to_color(StringView color)
|
||||||
{
|
{
|
||||||
auto it = find_if(color_names, [&](const char* c){ return color == c; });
|
auto it = find_if(color_names, [&](const char* c){ return color == c; });
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef color_hh_INCLUDED
|
#ifndef color_hh_INCLUDED
|
||||||
#define color_hh_INCLUDED
|
#define color_hh_INCLUDED
|
||||||
|
|
||||||
|
#include "exception.hh"
|
||||||
#include "hash.hh"
|
#include "hash.hh"
|
||||||
#include "meta.hh"
|
#include "meta.hh"
|
||||||
#include "assert.hh"
|
#include "assert.hh"
|
||||||
|
@ -55,7 +56,11 @@ struct Color
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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)
|
constexpr bool operator==(Color lhs, Color rhs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user