Sprout/sprout/static_warning.hpp

50 lines
1.4 KiB
C++
Raw Normal View History

2014-03-01 01:35:24 +00:00
/*=============================================================================
2016-02-25 09:48:28 +00:00
Copyright (c) 2011-2016 Bolero MURAKAMI
2014-03-01 01:35:24 +00:00
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_STATIC_WARNING_HPP
#define SPROUT_STATIC_WARNING_HPP
#include <sprout/config.hpp>
namespace sprout {
//
// static_warning
//
template<bool C>
struct static_warning;
template<>
struct static_warning<true> {
template<typename Message>
static void warn() {}
};
template<>
2014-03-01 01:35:24 +00:00
struct static_warning<false> {
template<typename Message>
static void warn() {
Message static_warning_failed;
}
};
} // namespace sprout
//
// SPROUT_STATIC_WARNING
//
2014-08-14 13:55:49 +00:00
#define SPROUT_STATIC_WARNING_IMPL_2(COND, MSG, LINE) \
struct sprout_static_warning_line_ ## LINE { \
struct MSG {}; \
sprout_static_warning_line_ ## LINE() { \
::sprout::static_warning<(COND)>:: \
warn<void***** (MSG::*****)()>(); \
2014-03-01 01:35:24 +00:00
} \
}
2014-08-14 13:55:49 +00:00
#define SPROUT_STATIC_WARNING_IMPL(COND, MSG) \
SPROUT_STATIC_WARNING_IMPL_2(COND, MSG, __LINE__)
#define SPROUT_STATIC_WARNING(COND) \
SPROUT_STATIC_WARNING_IMPL(COND, static_warning_failed)
2014-03-01 01:35:24 +00:00
#endif // #ifndef SPROUT_STATIC_WARNING_HPP