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