fix SPROUT_ASSERT

This commit is contained in:
bolero-MURAKAMI 2013-03-19 16:32:48 +09:00
parent 07f052fb6e
commit 2cb0f08555
3 changed files with 17 additions and 23 deletions

View file

@ -31,17 +31,8 @@
#if defined(SPROUT_DISABLE_ASSERTS) || defined(NDEBUG)
namespace sprout {
namespace detail {
inline SPROUT_CONSTEXPR bool
assertion_disabled() SPROUT_NOEXCEPT {
return true;
}
} // namespace detail
} // namespace sprout
# define SPROUT_ASSERT(expr) \
(sprout::detail::assertion_disabled())
((void)0)
#elif defined(SPROUT_ENABLE_ASSERT_HANDLER)
@ -80,9 +71,10 @@ namespace sprout {
} // namespace sprout
# define SPROUT_ASSERT(expr) ( \
sprout::detail::assertion_check( \
(void)sprout::detail::assertion_check( \
(expr), SPROUT_ASSERTION_FAILED_FORMAT(expr, __FILE__, __LINE__), \
#expr, "(unknown)"/*SPROUT_CURRENT_FUNCTION*/, __FILE__, __LINE__) \
#expr, "(unknown)"/*SPROUT_CURRENT_FUNCTION*/, __FILE__, __LINE__ \
) \
)
#else
@ -103,7 +95,7 @@ namespace sprout {
} // namespace sprout
# define SPROUT_ASSERT(expr) \
(sprout::detail::assertion_check((expr), SPROUT_ASSERTION_FAILED_FORMAT(expr, __FILE__, __LINE__)))
((void)sprout::detail::assertion_check((expr), SPROUT_ASSERTION_FAILED_FORMAT(expr, __FILE__, __LINE__)))
#endif
@ -114,7 +106,7 @@ namespace sprout {
#if defined(SPROUT_DISABLE_ASSERTS) || defined(NDEBUG)
# define SPROUT_ASSERT_MSG(expr, msg) \
(sprout::detail::assertion_disabled())
((void)0)
#elif defined(SPROUT_ENABLE_ASSERT_HANDLER)
@ -141,9 +133,10 @@ namespace sprout {
} // namespace sprout
# define SPROUT_ASSERT_MSG(expr, msg) ( \
sprout::detail::assertion_check_msg( \
(void)sprout::detail::assertion_check_msg( \
(expr), SPROUT_ASSERTION_FAILED_FORMAT(expr, __FILE__, __LINE__), \
#expr, msg, "(unknown)"/*SPROUT_CURRENT_FUNCTION*/, __FILE__, __LINE__) \
#expr, msg, "(unknown)"/*SPROUT_CURRENT_FUNCTION*/, __FILE__, __LINE__ \
) \
)
#else
@ -164,7 +157,7 @@ namespace sprout {
} // namespace sprout
# define SPROUT_ASSERT_MSG(expr, msg) \
(sprout::detail::assertion_check_msg((expr), SPROUT_ASSERTION_FAILED_FORMAT(expr, __FILE__, __LINE__), msg))
((void)sprout::detail::assertion_check_msg((expr), SPROUT_ASSERTION_FAILED_FORMAT(expr, __FILE__, __LINE__), msg))
#endif
@ -184,11 +177,12 @@ namespace sprout {
} // namespace sprout
# define SPROUT_VERIFY(expr) \
(sprout::detail::verification_disabled((expr)))
((void)(sprout::detail::verification_disabled((expr))))
#else
# define SPROUT_VERIFY(expr) SPROUT_ASSERT(expr)
# define SPROUT_VERIFY(expr) \
SPROUT_ASSERT(expr)
#endif

View file

@ -120,12 +120,12 @@ namespace sprout {
return get();
}
SPROUT_CONSTEXPR reference_const_type get() const {
return SPROUT_ASSERT(is_initialized()) ? val.get()
return (SPROUT_ASSERT(is_initialized()), true) ? val.get()
: val.get()
;
}
reference_type get() {
return SPROUT_ASSERT(is_initialized()) ? val.get()
return (SPROUT_ASSERT(is_initialized()), true) ? val.get()
: val.get()
;
}

View file

@ -291,7 +291,7 @@ namespace sprout {
I != sizeof...(Types),
typename sprout::tuples::tuple_element<I, tuple_type>::type const&
>::type get_at() const {
return SPROUT_ASSERT(I == which_) ? sprout::tuples::get<I>(tuple_)
return (SPROUT_ASSERT(I == which_), true) ? sprout::tuples::get<I>(tuple_)
: sprout::tuples::get<I>(tuple_)
;
}
@ -300,7 +300,7 @@ namespace sprout {
I != sizeof...(Types),
typename sprout::tuples::tuple_element<I, tuple_type>::type&
>::type get_at() {
return SPROUT_ASSERT(I == which_) ? sprout::tuples::get<I>(tuple_)
return (SPROUT_ASSERT(I == which_), true) ? sprout::tuples::get<I>(tuple_)
: sprout::tuples::get<I>(tuple_)
;
}