mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-05 00:39:50 +00:00
Use static_assert()
This commit is contained in:
parent
dfc1ecd2da
commit
9d675b6864
@ -18,11 +18,7 @@ namespace base {
|
||||
// Undefined convertion
|
||||
template<typename To, typename From>
|
||||
To convert_to(const From& from) {
|
||||
// As this function doesn't return a value, if a specialization is
|
||||
// not found, a compiler error will be thrown (which means that
|
||||
// the conversion isn't supported).
|
||||
|
||||
// TODO Use a static_assert(false)
|
||||
static_assert(false && sizeof(To), "Invalid conversion");
|
||||
}
|
||||
|
||||
template<> int convert_to(const std::string& from);
|
||||
|
@ -93,23 +93,23 @@ static inline bool color_equal_8(color_t c1, color_t c2, int tolerance)
|
||||
template<typename ImageTraits>
|
||||
static inline bool color_equal(color_t c1, color_t c2, int tolerance)
|
||||
{
|
||||
// TODO static_assert(false)
|
||||
static_assert(false && sizeof(ImageTraits), "Invalid color comparison");
|
||||
}
|
||||
|
||||
template<>
|
||||
static inline bool color_equal<RgbTraits>(color_t c1, color_t c2, int tolerance)
|
||||
inline bool color_equal<RgbTraits>(color_t c1, color_t c2, int tolerance)
|
||||
{
|
||||
return color_equal_32(c1, c2, tolerance);
|
||||
}
|
||||
|
||||
template<>
|
||||
static inline bool color_equal<GrayscaleTraits>(color_t c1, color_t c2, int tolerance)
|
||||
inline bool color_equal<GrayscaleTraits>(color_t c1, color_t c2, int tolerance)
|
||||
{
|
||||
return color_equal_16(c1, c2, tolerance);
|
||||
}
|
||||
|
||||
template<>
|
||||
static inline bool color_equal<IndexedTraits>(color_t c1, color_t c2, int tolerance)
|
||||
inline bool color_equal<IndexedTraits>(color_t c1, color_t c2, int tolerance)
|
||||
{
|
||||
return color_equal_8(c1, c2, tolerance);
|
||||
}
|
||||
|
@ -38,9 +38,7 @@ namespace {
|
||||
|
||||
template<typename ImageTraits, int color_depth>
|
||||
int convert_color_to_allegro(color_t color, const Palette* palette) {
|
||||
// Error, it must use a specialization
|
||||
|
||||
// TODO Use a static_assert(false)
|
||||
static_assert(false && sizeof(ImageTraits), "Invalid color conversion");
|
||||
}
|
||||
|
||||
template<>
|
||||
|
@ -41,9 +41,7 @@ namespace {
|
||||
|
||||
template<typename ImageTraits, she::SurfaceFormat format>
|
||||
uint32_t convert_color_to_surface(color_t color, const Palette* palette, const she::SurfaceFormatData* fd) {
|
||||
// Error, it must use a specialization
|
||||
|
||||
// TODO Use a static_assert(false)
|
||||
static_assert(false && sizeof(ImageTraits), "Invalid color conversion");
|
||||
}
|
||||
|
||||
template<>
|
||||
|
Loading…
x
Reference in New Issue
Block a user