__builtin_abort();
}
}
-#define __glibcxx_assert_impl(_Condition) \
- do \
- { \
- if (! (_Condition)) \
- std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
- #_Condition); \
- } while (false)
+#define __glibcxx_assert_impl(_Condition) \
+ if (!bool(_Condition)) \
+ std::__replacement_assert(__FILE__, __LINE__, __PRETTY_FUNCTION__, \
+ #_Condition)
#endif
#if defined(_GLIBCXX_ASSERTIONS)
-# define __glibcxx_assert(_Condition) __glibcxx_assert_impl(_Condition)
+# define __glibcxx_assert_2(_Condition) __glibcxx_assert_impl(_Condition)
#else
-# define __glibcxx_assert(_Condition)
+# define __glibcxx_assert_2(_Condition)
#endif
// Macros for race detectors.
# endif
#endif // GCC
+#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+# define __glibcxx_assert_1(_Condition) \
+ if (__builtin_is_constant_evaluated()) \
+ { \
+ void __failed_assertion(); \
+ if (!bool(_Condition)) \
+ __failed_assertion(); \
+ } \
+ else
+#else
+# define __glibcxx_assert_1(_Condition)
+#endif
+
+# define __glibcxx_assert(_Condition) \
+ do { \
+ __glibcxx_assert_1(_Condition) \
+ { __glibcxx_assert_2(_Condition); } \
+ } while (false)
+
+
// PSTL configuration
#if __cplusplus >= 201703L
}
else
{
-#ifdef __cpp_lib_is_constant_evaluated
- if (std::is_constant_evaluated() && __n < 0)
- throw "attempt to decrement a non-bidirectional iterator";
-#endif
+ // cannot decrement a non-bidirectional iterator
__glibcxx_assert(__n >= 0);
while (__n-- > 0)
++__it;
}
else
{
-#ifdef __cpp_lib_is_constant_evaluated
- if (std::is_constant_evaluated() && __n < 0)
- throw "attempt to decrement a non-bidirectional iterator";
-#endif
+ // cannot decrement a non-bidirectional iterator
__glibcxx_assert(__n >= 0);
return __n;
}
}
#if _GLIBCXX_PARALLEL_ASSERTIONS && defined(__glibcxx_assert_impl)
-#define _GLIBCXX_PARALLEL_ASSERT(_Condition) __glibcxx_assert_impl(_Condition)
+# define _GLIBCXX_PARALLEL_ASSERT(_Condition) \
+ do { __glibcxx_assert_impl(_Condition); } while (false)
#else
-#define _GLIBCXX_PARALLEL_ASSERT(_Condition)
+# define _GLIBCXX_PARALLEL_ASSERT(_Condition) do { } while (false)
#endif
} //namespace __gnu_parallel
: _M_value(__value), _M_bound(__bound)
{
if constexpr (totally_ordered_with<_Winc, _Bound>)
- {
- __glibcxx_assert( bool(__value <= __bound) );
- }
+ __glibcxx_assert( bool(__value <= __bound) );
}
constexpr _Iterator