mirror of
https://git.freebsd.org/ports.git
synced 2025-06-01 10:56:27 -04:00
As noted in the libc++ 19 release notes [1], std::char_traits<> is now only provided for char, char8_t, char16_t, char32_t and wchar_t, and any instantiation for other types will fail. This causes ports using devel/rapidfuzz-cpp to fail to compile with clang 19 and libc++ 19, resulting in errors similar to: /usr/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned int>' 820 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, | ^ /wrkdirs/usr/ports/devel/py-rapidfuzz/work-py311/rapidfuzz-3.9.6/src/rapidfuzz/cpp_common.hpp:711:25: note: in instantiation of template class 'std::basic_string<unsigned int>' requested here 711 | auto proc_str = rf::opcodes_apply<uint32_t>(ops, s1, s2); | ^ The devel/rapidfuzz-cpp port itself does "build" since it only gathers a bunch of headers and installs them into the stage area, but running 'make test' also fails similarly: /usr/include/c++/v1/string:820:42: error: implicit instantiation of undefined template 'std::char_traits<unsigned char>' 820 | static_assert(is_same<_CharT, typename traits_type::char_type>::value, | ^ /wrkdirs/usr/ports/devel/rapidfuzz-cpp/work/rapidfuzz-cpp-3.0.5/test/distance/examples/ocr.cpp:3:28: note: in instantiation of template class 'std::basic_string<unsigned char>' requested here 3 | std::basic_string<uint8_t> ocr_example1 = { | ^ /usr/include/c++/v1/__fwd/string.h:23:29: note: template is declared here 23 | struct _LIBCPP_TEMPLATE_VIS char_traits; | ^ Unfortunately rapidfuzz-cpp makes heavy use of the no-longer-existing `std::basic_string<uint8_t>`, so I had to do quite a lots of search and replace operations, replacing these with equivalent `std::vector` types. Note that as far as I can see, only devel/py-rapidfuzz is a consumer of this port, applying these changes should not disrupt anything else. I have a follow-up patch for that port too. [1] https://libcxx.llvm.org/ReleaseNotes/19.html#deprecations-and-removals PR: 281193 Approved by: yuri (maintainer) MFH: 2024Q3
88 lines
4.4 KiB
C++
88 lines
4.4 KiB
C++
--- test/distance/tests-Levenshtein.cpp.orig 2024-07-02 14:50:14 UTC
|
|
+++ test/distance/tests-Levenshtein.cpp
|
|
@@ -63,9 +63,9 @@ template <typename T>
|
|
}
|
|
|
|
template <typename T>
|
|
-std::basic_string<T> get_subsequence(const std::basic_string<T>& s, ptrdiff_t pos, ptrdiff_t len)
|
|
+std::vector<T> get_subsequence(const std::vector<T>& s, ptrdiff_t pos, ptrdiff_t len)
|
|
{
|
|
- return std::basic_string<T>(std::begin(s) + pos, std::begin(s) + pos + len);
|
|
+ return std::vector<T>(std::begin(s) + pos, std::begin(s) + pos + len);
|
|
}
|
|
|
|
template <typename Sentence1, typename Sentence2>
|
|
@@ -233,7 +233,7 @@ TEST_CASE("Levenshtein_editops")
|
|
std::string d = "XYZLorem ABC iPsum";
|
|
|
|
rapidfuzz::Editops ops = rapidfuzz::levenshtein_editops(s, d);
|
|
- REQUIRE(d == rapidfuzz::editops_apply<char>(ops, s, d));
|
|
+ REQUIRE(std::vector<char>{d.begin(), d.end()} == rapidfuzz::editops_apply<char>(ops, s, d));
|
|
REQUIRE(ops.get_src_len() == s.size());
|
|
REQUIRE(ops.get_dest_len() == d.size());
|
|
}
|
|
@@ -293,21 +293,21 @@ TEST_CASE("Levenshtein_editops[fuzzing_regressions]")
|
|
std::string s1 = "b";
|
|
std::string s2 = "aaaaaaaaaaaaaaaabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
|
rapidfuzz::Editops ops = rapidfuzz::levenshtein_editops(s1, s2);
|
|
- REQUIRE(s2 == rapidfuzz::editops_apply<char>(ops, s1, s2));
|
|
+ REQUIRE(std::vector<char>{s2.begin(), s2.end()} == rapidfuzz::editops_apply<char>(ops, s1, s2));
|
|
}
|
|
|
|
{
|
|
std::string s1 = "aa";
|
|
std::string s2 = "abb";
|
|
rapidfuzz::Editops ops = rapidfuzz::levenshtein_editops(s1, s2);
|
|
- REQUIRE(s2 == rapidfuzz::editops_apply<char>(ops, s1, s2));
|
|
+ REQUIRE(std::vector<char>{s2.begin(), s2.end()} == rapidfuzz::editops_apply<char>(ops, s1, s2));
|
|
}
|
|
|
|
{
|
|
std::string s1 = str_multiply(std::string("abb"), 8 * 64);
|
|
std::string s2 = str_multiply(std::string("ccccca"), 8 * 64);
|
|
rapidfuzz::Editops ops = rapidfuzz::levenshtein_editops(s1, s2);
|
|
- REQUIRE(s2 == rapidfuzz::editops_apply<char>(ops, s1, s2));
|
|
+ REQUIRE(std::vector<char>{s2.begin(), s2.end()} == rapidfuzz::editops_apply<char>(ops, s1, s2));
|
|
}
|
|
}
|
|
|
|
@@ -352,7 +352,7 @@ TEST_CASE("Levenshtein small band")
|
|
rapidfuzz::Editops ops1;
|
|
rapidfuzz::detail::levenshtein_align(ops1, rapidfuzz::detail::Range(s1),
|
|
rapidfuzz::detail::Range(s2));
|
|
- REQUIRE(s2 == rapidfuzz::editops_apply<char>(ops1, s1, s2));
|
|
+ REQUIRE(std::vector<char>{s2.begin(), s2.end()} == rapidfuzz::editops_apply<char>(ops1, s1, s2));
|
|
rapidfuzz::Editops ops2;
|
|
rapidfuzz::detail::levenshtein_align(ops2, rapidfuzz::detail::Range(s1), rapidfuzz::detail::Range(s2),
|
|
ops1.size());
|
|
@@ -400,7 +400,7 @@ TEST_CASE("Levenshtein small band")
|
|
rapidfuzz::Editops ops1;
|
|
rapidfuzz::detail::levenshtein_align(ops1, rapidfuzz::detail::Range(s1),
|
|
rapidfuzz::detail::Range(s2));
|
|
- REQUIRE(s2 == rapidfuzz::editops_apply<char>(ops1, s1, s2));
|
|
+ REQUIRE(std::vector<char>{s2.begin(), s2.end()} == rapidfuzz::editops_apply<char>(ops1, s1, s2));
|
|
rapidfuzz::Editops ops2;
|
|
rapidfuzz::detail::levenshtein_align(ops2, rapidfuzz::detail::Range(s1), rapidfuzz::detail::Range(s2),
|
|
ops1.size());
|
|
@@ -416,8 +416,8 @@ TEST_CASE("Levenshtein large band (python-Levenshtein
|
|
REQUIRE(example2.size() == 5569);
|
|
|
|
{
|
|
- std::basic_string<uint8_t> s1 = get_subsequence(example1, 3718, 1509);
|
|
- std::basic_string<uint8_t> s2 = get_subsequence(example2, 2784, 2785);
|
|
+ std::vector<uint8_t> s1 = get_subsequence(example1, 3718, 1509);
|
|
+ std::vector<uint8_t> s2 = get_subsequence(example2, 2784, 2785);
|
|
|
|
REQUIRE(rapidfuzz::levenshtein_distance(s1, s2) == 1587);
|
|
|
|
@@ -440,8 +440,8 @@ TEST_CASE("Levenshtein large band (ocr example)")
|
|
REQUIRE(ocr_example2.size() == 107244);
|
|
|
|
{
|
|
- std::basic_string<uint8_t> s1 = get_subsequence(ocr_example1, 51, 6541);
|
|
- std::basic_string<uint8_t> s2 = get_subsequence(ocr_example2, 51, 6516);
|
|
+ std::vector<uint8_t> s1 = get_subsequence(ocr_example1, 51, 6541);
|
|
+ std::vector<uint8_t> s2 = get_subsequence(ocr_example2, 51, 6516);
|
|
|
|
rapidfuzz::Editops ops1;
|
|
rapidfuzz::detail::levenshtein_align(ops1, rapidfuzz::detail::Range(s1),
|