diff options
author | Andrey Khalyavin <halyavin@gmail.com> | 2022-04-30 01:06:30 +0300 |
---|---|---|
committer | Andrey Khalyavin <halyavin@gmail.com> | 2022-04-30 01:06:30 +0300 |
commit | 53508f15464dfda8cefda38389d55e18d55958cc (patch) | |
tree | e2a3fee5d27a1ca195d63924be57e69d933f4cdd /contrib/libs/cxxsupp/libcxx/include/__format/formatter.h | |
parent | 84d0f48167dad0467bd26e32b0d876f0b49d62d8 (diff) | |
download | ydb-53508f15464dfda8cefda38389d55e18d55958cc.tar.gz |
Update libc++ to 4684857a (25 Jan 2022).
Notable changes:
* enable constexpr in std::common_iterator
* add std::basic_format_arg::handle
* disable formatter constructors in default template to make errors compile-time rather than runtime-time
* implement pointer formatter
* implement floating pointer formatter
ref:05aacf96e1ad5fc10a5fdd0238b020bbfda51953
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__format/formatter.h')
-rw-r--r-- | contrib/libs/cxxsupp/libcxx/include/__format/formatter.h | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter.h index 1adce75a86..38b73bba32 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter.h @@ -38,26 +38,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD // to support compilers with partial C++20 support. #if !defined(_LIBCPP_HAS_NO_CONCEPTS) -// Currently not implemented specializations throw an exception when used. This -// does not conform to the Standard. However not all Standard defined formatters -// have been implemented yet. Until that time the current behavior is intended. -// TODO FMT Disable the default template. +/// The default formatter template. +/// +/// [format.formatter.spec]/5 +/// If F is a disabled specialization of formatter, these values are false: +/// - is_default_constructible_v<F>, +/// - is_copy_constructible_v<F>, +/// - is_move_constructible_v<F>, +/// - is_copy_assignable<F>, and +/// - is_move_assignable<F>. template <class _Tp, class _CharT> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter { - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - __throw(); - } - - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI auto format(_Tp, auto& __ctx) - -> decltype(__ctx.out()) { - __throw(); - } - -private: - _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw() { - __throw_format_error("Argument type not implemented yet"); - } + formatter() = delete; + formatter(const formatter&) = delete; + formatter& operator=(const formatter&) = delete; }; namespace __format_spec { @@ -193,6 +187,34 @@ __write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first, /** * @overload * + * Writes additional zero's for the precision before the exponent. + * This is used when the precision requested in the format string is larger + * than the maximum precision of the floating-point type. These precision + * digits are always 0. + * + * @param __exponent The location of the exponent character. + * @param __num_trailing_zeros The number of 0's to write before the exponent + * character. + */ +template <class _CharT, class _Fill> +_LIBCPP_HIDE_FROM_ABI auto __write(output_iterator<const _CharT&> auto __out_it, const _CharT* __first, + const _CharT* __last, size_t __size, size_t __width, _Fill __fill, + __format_spec::_Flags::_Alignment __alignment, const _CharT* __exponent, + size_t __num_trailing_zeros) -> decltype(__out_it) { + _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); + _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used"); + + __padding_size_result __padding = __padding_size(__size + __num_trailing_zeros, __width, __alignment); + __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill); + __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it)); + __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0')); + __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it)); + return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill); +} + +/** + * @overload + * * Uses a transformation operation before writing an element. * * TODO FMT Fill will probably change to support Unicode grapheme cluster. |