Use static_assert()

This commit is contained in:
David Capello 2014-08-15 00:24:59 -03:00
parent dfc1ecd2da
commit 9d675b6864
4 changed files with 7 additions and 15 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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<>

View File

@ -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<>