Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/ftp/libfilezilla/files/extra-patch-lib_libfilezilla_string.hpp
16461 views
1
--- lib/libfilezilla/string.hpp.orig 2024-10-15 12:59:21 UTC
2
+++ lib/libfilezilla/string.hpp
3
@@ -11,6 +11,39 @@
4
#include <string_view>
5
#include <vector>
6
7
+template<class CharT, class BaseT>
8
+class traits_cloner
9
+{
10
+public:
11
+ using char_type = CharT;
12
+
13
+ using base_type = BaseT;
14
+ using base_traits = std::char_traits<base_type>;
15
+
16
+ static std::size_t length(char_type const* s) {
17
+ return base_traits::length(reinterpret_cast<base_type const*>(s));
18
+ }
19
+ static int compare(char_type const* s1, char_type const* s2, std::size_t count) {
20
+ return base_traits::compare(reinterpret_cast<base_type const*>(s1), reinterpret_cast<base_type const*>(s2), count);
21
+ }
22
+ static char_type* copy(char_type* dest, char_type const* src, std::size_t count) {
23
+ return reinterpret_cast<char_type*>(base_traits::copy(reinterpret_cast<base_type*>(dest), reinterpret_cast<base_type const*>(src), count));
24
+ }
25
+ static void assign( char_type& c1, char_type const& c2 ) noexcept {
26
+ c1 = c2;
27
+ }
28
+ static char_type const* find(char_type const* ptr, std::size_t count, char_type const& ch) {
29
+ return reinterpret_cast<char_type const*>(base_traits::find(reinterpret_cast<base_type const*>(ptr), count, reinterpret_cast<base_type const&>(ch)));
30
+ }
31
+ static bool eq(char_type a, char_type b) {
32
+ return base_traits::eq(static_cast<base_type>(a), static_cast<base_type>(b));
33
+ }
34
+};
35
+
36
+template<>
37
+class std::char_traits<uint8_t> : public traits_cloner<uint8_t, char>
38
+{};
39
+
40
/** \file
41
* \brief String types and assorted functions.
42
*
43
44