zbackup/static_assert.hh

28 lines
584 B
C++
Raw Normal View History

// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
2013-07-18 21:33:25 +04:00
#ifndef STATIC_ASSERT_HH_INCLUDED__
#define STATIC_ASSERT_HH_INCLUDED__
// Based on the one from the Boost library. It wouldn't make sense to depend on
// boost just for that
namespace StaticAssert {
template < bool >
struct AssertionFailure;
template <>
struct AssertionFailure< true >
{};
template< int > struct Test
{};
}
#define STATIC_ASSERT( B ) \
typedef ::StaticAssert::Test< \
sizeof( ::StaticAssert::AssertionFailure< bool( B ) > ) >\
static_assert_typedef_ ## __LINE__
#endif