mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-23 13:50:11 +00:00
[NFC][libc++][format] Switches to from_range constructor.
Some places in the format library were identified to benefit from basic_string's from_range constructor. At that time that constructor was not implemented. It's implemented now so adjust the code to use this new constructor. Reviewed By: #libc, var-const Differential Revision: https://reviews.llvm.org/D156022
This commit is contained in:
parent
4f46a48aaf
commit
7b580d8b40
@ -24,6 +24,7 @@
|
||||
#include <__iterator/back_insert_iterator.h>
|
||||
#include <__ranges/concepts.h>
|
||||
#include <__ranges/data.h>
|
||||
#include <__ranges/from_range.h>
|
||||
#include <__ranges/size.h>
|
||||
#include <__type_traits/conditional.h>
|
||||
#include <__type_traits/remove_cvref.h>
|
||||
@ -197,15 +198,8 @@ public:
|
||||
// specialization is the "basic" string formatter in libc++.
|
||||
if constexpr (ranges::contiguous_range<_Rp> && std::ranges::sized_range<_Rp>)
|
||||
return __underlying_.format(basic_string_view<_CharT>{ranges::data(__range), ranges::size(__range)}, __ctx);
|
||||
else {
|
||||
// P2106's from_range has not been implemented yet. Instead use a simple
|
||||
// copy operation.
|
||||
// TODO FMT use basic_string's "from_range" constructor.
|
||||
// return __underlying_.format(basic_string<_CharT>{from_range, __range}, __ctx);
|
||||
basic_string<_CharT> __str;
|
||||
std::ranges::copy(__range, back_insert_iterator{__str});
|
||||
return __underlying_.format(static_cast<basic_string_view<_CharT>>(__str), __ctx);
|
||||
}
|
||||
else
|
||||
return __underlying_.format(basic_string<_CharT>{from_range, __range}, __ctx);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <__iterator/back_insert_iterator.h>
|
||||
#include <__ranges/concepts.h>
|
||||
#include <__ranges/data.h>
|
||||
#include <__ranges/from_range.h>
|
||||
#include <__ranges/size.h>
|
||||
#include <__type_traits/remove_cvref.h>
|
||||
#include <string_view>
|
||||
@ -184,13 +185,7 @@ struct _LIBCPP_TEMPLATE_VIS range_formatter {
|
||||
std::formatter<basic_string<_CharT>, _CharT> __formatter;
|
||||
if (__debug_format)
|
||||
__formatter.set_debug_format();
|
||||
// P2106's from_range has not been implemented yet. Instead use a simple
|
||||
// copy operation.
|
||||
// TODO FMT use basic_string's "from_range" constructor.
|
||||
// return std::formatter<basic_string<_CharT>, _CharT>{}.format(basic_string<_CharT>{from_range, __range}, __ctx);
|
||||
basic_string<_CharT> __str;
|
||||
ranges::copy(__range, back_insert_iterator{__str});
|
||||
return __formatter.format(__str, __ctx);
|
||||
return __formatter.format(basic_string<_CharT>{from_range, __range}, __ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user