added assert_nothrow and added ranges_equal
This commit is contained in:
parent
4e448f2f85
commit
9fb3eb0419
|
|
@ -33,6 +33,7 @@ constexpr auto make_copy(auto& value) -> std::remove_cvref_t<decltype(value)> {
|
|||
#define ASSERT(condition, ...) ASSERT_MSG((condition), "Condition (" #condition ") evaluated to false" _LOCATION, __VA_ARGS__)
|
||||
#define ASSERT_MSG(condition, msg, ...) { if (!(condition)) return _ret_val_from_ctx<__VA_ARGS__>(ReturnCode::FAILED, msg); } static_assert(true, "")
|
||||
#define ASSERT_THROWS(operation, exception_type, ...) if not consteval { try { operation; ASSERT_MSG(false, #operation " did not throw " #exception_type _LOCATION, __VA_ARGS__); } catch (exception_type &e) {} } static_assert(true, "")
|
||||
#define ASSERT_NOTHROW(operation, exception_type, ...) if not consteval { try { operation; } catch (exception_type &e) { ASSERT_MSG(false, #operation " threw " #exception_type _LOCATION, __VA_ARGS__); } } static_assert(true, "")
|
||||
|
||||
template<typename T>
|
||||
concept StringLike = std::is_convertible_v<T, std::string_view>;
|
||||
|
|
@ -66,6 +67,19 @@ constexpr bool all_equal_to(I first, S last, T t) {
|
|||
return std::ranges::equal(r1, r2);
|
||||
}
|
||||
|
||||
template<std::ranges::range R1, std::ranges::range R2>
|
||||
requires StringLike<std::ranges::range_value_t<R1>> && StringLike<std::ranges::range_value_t<R2>>
|
||||
constexpr bool ranges_equal(R1 r1, R2 r2) {
|
||||
auto r1t = r1 | std::ranges::views::transform([](auto&& e) constexpr { return std::string_view(e); });
|
||||
auto r2t = r2 | std::ranges::views::transform([](auto&& e) constexpr { return std::string_view(e); });
|
||||
return std::ranges::equal(r1t, r2t);
|
||||
}
|
||||
|
||||
template<std::ranges::range R1, std::ranges::range R2>
|
||||
constexpr bool ranges_equal(R1 r1, R2 r2) {
|
||||
return std::ranges::equal(r1, r2);
|
||||
}
|
||||
|
||||
template<std::input_iterator I, std::sentinel_for<I> S, std::ranges::range R>
|
||||
requires StringLike<std::ranges::range_value_t<R>>
|
||||
constexpr bool equal_to(I first, S last, R r) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue