zbackup/static_assert.hh

29 lines
686 B
C++
Raw Normal View History

2014-12-11 10:50:15 +03:00
// Copyright (c) 2012-2014 Konstantin Isakov <ikm@zbackup.org> and ZBackup contributors, see CONTRIBUTORS
// 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
2013-07-18 21:33:25 +04:00
// 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