[libcxx-commits] [PATCH] D126663: [libc++][test] Refactor SmallBasicString uses in range.lazy.split tests

Konstantin Varlamov via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jun 15 00:29:08 PDT 2022


var-const added inline comments.


================
Comment at: libcxx/test/std/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/deref.pass.cpp:34
     static_assert(!std::is_reference_v<decltype(*i)>);
-    assert(SmallString(*i) == "abc"_str);
-    assert(SmallString(*(++i)) == "def"_str);
-    assert(SmallString(*(++i)) == "ghi"_str);
+    assert(std::ranges::equal(*i, "abc"s));
+    assert(std::ranges::equal(*(++i), "def"s));
----------------
jloser wrote:
> var-const wrote:
> > Why is calling `equal` necessary instead of `==`?
> There's no valid `operator==` now. The error is:
> 
> ```
> libcxx/test/std/ranges/range.adaptors/range.lazy.split/range.lazy.split.outer/deref.pass.cpp:35:15: error: invalid operands to binary expression ('std::ranges::lazy_split_view<ForwardDiffView, ForwardDiffView>::__outer_iterator<false>::value_type' and 'basic_string<char>')
>     assert(*i == "abc"s);
> ```
> 
> In the previous code, it worked because of
> 
> ```
> constexpr bool operator==(const BasicSmallString& lhs, std::string_view rhs)
> ```
> 
> in `small_string.h` if I understand correctly. Now that we removed `SmallString`, we don't have that comparison operator. Similar story in the other call sites that were made to use `std::ranges::equal`.
> 
> Does that make sense?
> 
Ah, right, basically dereferencing returns some helper type instead of a string, and we don't have the constructor taking a range for `std::string` yet. Thanks for explaining.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126663/new/

https://reviews.llvm.org/D126663



More information about the libcxx-commits mailing list