You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::ranges::filter_view has only non-const begin/end as it writes the filtered value into the view object (per standard requirements), yet the Catch::stringify and Catch::StringMaker...::convert both accept const-references only and IsStreamInsertable tests for std::declval<U> only (rvalue) with const T& as argument
To fix this I had to:
Change stringify to universal reference and use forward
Move IsStreamInsertable constness to the template argument (specified by callers)
Use std::declval<U&> in IsStreamInsertable is is_range_impl
Add non-const overloads to StringMaker (normal and range specialization)
Add a non-const overload to ReusableStringStream::operator<<
Remove const from rangeToString
Test case:
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_range_equals.hpp>
TEST_CASE("std::views::filter")
{
int const ints[] = {1, 2, 3};
auto range = ints | std::views::filter([](int const x) { return x % 2 == 0; });
int const expected[] = {3}; // forcing the error output
CHECK_THAT(range, Catch::Matchers::RangeEquals(expected));
}
std::ranges::filter_view
has only non-constbegin
/end
as it writes the filtered value into the view object (per standard requirements), yet theCatch::stringify
andCatch::StringMaker...::convert
both accept const-references only andIsStreamInsertable
tests forstd::declval<U>
only (rvalue) withconst T&
as argumentTo fix this I had to:
stringify
to universal reference and use forwardIsStreamInsertable
constness to the template argument (specified by callers)std::declval<U&>
inIsStreamInsertable
isis_range_impl
StringMaker
(normal and range specialization)ReusableStringStream::operator<<
rangeToString
Test case:
https://gcc.godbolt.org/z/4EexKf1d5
Expected:
Actually get:
The text was updated successfully, but these errors were encountered: