dxx-rebirth/common/include/compiler-static_assert.h

20 lines
664 B
C
Raw Normal View History

2014-06-01 17:55:23 +00:00
/*
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
2014-06-01 17:55:23 +00:00
* It is copyright by its individual contributors, as recorded in the
* project's Git history. See COPYING.txt at the top level for license
* terms and a link to the Git history.
*/
2013-12-21 05:12:38 +00:00
#pragma once
#include <type_traits>
2014-04-27 03:07:24 +00:00
#define DEFINE_ASSERT_HELPER_CLASS(N,OP,STR) \
template <typename T, T L, T R> \
class N : public std::integral_constant<bool, (L OP R)> \
2014-04-27 03:07:24 +00:00
{ \
static_assert(L OP R, STR); \
}
DEFINE_ASSERT_HELPER_CLASS(assert_equal, ==, "values must be equal");
#define assert_equal(L,R,S) static_assert((assert_equal<decltype((L) + 0), (L) + 0, (R) + 0>::value), S)