@@ -60,22 +60,6 @@ class BasicStringUnicode
60
60
template <typename DesiredStringType, typename SourceStringType = StringType>
61
61
static std::optional<DesiredStringType> convert_encoding (SourceStringType &&value);
62
62
63
- /* *
64
- * Convert the Unicode encoding of a string to another encoding.
65
- *
66
- * @tparam DesiredStringType The type of string to convert to.
67
- * @tparam IteratorType The type of the encoded Unicode string's iterator.
68
- *
69
- * @param it Pointer to the beginning of the encoded Unicode string.
70
- * @param end Pointer to the end of the encoded Unicode string.
71
- *
72
- * @return If successful, a copy of the source string with the desired encoding. Otherwise, an
73
- * uninitialized value.
74
- */
75
- template <typename DesiredStringType, typename IteratorType>
76
- static std::optional<DesiredStringType>
77
- convert_encoding (IteratorType &it, const IteratorType &end);
78
-
79
63
/* *
80
64
* Convert the Unicode encoding of a string to another encoding, inserting the result into the
81
65
* provided output iterator.
@@ -96,23 +80,6 @@ class BasicStringUnicode
96
80
typename SourceStringType = StringType>
97
81
static bool convert_encoding_into (SourceStringType &&value, OutputIteratorType out);
98
82
99
- /* *
100
- * Convert the Unicode encoding of a string to another encoding, inserting the result into the
101
- * provided output iterator.
102
- *
103
- * @tparam DesiredStringType The type of string to convert to.
104
- * @tparam OutputIteratorType The type of the output iterator to insert the result into.
105
- * @tparam SourceStringType The type of string to convert.
106
- *
107
- * @param value The encoded Unicode string to convert.
108
- * @param out The output iterator to insert the result into.
109
- *
110
- * @return Whether the conversion was successful.
111
- */
112
- template <typename DesiredStringType, typename IteratorType, typename OutputIteratorType>
113
- static bool
114
- convert_encoding_into (IteratorType &it, const IteratorType &end, OutputIteratorType out);
115
-
116
83
/* *
117
84
* Decode a single Unicode codepoint, starting at the character pointed to by the provided
118
85
* iterator. If successful, after invoking this method, that iterator will point at the first
@@ -427,21 +394,13 @@ template <typename StringType>
427
394
template <typename DesiredStringType, typename SourceStringType>
428
395
inline std::optional<DesiredStringType>
429
396
BasicStringUnicode<StringType>::convert_encoding(SourceStringType &&value)
430
- {
431
- auto it = value.cbegin ();
432
- return convert_encoding<DesiredStringType>(it, value.cend ());
433
- }
434
-
435
- // ==================================================================================================
436
- template <typename StringType>
437
- template <typename DesiredStringType, typename IteratorType>
438
- std::optional<DesiredStringType>
439
- BasicStringUnicode<StringType>::convert_encoding(IteratorType &it, const IteratorType &end)
440
397
{
441
398
DesiredStringType result;
442
- result.reserve (static_cast <typename StringType::size_type>(std::distance (it, end )));
399
+ result.reserve (static_cast <typename StringType::size_type>(value. size ( )));
443
400
444
- if (convert_encoding_into<DesiredStringType>(it, end, std::back_inserter (result)))
401
+ if (convert_encoding_into<DesiredStringType>(
402
+ std::forward<SourceStringType>(value),
403
+ std::back_inserter (result)))
445
404
{
446
405
return result;
447
406
}
@@ -455,21 +414,12 @@ template <typename DesiredStringType, typename OutputIteratorType, typename Sour
455
414
bool BasicStringUnicode<StringType>::convert_encoding_into(
456
415
SourceStringType &&value,
457
416
OutputIteratorType out)
458
- {
459
- auto it = value.cbegin ();
460
- return convert_encoding_into<DesiredStringType>(it, value.cend (), out);
461
- }
462
-
463
- // ==================================================================================================
464
- template <typename StringType>
465
- template <typename DesiredStringType, typename IteratorType, typename OutputIteratorType>
466
- bool BasicStringUnicode<StringType>::convert_encoding_into(
467
- IteratorType &it,
468
- const IteratorType &end,
469
- OutputIteratorType out)
470
417
{
471
418
using DesiredUnicodeType = BasicStringUnicode<DesiredStringType>;
472
419
420
+ auto it = value.cbegin ();
421
+ const auto end = value.cend ();
422
+
473
423
while (it != end)
474
424
{
475
425
if (auto codepoint = decode_codepoint (it, end); codepoint)
0 commit comments