aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/std
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/std')
-rw-r--r--libstdc++-v3/include/std/flat_set20
-rw-r--r--libstdc++-v3/include/std/format36
-rw-r--r--libstdc++-v3/include/std/tuple2
-rw-r--r--libstdc++-v3/include/std/vector32
4 files changed, 69 insertions, 21 deletions
diff --git a/libstdc++-v3/include/std/flat_set b/libstdc++-v3/include/std/flat_set
index a7b0b8a..3e15d1a 100644
--- a/libstdc++-v3/include/std/flat_set
+++ b/libstdc++-v3/include/std/flat_set
@@ -350,12 +350,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_cont.max_size(); }
// modifiers
- template<typename... _Args>
+ template<typename _Arg, typename... _Args>
pair<iterator, bool>
- _M_try_emplace(optional<const_iterator> __hint, _Args&&... __args)
+ _M_try_emplace(optional<const_iterator> __hint, _Arg&& __arg, _Args&&... __args)
{
// TODO: Simplify and audit the hint handling.
- value_type __k(std::forward<_Args>(__args)...);
+ auto&& __k = [&] -> decltype(auto) {
+ if constexpr (sizeof...(_Args) == 0
+ && same_as<remove_cvref_t<_Arg>, value_type>)
+ return std::forward<_Arg>(__arg);
+ else
+ return value_type(std::forward<_Arg>(__arg),
+ std::forward<_Args>(__args)...);
+ }();
typename container_type::iterator __it;
int __r = -1, __s = -1;
if (__hint.has_value()
@@ -397,12 +404,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return {__it, false};
auto __guard = _M_make_clear_guard();
- __it = _M_cont.insert(__it, std::move(__k));
+ __it = _M_cont.insert(__it, std::forward<decltype(__k)>(__k));
__guard._M_disable();
return {__it, true};
}
template<typename... _Args>
+ pair<iterator, bool>
+ _M_try_emplace(optional<const_iterator> __hint)
+ { return _M_try_emplace(__hint, value_type()); }
+
+ template<typename... _Args>
requires is_constructible_v<value_type, _Args...>
__emplace_result_t
emplace(_Args&&... __args)
diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index c3327e1..2e9319c 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -52,6 +52,7 @@
#include <string_view>
#include <string>
#include <bits/monostate.h>
+#include <bits/formatfwd.h>
#include <bits/ranges_base.h> // input_range, range_reference_t
#include <bits/ranges_util.h> // subrange
#include <bits/ranges_algobase.h> // ranges::copy
@@ -73,9 +74,6 @@ namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
- // [format.context], class template basic_format_context
- template<typename _Out, typename _CharT> class basic_format_context;
-
// [format.fmt.string], class template basic_format_string
template<typename _CharT, typename... _Args> struct basic_format_string;
@@ -178,7 +176,7 @@ namespace __format
// [format.formatter], formatter
/// The primary template of std::formatter is disabled.
- template<typename _Tp, typename _CharT = char>
+ template<typename _Tp, typename _CharT>
struct formatter
{
formatter() = delete; // No std::formatter specialization for this type.
@@ -923,14 +921,6 @@ namespace __format
bool _M_hasval = false;
};
-#ifdef _GLIBCXX_USE_WCHAR_T
- template<typename _CharT>
- concept __char = same_as<_CharT, char> || same_as<_CharT, wchar_t>;
-#else
- template<typename _CharT>
- concept __char = same_as<_CharT, char>;
-#endif
-
template<__char _CharT>
struct __formatter_str
{
@@ -1277,12 +1267,26 @@ namespace __format
_M_spec);
}
+ [[__gnu__::__always_inline__]]
+ static size_t
+ _S_character_width(_CharT __c)
+ {
+ // N.B. single byte cannot encode charcter of width greater than 1
+ if constexpr (sizeof(_CharT) > 1u &&
+ __unicode::__literal_encoding_is_unicode<_CharT>())
+ return __unicode::__field_width(__c);
+ else
+ return 1u;
+ }
+
template<typename _Out>
typename basic_format_context<_Out, _CharT>::iterator
_M_format_character(_CharT __c,
basic_format_context<_Out, _CharT>& __fc) const
{
- return __format::__write_padded_as_spec({&__c, 1u}, 1, __fc, _M_spec);
+ return __format::__write_padded_as_spec({&__c, 1u},
+ _S_character_width(__c),
+ __fc, _M_spec);
}
template<typename _Int>
@@ -1834,9 +1838,9 @@ namespace __format
if (_M_spec._M_localized && __builtin_isfinite(__v))
{
- __wstr = _M_localize(__str, __expc, __fc.locale());
- if (!__wstr.empty())
- __str = __wstr;
+ auto __s = _M_localize(__str, __expc, __fc.locale());
+ if (!__s.empty())
+ __str = __wstr = std::move(__s);
}
size_t __width = _M_spec._M_get_width(__fc);
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index d3deb7b..2e69af1 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -2534,7 +2534,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
return [&]<size_t... _Inds>(index_sequence<_Inds...>) {
// Fold == over the tuples until non-equal elements are found.
- return ((std::get<_Inds>(__t) == std::get<_Inds>(__u)) && ...);
+ return (bool(std::get<_Inds>(__t) == std::get<_Inds>(__u)) && ...);
}(index_sequence_for<_Tps...>{});
}
diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector
index 0f04334..8bb2543 100644
--- a/libstdc++-v3/include/std/vector
+++ b/libstdc++-v3/include/std/vector
@@ -157,4 +157,36 @@ _GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // __cpp_lib_erase_if
+#ifdef __glibcxx_format_ranges // C++ >= 20 && HOSTED
+#include <bits/formatfwd.h>
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+ // Standard does not constrain accepted _CharT and declares it as formatter
+ // of Tp that statisfies is-vector-bool-reference<T>,
+ template<__format::__char _CharT>
+ struct formatter<_GLIBCXX_STD_C::_Bit_reference, _CharT>
+ {
+ // Standard declares this as template accepting unconstrained
+ // ParseContext type.
+ constexpr typename basic_format_parse_context<_CharT>::iterator
+ parse(basic_format_parse_context<_CharT>& __pc)
+ { return _M_f.template _M_parse<bool>(__pc); }
+
+ // Standard declares this as template accepting unconstrained
+ // FormatContext type.
+ template<typename _Out>
+ typename basic_format_context<_Out, _CharT>::iterator
+ format(const _GLIBCXX_STD_C::_Bit_reference& __u,
+ basic_format_context<_Out, _CharT>& __fc) const
+ { return _M_f.format(static_cast<bool>(__u), __fc); }
+
+ private:
+ __format::__formatter_int<_CharT> _M_f;
+ };
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace std
+#endif // __glibcxx_format_ranges
+
#endif /* _GLIBCXX_VECTOR */