1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
--- include/cpprest/astreambuf.h.orig 2023-12-05 04:23:31 UTC
+++ include/cpprest/astreambuf.h
@@ -15,6 +15,7 @@
#include "cpprest/asyncrt_utils.h"
#include "cpprest/details/basic_types.h"
+#include "cpprest/details/char_traits.h"
#include "pplx/pplxtasks.h"
#include <atomic>
#include <cstring>
@@ -56,55 +57,28 @@ namespace streams
/// <typeparam name="_CharType">
/// The data type of the basic element of the stream.
/// </typeparam>
+namespace detail
+{
template<typename _CharType>
-struct char_traits : std::char_traits<_CharType>
+struct char_traits : utility::CanUseStdCharTraits<_CharType>::TraitsType
{
/// <summary>
/// Some synchronous functions will return this value if the operation
/// requires an asynchronous call in a given situation.
/// </summary>
/// <returns>An <c>int_type</c> value which implies that an asynchronous call is required.</returns>
- static typename std::char_traits<_CharType>::int_type requires_async()
+ static typename utility::CanUseStdCharTraits<_CharType>::TraitsType::int_type requires_async()
{
- return std::char_traits<_CharType>::eof() - 1;
+ return utility::CanUseStdCharTraits<_CharType>::TraitsType::eof() - 1;
}
};
+}
+template<typename _CharType> struct char_traits : detail::char_traits<_CharType> {
+};
#if !defined(_WIN32)
-template<>
-struct char_traits<unsigned char> : private std::char_traits<char>
-{
-public:
- typedef unsigned char char_type;
-
- using std::char_traits<char>::eof;
- using std::char_traits<char>::int_type;
- using std::char_traits<char>::off_type;
- using std::char_traits<char>::pos_type;
-
- static size_t length(const unsigned char* str)
- {
- return std::char_traits<char>::length(reinterpret_cast<const char*>(str));
- }
-
- static void assign(unsigned char& left, const unsigned char& right) { left = right; }
- static unsigned char* assign(unsigned char* left, size_t n, unsigned char value)
- {
- return reinterpret_cast<unsigned char*>(
- std::char_traits<char>::assign(reinterpret_cast<char*>(left), n, static_cast<char>(value)));
- }
-
- static unsigned char* copy(unsigned char* left, const unsigned char* right, size_t n)
- {
- return reinterpret_cast<unsigned char*>(
- std::char_traits<char>::copy(reinterpret_cast<char*>(left), reinterpret_cast<const char*>(right), n));
- }
-
- static unsigned char* move(unsigned char* left, const unsigned char* right, size_t n)
- {
- return reinterpret_cast<unsigned char*>(
- std::char_traits<char>::move(reinterpret_cast<char*>(left), reinterpret_cast<const char*>(right), n));
- }
-
+template <> struct char_traits<unsigned char> : detail::char_traits<unsigned char> {
+ typedef typename std::char_traits<char>::int_type int_type;
+ static int_type eof() { return std::char_traits<char>::eof(); }
static int_type requires_async() { return eof() - 1; }
};
#endif
|