10 #include <nlohmann/detail/input/binary_reader.hpp>
11 #include <nlohmann/detail/macro_scope.hpp>
12 #include <nlohmann/detail/output/output_adapters.hpp>
25 template<
typename BasicJsonType,
typename CharType>
28 using string_t =
typename BasicJsonType::string_t;
51 write_bson_object(*j.m_value.object);
57 JSON_THROW(type_error::create(317,
"to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name())));
71 oa->write_character(to_char_type(0xF6));
77 oa->write_character(j.m_value.boolean
79 : to_char_type(0xF4));
85 if (j.m_value.number_integer >= 0)
90 if (j.m_value.number_integer <= 0x17)
92 write_number(
static_cast<std::uint8_t>(j.m_value.number_integer));
94 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
96 oa->write_character(to_char_type(0x18));
97 write_number(
static_cast<std::uint8_t>(j.m_value.number_integer));
99 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
101 oa->write_character(to_char_type(0x19));
102 write_number(
static_cast<std::uint16_t>(j.m_value.number_integer));
104 else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
106 oa->write_character(to_char_type(0x1A));
107 write_number(
static_cast<std::uint32_t>(j.m_value.number_integer));
111 oa->write_character(to_char_type(0x1B));
112 write_number(
static_cast<std::uint64_t>(j.m_value.number_integer));
119 const auto positive_number = -1 - j.m_value.number_integer;
120 if (j.m_value.number_integer >= -24)
122 write_number(
static_cast<std::uint8_t>(0x20 + positive_number));
124 else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
126 oa->write_character(to_char_type(0x38));
127 write_number(
static_cast<std::uint8_t>(positive_number));
129 else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
131 oa->write_character(to_char_type(0x39));
134 else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
136 oa->write_character(to_char_type(0x3A));
141 oa->write_character(to_char_type(0x3B));
150 if (j.m_value.number_unsigned <= 0x17)
152 write_number(
static_cast<std::uint8_t>(j.m_value.number_unsigned));
154 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
156 oa->write_character(to_char_type(0x18));
157 write_number(
static_cast<std::uint8_t>(j.m_value.number_unsigned));
159 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
161 oa->write_character(to_char_type(0x19));
162 write_number(
static_cast<std::uint16_t>(j.m_value.number_unsigned));
164 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
166 oa->write_character(to_char_type(0x1A));
167 write_number(
static_cast<std::uint32_t>(j.m_value.number_unsigned));
171 oa->write_character(to_char_type(0x1B));
172 write_number(
static_cast<std::uint64_t>(j.m_value.number_unsigned));
179 oa->write_character(get_cbor_float_prefix(j.m_value.number_float));
180 write_number(j.m_value.number_float);
187 const auto N = j.m_value.string->size();
192 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
194 oa->write_character(to_char_type(0x78));
197 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
199 oa->write_character(to_char_type(0x79));
202 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
204 oa->write_character(to_char_type(0x7A));
208 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
210 oa->write_character(to_char_type(0x7B));
216 oa->write_characters(
217 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
218 j.m_value.string->size());
225 const auto N = j.m_value.array->size();
230 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
232 oa->write_character(to_char_type(0x98));
235 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
237 oa->write_character(to_char_type(0x99));
240 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
242 oa->write_character(to_char_type(0x9A));
246 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
248 oa->write_character(to_char_type(0x9B));
254 for (
const auto& el : *j.m_value.array)
264 const auto N = j.m_value.object->size();
269 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
271 oa->write_character(to_char_type(0xB8));
274 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
276 oa->write_character(to_char_type(0xB9));
279 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
281 oa->write_character(to_char_type(0xBA));
285 else if (N <= (std::numeric_limits<std::uint64_t>::max)())
287 oa->write_character(to_char_type(0xBB));
293 for (
const auto& el : *j.m_value.object)
315 oa->write_character(to_char_type(0xC0));
321 oa->write_character(j.m_value.boolean
323 : to_char_type(0xC2));
329 if (j.m_value.number_integer >= 0)
334 if (j.m_value.number_unsigned < 128)
337 write_number(
static_cast<std::uint8_t>(j.m_value.number_integer));
339 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
342 oa->write_character(to_char_type(0xCC));
343 write_number(
static_cast<std::uint8_t>(j.m_value.number_integer));
345 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
348 oa->write_character(to_char_type(0xCD));
349 write_number(
static_cast<std::uint16_t>(j.m_value.number_integer));
351 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
354 oa->write_character(to_char_type(0xCE));
355 write_number(
static_cast<std::uint32_t>(j.m_value.number_integer));
357 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
360 oa->write_character(to_char_type(0xCF));
361 write_number(
static_cast<std::uint64_t>(j.m_value.number_integer));
366 if (j.m_value.number_integer >= -32)
369 write_number(
static_cast<std::int8_t>(j.m_value.number_integer));
371 else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() and
372 j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
375 oa->write_character(to_char_type(0xD0));
376 write_number(
static_cast<std::int8_t>(j.m_value.number_integer));
378 else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() and
379 j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
382 oa->write_character(to_char_type(0xD1));
383 write_number(
static_cast<std::int16_t>(j.m_value.number_integer));
385 else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() and
386 j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
389 oa->write_character(to_char_type(0xD2));
390 write_number(
static_cast<std::int32_t>(j.m_value.number_integer));
392 else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() and
393 j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
396 oa->write_character(to_char_type(0xD3));
397 write_number(
static_cast<std::int64_t>(j.m_value.number_integer));
405 if (j.m_value.number_unsigned < 128)
408 write_number(
static_cast<std::uint8_t>(j.m_value.number_integer));
410 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
413 oa->write_character(to_char_type(0xCC));
414 write_number(
static_cast<std::uint8_t>(j.m_value.number_integer));
416 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
419 oa->write_character(to_char_type(0xCD));
420 write_number(
static_cast<std::uint16_t>(j.m_value.number_integer));
422 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
425 oa->write_character(to_char_type(0xCE));
426 write_number(
static_cast<std::uint32_t>(j.m_value.number_integer));
428 else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
431 oa->write_character(to_char_type(0xCF));
432 write_number(
static_cast<std::uint64_t>(j.m_value.number_integer));
439 oa->write_character(get_msgpack_float_prefix(j.m_value.number_float));
440 write_number(j.m_value.number_float);
447 const auto N = j.m_value.string->size();
453 else if (N <= (std::numeric_limits<std::uint8_t>::max)())
456 oa->write_character(to_char_type(0xD9));
459 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
462 oa->write_character(to_char_type(0xDA));
465 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
468 oa->write_character(to_char_type(0xDB));
473 oa->write_characters(
474 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
475 j.m_value.string->size());
482 const auto N = j.m_value.array->size();
488 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
491 oa->write_character(to_char_type(0xDC));
494 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
497 oa->write_character(to_char_type(0xDD));
502 for (
const auto& el : *j.m_value.array)
512 const auto N = j.m_value.object->size();
516 write_number(
static_cast<std::uint8_t>(0x80 | (N & 0xF)));
518 else if (N <= (std::numeric_limits<std::uint16_t>::max)())
521 oa->write_character(to_char_type(0xDE));
524 else if (N <= (std::numeric_limits<std::uint32_t>::max)())
527 oa->write_character(to_char_type(0xDF));
532 for (
const auto& el : *j.m_value.object)
552 const bool use_type,
const bool add_prefix =
true)
560 oa->write_character(to_char_type(
'Z'));
569 oa->write_character(j.m_value.boolean
571 : to_char_type(
'F'));
578 write_number_with_ubjson_prefix(j.m_value.number_integer, add_prefix);
584 write_number_with_ubjson_prefix(j.m_value.number_unsigned, add_prefix);
590 write_number_with_ubjson_prefix(j.m_value.number_float, add_prefix);
598 oa->write_character(to_char_type(
'S'));
600 write_number_with_ubjson_prefix(j.m_value.string->size(),
true);
601 oa->write_characters(
602 reinterpret_cast<const CharType*
>(j.m_value.string->c_str()),
603 j.m_value.string->size());
611 oa->write_character(to_char_type(
'['));
614 bool prefix_required =
true;
615 if (use_type and not j.m_value.array->empty())
618 const CharType first_prefix = ubjson_prefix(j.front());
619 const bool same_prefix = std::all_of(j.begin() + 1, j.end(),
620 [
this, first_prefix](
const BasicJsonType & v)
622 return ubjson_prefix(v) == first_prefix;
627 prefix_required =
false;
628 oa->write_character(to_char_type(
'$'));
629 oa->write_character(first_prefix);
635 oa->write_character(to_char_type(
'#'));
636 write_number_with_ubjson_prefix(j.m_value.array->size(),
true);
639 for (
const auto& el : *j.m_value.array)
646 oa->write_character(to_char_type(
']'));
656 oa->write_character(to_char_type(
'{'));
659 bool prefix_required =
true;
660 if (use_type and not j.m_value.object->empty())
663 const CharType first_prefix = ubjson_prefix(j.front());
664 const bool same_prefix = std::all_of(j.begin(), j.end(),
665 [
this, first_prefix](
const BasicJsonType & v)
667 return ubjson_prefix(v) == first_prefix;
672 prefix_required =
false;
673 oa->write_character(to_char_type(
'$'));
674 oa->write_character(first_prefix);
680 oa->write_character(to_char_type(
'#'));
681 write_number_with_ubjson_prefix(j.m_value.object->size(),
true);
684 for (
const auto& el : *j.m_value.object)
686 write_number_with_ubjson_prefix(el.first.size(),
true);
687 oa->write_characters(
688 reinterpret_cast<const CharType*
>(el.first.c_str()),
690 write_ubjson(el.second, use_count, use_type, prefix_required);
695 oa->write_character(to_char_type(
'}'));
715 static std::size_t calc_bson_entry_header_size(
const string_t& name)
717 const auto it = name.find(
static_cast<typename string_t::value_type
>(0));
718 if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos))
720 JSON_THROW(out_of_range::create(409,
721 "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) +
")"));
724 return 1ul + name.size() + 1u;
730 void write_bson_entry_header(
const string_t& name,
733 oa->write_character(to_char_type(element_type));
734 oa->write_characters(
735 reinterpret_cast<const CharType*
>(name.c_str()),
742 void write_bson_boolean(
const string_t& name,
745 write_bson_entry_header(name, 0x08);
746 oa->write_character(value ? to_char_type(0x01) : to_char_type(0x00));
752 void write_bson_double(
const string_t& name,
755 write_bson_entry_header(name, 0x01);
756 write_number<double, true>(value);
762 static std::size_t calc_bson_string_size(
const string_t& value)
770 void write_bson_string(
const string_t& name,
771 const string_t& value)
773 write_bson_entry_header(name, 0x02);
775 write_number<std::int32_t, true>(
static_cast<std::int32_t>(value.size() + 1ul));
776 oa->write_characters(
777 reinterpret_cast<const CharType*
>(value.c_str()),
784 void write_bson_null(
const string_t& name)
786 write_bson_entry_header(name, 0x0A);
792 static std::size_t calc_bson_integer_size(
const std::int64_t value)
794 return (std::numeric_limits<std::int32_t>::min)() <= value and value <= (std::numeric_limits<std::int32_t>::max)()
802 void write_bson_integer(
const string_t& name,
805 if ((std::numeric_limits<std::int32_t>::min)() <= value and value <= (std::numeric_limits<std::int32_t>::max)())
807 write_bson_entry_header(name, 0x10);
808 write_number<std::int32_t, true>(
static_cast<std::int32_t>(value));
812 write_bson_entry_header(name, 0x12);
813 write_number<std::int64_t, true>(
static_cast<std::int64_t>(value));
820 static constexpr std::size_t calc_bson_unsigned_size(
const std::uint64_t value) noexcept
822 return (value <=
static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
830 void write_bson_unsigned(
const string_t& name,
833 if (value <=
static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
835 write_bson_entry_header(name, 0x10 );
836 write_number<std::int32_t, true>(
static_cast<std::int32_t>(value));
838 else if (value <=
static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
840 write_bson_entry_header(name, 0x12 );
841 write_number<std::int64_t, true>(
static_cast<std::int64_t>(value));
845 JSON_THROW(out_of_range::create(407,
"integer number " + std::to_string(value) +
" cannot be represented by BSON as it does not fit int64"));
852 void write_bson_object_entry(
const string_t& name,
853 const typename BasicJsonType::object_t& value)
855 write_bson_entry_header(name, 0x03);
856 write_bson_object(value);
862 static std::size_t calc_bson_array_size(
const typename BasicJsonType::array_t& value)
864 std::size_t array_index = 0ul;
866 const std::size_t embedded_document_size = std::accumulate(std::begin(value), std::end(value), 0ul, [&array_index](std::size_t result,
const typename BasicJsonType::array_t::value_type & el)
868 return result + calc_bson_element_size(std::to_string(array_index++), el);
871 return sizeof(
std::int32_t) + embedded_document_size + 1ul;
877 void write_bson_array(
const string_t& name,
878 const typename BasicJsonType::array_t& value)
880 write_bson_entry_header(name, 0x04);
881 write_number<std::int32_t, true>(
static_cast<std::int32_t>(calc_bson_array_size(value)));
883 std::size_t array_index = 0ul;
885 for (
const auto& el : value)
887 write_bson_element(std::to_string(array_index++), el);
890 oa->write_character(to_char_type(0x00));
897 static std::size_t calc_bson_element_size(
const string_t& name,
898 const BasicJsonType& j)
900 const auto header_size = calc_bson_entry_header_size(name);
904 return header_size + calc_bson_object_size(*j.m_value.object);
907 return header_size + calc_bson_array_size(*j.m_value.array);
910 return header_size + 1ul;
913 return header_size + 8ul;
916 return header_size + calc_bson_integer_size(j.m_value.number_integer);
919 return header_size + calc_bson_unsigned_size(j.m_value.number_unsigned);
922 return header_size + calc_bson_string_size(*j.m_value.string);
925 return header_size + 0ul;
942 void write_bson_element(
const string_t& name,
943 const BasicJsonType& j)
948 return write_bson_object_entry(name, *j.m_value.object);
951 return write_bson_array(name, *j.m_value.array);
954 return write_bson_boolean(name, j.m_value.boolean);
957 return write_bson_double(name, j.m_value.number_float);
960 return write_bson_integer(name, j.m_value.number_integer);
963 return write_bson_unsigned(name, j.m_value.number_unsigned);
966 return write_bson_string(name, *j.m_value.string);
969 return write_bson_null(name);
985 static std::size_t calc_bson_object_size(
const typename BasicJsonType::object_t& value)
987 std::size_t document_size = std::accumulate(value.begin(), value.end(), 0ul,
988 [](
size_t result,
const typename BasicJsonType::object_t::value_type & el)
990 return result += calc_bson_element_size(el.first, el.second);
1000 void write_bson_object(
const typename BasicJsonType::object_t& value)
1002 write_number<std::int32_t, true>(
static_cast<std::int32_t>(calc_bson_object_size(value)));
1004 for (
const auto& el : value)
1006 write_bson_element(el.first, el.second);
1009 oa->write_character(to_char_type(0x00));
1016 static constexpr CharType get_cbor_float_prefix(
float )
1018 return to_char_type(0xFA);
1021 static constexpr CharType get_cbor_float_prefix(
double )
1023 return to_char_type(0xFB);
1030 static constexpr CharType get_msgpack_float_prefix(
float )
1032 return to_char_type(0xCA);
1035 static constexpr CharType get_msgpack_float_prefix(
double )
1037 return to_char_type(0xCB);
1045 template<
typename NumberType,
typename std::enable_if<
1046 std::is_floating_point<NumberType>::value,
int>::type = 0>
1047 void write_number_with_ubjson_prefix(
const NumberType n,
1048 const bool add_prefix)
1052 oa->write_character(get_ubjson_float_prefix(n));
1058 template<
typename NumberType,
typename std::enable_if<
1059 std::is_unsigned<NumberType>::value,
int>::type = 0>
1060 void write_number_with_ubjson_prefix(
const NumberType n,
1061 const bool add_prefix)
1063 if (n <=
static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
1067 oa->write_character(to_char_type(
'i'));
1071 else if (n <= (std::numeric_limits<std::uint8_t>::max)())
1075 oa->write_character(to_char_type(
'U'));
1079 else if (n <=
static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
1083 oa->write_character(to_char_type(
'I'));
1087 else if (n <=
static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
1091 oa->write_character(to_char_type(
'l'));
1095 else if (n <=
static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
1099 oa->write_character(to_char_type(
'L'));
1105 JSON_THROW(out_of_range::create(407,
"integer number " + std::to_string(n) +
" cannot be represented by UBJSON as it does not fit int64"));
1110 template<
typename NumberType,
typename std::enable_if<
1111 std::is_signed<NumberType>::value and
1112 not std::is_floating_point<NumberType>::value,
int>::type = 0>
1113 void write_number_with_ubjson_prefix(
const NumberType n,
1114 const bool add_prefix)
1116 if ((std::numeric_limits<std::int8_t>::min)() <= n and n <= (std::numeric_limits<std::int8_t>::max)())
1120 oa->write_character(to_char_type(
'i'));
1124 else if (
static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n and n <=
static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
1128 oa->write_character(to_char_type(
'U'));
1132 else if ((std::numeric_limits<std::int16_t>::min)() <= n and n <= (std::numeric_limits<std::int16_t>::max)())
1136 oa->write_character(to_char_type(
'I'));
1140 else if ((std::numeric_limits<std::int32_t>::min)() <= n and n <= (std::numeric_limits<std::int32_t>::max)())
1144 oa->write_character(to_char_type(
'l'));
1148 else if ((std::numeric_limits<std::int64_t>::min)() <= n and n <= (std::numeric_limits<std::int64_t>::max)())
1152 oa->write_character(to_char_type(
'L'));
1159 JSON_THROW(out_of_range::create(407,
"integer number " + std::to_string(n) +
" cannot be represented by UBJSON as it does not fit int64"));
1173 CharType ubjson_prefix(
const BasicJsonType& j)
const noexcept
1181 return j.m_value.boolean ?
'T' :
'F';
1185 if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
1189 if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
1193 if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
1197 if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
1207 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
1211 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::uint8_t>::max)()))
1215 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
1219 if (j.m_value.number_unsigned <=
static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
1228 return get_ubjson_float_prefix(j.m_value.number_float);
1244 static constexpr CharType get_ubjson_float_prefix(
float )
1249 static constexpr CharType get_ubjson_float_prefix(
double )
1269 template<
typename NumberType,
bool OutputIsLittleEndian = false>
1270 void write_number(
const NumberType n)
1273 std::array<CharType,
sizeof(NumberType)> vec;
1274 std::memcpy(vec.data(), &n,
sizeof(NumberType));
1277 if (is_little_endian != OutputIsLittleEndian)
1280 std::reverse(vec.begin(), vec.end());
1283 oa->write_characters(vec.data(),
sizeof(NumberType));
1291 template <
typename C = CharType,
1292 enable_if_t < std::is_signed<C>::value and std::is_signed<char>::value > * =
nullptr >
1293 static constexpr CharType to_char_type(
std::uint8_t x) noexcept
1295 return *
reinterpret_cast<char*
>(&x);
1298 template <
typename C = CharType,
1299 enable_if_t < std::is_signed<C>::value and std::is_unsigned<char>::value > * =
nullptr >
1302 static_assert(
sizeof(
std::uint8_t) ==
sizeof(CharType),
"size of CharType must be equal to std::uint8_t");
1303 static_assert(std::is_pod<CharType>::value,
"CharType must be POD");
1305 std::memcpy(&result, &x,
sizeof(x));
1309 template<
typename C = CharType,
1310 enable_if_t<std::is_unsigned<C>::value>* =
nullptr>
1311 static constexpr CharType to_char_type(
std::uint8_t x) noexcept
1316 template <
typename InputCharType,
typename C = CharType,
1318 std::is_signed<C>::value and
1319 std::is_signed<char>::value and
1320 std::is_same<char, typename std::remove_cv<InputCharType>::type>::value
1322 static constexpr CharType to_char_type(InputCharType x) noexcept
1332 output_adapter_t<CharType> oa =
nullptr;