[libcxx-commits] [libcxx] [libc++][modules] Guard carved-out headers more consistently (PR #108637)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 13 12:53:34 PDT 2024
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/108637
Several headers that should not be provided when localization or threads are disabled were not guarded. That works until one tries to build with modules and these headers get pulled in.
Note that this could be cleaned up further into something more systematic, but this patch solves the immediate problems I ran into with the monolithic modulemap and doesn't create any new inconsistency that wasn't already there.
>From 56f5a3df6b5682bffb45ee7046458de59045139e Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 13 Sep 2024 12:50:35 -0400
Subject: [PATCH] [libc++] Guard carved-out headers more consistently
Several headers that should not be provided when localization or
threads are disabled were not guarded. That works until one tries
to build with modules and these headers get pulled in.
Note that this could be cleaned up further into something more
systematic, but this patch solves the immediate problems I ran
into with the monolithic modulemap and doesn't create any new
inconsistency that wasn't already there.
---
libcxx/include/__chrono/formatter.h | 168 ++++++------
libcxx/include/__chrono/ostream.h | 74 +++---
.../include/__chrono/parser_std_format_spec.h | 27 +-
libcxx/include/__ostream/basic_ostream.h | 247 +++++++++---------
libcxx/include/__ostream/print.h | 79 +++---
libcxx/include/__thread/jthread.h | 4 +-
libcxx/include/__thread/this_thread.h | 4 +
libcxx/include/__thread/thread.h | 20 +-
libcxx/include/fstream | 4 +-
libcxx/include/iomanip | 51 ++--
libcxx/include/istream | 235 +++++++++--------
libcxx/include/ostream | 20 +-
libcxx/include/sstream | 175 +++++++------
libcxx/include/streambuf | 37 +--
libcxx/include/syncstream | 89 ++++---
15 files changed, 644 insertions(+), 590 deletions(-)
diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h
index 449c415e957602..ff2593f7230292 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -10,55 +10,58 @@
#ifndef _LIBCPP___CHRONO_FORMATTER_H
#define _LIBCPP___CHRONO_FORMATTER_H
-#include <__algorithm/ranges_copy.h>
-#include <__chrono/calendar.h>
-#include <__chrono/concepts.h>
-#include <__chrono/convert_to_tm.h>
-#include <__chrono/day.h>
-#include <__chrono/duration.h>
-#include <__chrono/file_clock.h>
-#include <__chrono/hh_mm_ss.h>
-#include <__chrono/local_info.h>
-#include <__chrono/month.h>
-#include <__chrono/month_weekday.h>
-#include <__chrono/monthday.h>
-#include <__chrono/ostream.h>
-#include <__chrono/parser_std_format_spec.h>
-#include <__chrono/statically_widen.h>
-#include <__chrono/sys_info.h>
-#include <__chrono/system_clock.h>
-#include <__chrono/time_point.h>
-#include <__chrono/weekday.h>
-#include <__chrono/year.h>
-#include <__chrono/year_month.h>
-#include <__chrono/year_month_day.h>
-#include <__chrono/year_month_weekday.h>
-#include <__chrono/zoned_time.h>
-#include <__concepts/arithmetic.h>
-#include <__concepts/same_as.h>
#include <__config>
-#include <__format/concepts.h>
-#include <__format/format_error.h>
-#include <__format/format_functions.h>
-#include <__format/format_parse_context.h>
-#include <__format/formatter.h>
-#include <__format/parser_std_format_spec.h>
-#include <__format/write_escaped.h>
-#include <__memory/addressof.h>
-#include <__type_traits/is_specialization.h>
-#include <cmath>
-#include <ctime>
-#include <limits>
-#include <sstream>
-#include <string_view>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+# include <__algorithm/ranges_copy.h>
+# include <__chrono/calendar.h>
+# include <__chrono/concepts.h>
+# include <__chrono/convert_to_tm.h>
+# include <__chrono/day.h>
+# include <__chrono/duration.h>
+# include <__chrono/file_clock.h>
+# include <__chrono/hh_mm_ss.h>
+# include <__chrono/local_info.h>
+# include <__chrono/month.h>
+# include <__chrono/month_weekday.h>
+# include <__chrono/monthday.h>
+# include <__chrono/ostream.h>
+# include <__chrono/parser_std_format_spec.h>
+# include <__chrono/statically_widen.h>
+# include <__chrono/sys_info.h>
+# include <__chrono/system_clock.h>
+# include <__chrono/time_point.h>
+# include <__chrono/weekday.h>
+# include <__chrono/year.h>
+# include <__chrono/year_month.h>
+# include <__chrono/year_month_day.h>
+# include <__chrono/year_month_weekday.h>
+# include <__chrono/zoned_time.h>
+# include <__concepts/arithmetic.h>
+# include <__concepts/same_as.h>
+# include <__format/concepts.h>
+# include <__format/format_error.h>
+# include <__format/format_functions.h>
+# include <__format/format_parse_context.h>
+# include <__format/formatter.h>
+# include <__format/parser_std_format_spec.h>
+# include <__format/write_escaped.h>
+# include <__memory/addressof.h>
+# include <__type_traits/is_specialization.h>
+# include <cmath>
+# include <ctime>
+# include <limits>
+# include <sstream>
+# include <string_view>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
namespace __formatter {
@@ -139,24 +142,24 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<
__value.fractional_width);
}
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
- !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
+ !defined(_LIBCPP_HAS_NO_FILESYSTEM)
template <class _CharT, class _Duration, class _TimeZonePtr>
_LIBCPP_HIDE_FROM_ABI void
__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) {
__formatter::__format_sub_seconds(__sstr, __value.get_local_time().time_since_epoch());
}
-# endif
+# endif
template <class _Tp>
consteval bool __use_fraction() {
if constexpr (__is_time_point<_Tp>)
return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
- !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
+ !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
-# endif
+# endif
else if constexpr (chrono::__is_duration<_Tp>::value)
return chrono::hh_mm_ss<_Tp>::fractional_width;
else if constexpr (__is_hh_mm_ss<_Tp>)
@@ -225,16 +228,15 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
template <class _Tp>
_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const _Tp& __value) {
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
if constexpr (same_as<_Tp, chrono::sys_info>)
return {__value.abbrev, __value.offset};
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return __formatter::__convert_to_time_zone(__value.get_info());
-# endif
+# endif
else
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
return {"UTC", chrono::seconds{0}};
}
@@ -341,12 +343,12 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
//
// TODO FMT evaluate the comment above.
-# if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
+# if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
case _CharT('y'):
// Glibc fails for negative values, AIX for positive values too.
__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), (std::abs(__t.tm_year + 1900)) % 100);
break;
-# endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
+# endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
case _CharT('Y'):
// Depending on the platform's libc the range of supported years is
@@ -442,17 +444,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {
return __value.weekday().ok();
else if constexpr (__is_hh_mm_ss<_Tp>)
return true;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else if constexpr (same_as<_Tp, chrono::sys_info>)
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else
static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
@@ -493,17 +494,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {
return __value.weekday().ok();
else if constexpr (__is_hh_mm_ss<_Tp>)
return true;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else if constexpr (same_as<_Tp, chrono::sys_info>)
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else
static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
@@ -544,17 +544,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {
return __value.ok();
else if constexpr (__is_hh_mm_ss<_Tp>)
return true;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else if constexpr (same_as<_Tp, chrono::sys_info>)
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else
static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
@@ -595,17 +594,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {
return __value.month().ok();
else if constexpr (__is_hh_mm_ss<_Tp>)
return true;
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else if constexpr (same_as<_Tp, chrono::sys_info>)
return true;
else if constexpr (same_as<_Tp, chrono::local_info>)
return true;
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
return true;
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
else
static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
}
@@ -943,7 +941,7 @@ struct formatter<chrono::hh_mm_ss<_Duration>, _CharT> : public __formatter_chron
}
};
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
template <__fmt_char_type _CharT>
struct formatter<chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> {
public:
@@ -965,8 +963,7 @@ struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT>
return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{});
}
};
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
// Note due to how libc++'s formatters are implemented there is no need to add
// the exposition only local-time-format-t abstraction.
template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT>
@@ -979,12 +976,13 @@ struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public _
return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
}
};
-# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&
- // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
-#endif // if _LIBCPP_STD_VER >= 20
+# endif // if _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
#endif // _LIBCPP___CHRONO_FORMATTER_H
diff --git a/libcxx/include/__chrono/ostream.h b/libcxx/include/__chrono/ostream.h
index e6c43254eea15e..196ebd518541c7 100644
--- a/libcxx/include/__chrono/ostream.h
+++ b/libcxx/include/__chrono/ostream.h
@@ -10,37 +10,40 @@
#ifndef _LIBCPP___CHRONO_OSTREAM_H
#define _LIBCPP___CHRONO_OSTREAM_H
-#include <__chrono/calendar.h>
-#include <__chrono/day.h>
-#include <__chrono/duration.h>
-#include <__chrono/file_clock.h>
-#include <__chrono/hh_mm_ss.h>
-#include <__chrono/local_info.h>
-#include <__chrono/month.h>
-#include <__chrono/month_weekday.h>
-#include <__chrono/monthday.h>
-#include <__chrono/statically_widen.h>
-#include <__chrono/sys_info.h>
-#include <__chrono/system_clock.h>
-#include <__chrono/weekday.h>
-#include <__chrono/year.h>
-#include <__chrono/year_month.h>
-#include <__chrono/year_month_day.h>
-#include <__chrono/year_month_weekday.h>
-#include <__chrono/zoned_time.h>
-#include <__concepts/same_as.h>
#include <__config>
-#include <__format/format_functions.h>
-#include <__fwd/ostream.h>
-#include <ratio>
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+# include <__chrono/calendar.h>
+# include <__chrono/day.h>
+# include <__chrono/duration.h>
+# include <__chrono/file_clock.h>
+# include <__chrono/hh_mm_ss.h>
+# include <__chrono/local_info.h>
+# include <__chrono/month.h>
+# include <__chrono/month_weekday.h>
+# include <__chrono/monthday.h>
+# include <__chrono/statically_widen.h>
+# include <__chrono/sys_info.h>
+# include <__chrono/system_clock.h>
+# include <__chrono/weekday.h>
+# include <__chrono/year.h>
+# include <__chrono/year_month.h>
+# include <__chrono/year_month_day.h>
+# include <__chrono/year_month_weekday.h>
+# include <__chrono/zoned_time.h>
+# include <__concepts/same_as.h>
+# include <__format/format_functions.h>
+# include <__fwd/ostream.h>
+# include <ratio>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
namespace chrono {
@@ -82,11 +85,11 @@ _LIBCPP_HIDE_FROM_ABI auto __units_suffix() {
else if constexpr (same_as<typename _Period::type, nano>)
return _LIBCPP_STATICALLY_WIDEN(_CharT, "ns");
else if constexpr (same_as<typename _Period::type, micro>)
-# ifndef _LIBCPP_HAS_NO_UNICODE
+# ifndef _LIBCPP_HAS_NO_UNICODE
return _LIBCPP_STATICALLY_WIDEN(_CharT, "\u00b5s");
-# else
+# else
return _LIBCPP_STATICALLY_WIDEN(_CharT, "us");
-# endif
+# endif
else if constexpr (same_as<typename _Period::type, milli>)
return _LIBCPP_STATICALLY_WIDEN(_CharT, "ms");
else if constexpr (same_as<typename _Period::type, centi>)
@@ -265,7 +268,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms
return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms);
}
-# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
@@ -303,20 +306,21 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) {
_LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second);
}
-# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) {
return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T %Z}"), __tp);
}
-# endif
-# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
+# endif
+# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
} // namespace chrono
-#endif // if _LIBCPP_STD_VER >= 20
+# endif // if _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
#endif // _LIBCPP___CHRONO_OSTREAM_H
diff --git a/libcxx/include/__chrono/parser_std_format_spec.h b/libcxx/include/__chrono/parser_std_format_spec.h
index 6803d03ad882fd..c9cfcc6d572f41 100644
--- a/libcxx/include/__chrono/parser_std_format_spec.h
+++ b/libcxx/include/__chrono/parser_std_format_spec.h
@@ -11,20 +11,23 @@
#define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
#include <__config>
-#include <__format/concepts.h>
-#include <__format/format_error.h>
-#include <__format/format_parse_context.h>
-#include <__format/formatter_string.h>
-#include <__format/parser_std_format_spec.h>
-#include <string_view>
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+# include <__format/concepts.h>
+# include <__format/format_error.h>
+# include <__format/format_parse_context.h>
+# include <__format/formatter_string.h>
+# include <__format/parser_std_format_spec.h>
+# include <string_view>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
namespace __format_spec {
@@ -409,8 +412,10 @@ class _LIBCPP_TEMPLATE_VIS __parser_chrono {
} // namespace __format_spec
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
+#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
#endif // _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
diff --git a/libcxx/include/__ostream/basic_ostream.h b/libcxx/include/__ostream/basic_ostream.h
index e0698ccb4842a5..1f7fe8338c5894 100644
--- a/libcxx/include/__ostream/basic_ostream.h
+++ b/libcxx/include/__ostream/basic_ostream.h
@@ -10,29 +10,32 @@
#define _LIBCPP___OSTREAM_BASIC_OSTREAM_H
#include <__config>
-#include <__exception/operations.h>
-#include <__memory/shared_ptr.h>
-#include <__memory/unique_ptr.h>
-#include <__system_error/error_code.h>
-#include <__type_traits/conjunction.h>
-#include <__type_traits/enable_if.h>
-#include <__type_traits/is_base_of.h>
-#include <__type_traits/void_t.h>
-#include <__utility/declval.h>
-#include <bitset>
-#include <cstddef>
-#include <ios>
-#include <locale>
-#include <new> // for __throw_bad_alloc
-#include <streambuf>
-#include <string_view>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+# include <__exception/operations.h>
+# include <__memory/shared_ptr.h>
+# include <__memory/unique_ptr.h>
+# include <__system_error/error_code.h>
+# include <__type_traits/conjunction.h>
+# include <__type_traits/enable_if.h>
+# include <__type_traits/is_base_of.h>
+# include <__type_traits/void_t.h>
+# include <__utility/declval.h>
+# include <bitset>
+# include <cstddef>
+# include <ios>
+# include <locale>
+# include <new> // for __throw_bad_alloc
+# include <streambuf>
+# include <string_view>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
+# include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -99,19 +102,19 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Tra
basic_ostream& operator<<(long double __f);
basic_ostream& operator<<(const void* __p);
-#if _LIBCPP_STD_VER >= 23
+# if _LIBCPP_STD_VER >= 23
_LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) {
return operator<<(const_cast<const void*>(__p));
}
-#endif
+# endif
basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
-#if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 17
// LWG 2221 - nullptr. This is not backported to older standards modes.
// See https://reviews.llvm.org/D127033 for more info on the rationale.
_LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; }
-#endif
+# endif
// 27.7.2.7 Unformatted output:
basic_ostream& put(char_type __c);
@@ -153,15 +156,15 @@ basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& _
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>::sentry::~sentry() {
if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && uncaught_exceptions() == 0) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (__os_.rdbuf()->pubsync() == -1)
__os_.setstate(ios_base::badbit);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
}
@@ -182,15 +185,15 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() {}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
if (__sb) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
_Ip __i(__sb);
@@ -204,27 +207,27 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ
}
if (__c == 0)
this->setstate(ios_base::failbit);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_failbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
} else
this->setstate(ios_base::badbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -232,19 +235,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
@@ -259,19 +262,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short
.failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -279,19 +282,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig
if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
@@ -306,19 +309,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int _
.failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -326,19 +329,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig
if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -346,19 +349,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -366,19 +369,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -386,19 +389,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -406,19 +409,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -426,19 +429,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float
if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -446,19 +449,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(doubl
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -466,19 +469,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -486,20 +489,20 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const
if (__f.put(*this, *this, this->fill(), __n).failed())
this->setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
__put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s) {
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
@@ -513,11 +516,11 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s
.failed())
__os.setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return __os;
}
@@ -528,9 +531,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s) {
_CharT __c = __os.widen(__cn);
@@ -545,11 +548,11 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_
.failed())
__os.setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return __os;
}
@@ -577,9 +580,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) {
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s) {
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
@@ -606,11 +609,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {
.failed())
__os.setstate(ios_base::badbit | ios_base::failbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return __os;
}
@@ -635,9 +638,9 @@ operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) {
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __s(*this);
if (__s) {
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
@@ -646,37 +649,37 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __
if (__o.failed())
this->setstate(ios_base::badbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
sentry __sen(*this);
if (__sen && __n) {
if (this->rdbuf()->sputn(__s, __n) != __n)
this->setstate(ios_base::badbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf()) {
sentry __s(*this);
if (__s) {
@@ -684,11 +687,11 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {
this->setstate(ios_base::badbit);
}
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return *this;
}
@@ -797,9 +800,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) {
std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
}
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
@@ -818,9 +821,9 @@ basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, co
template <class _Traits>
basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
-# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-# ifndef _LIBCPP_HAS_NO_CHAR8_T
+# ifndef _LIBCPP_HAS_NO_CHAR8_T
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
@@ -832,7 +835,7 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch
template <class _Traits>
basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
-# endif
+# endif
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
@@ -846,15 +849,17 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const ch
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
-#endif
+# endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
#endif // _LIBCPP___OSTREAM_BASIC_OSTREAM_H
diff --git a/libcxx/include/__ostream/print.h b/libcxx/include/__ostream/print.h
index 8265ac00777e25..6c82b11e1de96b 100644
--- a/libcxx/include/__ostream/print.h
+++ b/libcxx/include/__ostream/print.h
@@ -10,21 +10,24 @@
#define _LIBCPP___OSTREAM_PRINT_H
#include <__config>
-#include <__fwd/ostream.h>
-#include <__iterator/ostreambuf_iterator.h>
-#include <__ostream/basic_ostream.h>
-#include <format>
-#include <ios>
-#include <locale>
-#include <print>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+# include <__fwd/ostream.h>
+# include <__iterator/ostreambuf_iterator.h>
+# include <__ostream/basic_ostream.h>
+# include <format>
+# include <ios>
+# include <locale>
+# include <print>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 23
+# if _LIBCPP_STD_VER >= 23
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
_LIBCPP_HIDE_FROM_ABI inline void
@@ -49,9 +52,9 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _
const char* __str = __o.data();
size_t __len = __o.size();
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-# endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typedef ostreambuf_iterator<char> _Ip;
if (std::__pad_and_output(
_Ip(__os),
@@ -63,11 +66,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _
.failed())
__os.setstate(ios_base::badbit | ios_base::failbit);
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
-# endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
}
@@ -91,12 +94,12 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view _
// is determined in the same way as the print(FILE*, ...) overloads.
_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os);
-# ifndef _LIBCPP_HAS_NO_UNICODE
+# ifndef _LIBCPP_HAS_NO_UNICODE
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
_LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
-# if _LIBCPP_AVAILABILITY_HAS_PRINT == 0
+# if _LIBCPP_AVAILABILITY_HAS_PRINT == 0
return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
-# else
+# else
FILE* __file = std::__get_ostream_file(__os);
if (!__file || !__print::__is_terminal(__file))
return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
@@ -112,49 +115,49 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo
// This is the path for the native API, start with flushing.
__os.flush();
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-# endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
ostream::sentry __s(__os);
if (__s) {
-# ifndef _LIBCPP_WIN32API
+# ifndef _LIBCPP_WIN32API
__print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true);
-# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
+# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
__print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true);
-# else
-# error "Windows builds with wchar_t disabled are not supported."
-# endif
+# else
+# error "Windows builds with wchar_t disabled are not supported."
+# endif
}
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
-# endif // _LIBCPP_HAS_NO_EXCEPTIONS
-# endif // _LIBCPP_AVAILABILITY_HAS_PRINT
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_AVAILABILITY_HAS_PRINT
}
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
_LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(ostream& __os, string_view __fmt, format_args __args) {
std::__vprint_unicode(__os, __fmt, __args, false);
}
-# endif // _LIBCPP_HAS_NO_UNICODE
+# endif // _LIBCPP_HAS_NO_UNICODE
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI void print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
-# ifndef _LIBCPP_HAS_NO_UNICODE
+# ifndef _LIBCPP_HAS_NO_UNICODE
if constexpr (__print::__use_unicode_execution_charset)
std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false);
else
std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
-# else // _LIBCPP_HAS_NO_UNICODE
+# else // _LIBCPP_HAS_NO_UNICODE
std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
-# endif // _LIBCPP_HAS_NO_UNICODE
+# endif // _LIBCPP_HAS_NO_UNICODE
}
template <class... _Args>
_LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
-# ifndef _LIBCPP_HAS_NO_UNICODE
+# ifndef _LIBCPP_HAS_NO_UNICODE
// Note the wording in the Standard is inefficient. The output of
// std::format is a std::string which is then copied. This solution
// just appends a newline at the end of the output.
@@ -162,9 +165,9 @@ _LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt,
std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true);
else
std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
-# else // _LIBCPP_HAS_NO_UNICODE
+# else // _LIBCPP_HAS_NO_UNICODE
std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
-# endif // _LIBCPP_HAS_NO_UNICODE
+# endif // _LIBCPP_HAS_NO_UNICODE
}
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
@@ -172,8 +175,10 @@ _LIBCPP_HIDE_FROM_ABI inline void println(ostream& __os) {
std::print(__os, "\n");
}
-#endif // _LIBCPP_STD_VER >= 23
+# endif // _LIBCPP_STD_VER >= 23
_LIBCPP_END_NAMESPACE_STD
+#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
#endif // _LIBCPP___OSTREAM_PRINT_H
diff --git a/libcxx/include/__thread/jthread.h b/libcxx/include/__thread/jthread.h
index d85ad3b9061b82..8fac72fff1689b 100644
--- a/libcxx/include/__thread/jthread.h
+++ b/libcxx/include/__thread/jthread.h
@@ -30,7 +30,7 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-#if _LIBCPP_STD_VER >= 20
+#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -127,7 +127,7 @@ class _LIBCPP_AVAILABILITY_SYNC jthread {
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER >= 20
+#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/__thread/this_thread.h b/libcxx/include/__thread/this_thread.h
index de7eea282c8749..2318a9b8795814 100644
--- a/libcxx/include/__thread/this_thread.h
+++ b/libcxx/include/__thread/this_thread.h
@@ -29,6 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace this_thread {
+#ifndef _LIBCPP_HAS_NO_THREADS
+
_LIBCPP_EXPORTED_FROM_ABI void sleep_for(const chrono::nanoseconds& __ns);
template <class _Rep, class _Period>
@@ -65,6 +67,8 @@ inline _LIBCPP_HIDE_FROM_ABI void sleep_until(const chrono::time_point<chrono::s
inline _LIBCPP_HIDE_FROM_ABI void yield() _NOEXCEPT { __libcpp_thread_yield(); }
+#endif // !_LIBCPP_HAS_NO_THREADS
+
} // namespace this_thread
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__thread/thread.h b/libcxx/include/__thread/thread.h
index 458c1cdb2da332..96de12e83b4917 100644
--- a/libcxx/include/__thread/thread.h
+++ b/libcxx/include/__thread/thread.h
@@ -38,6 +38,8 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
+#if !defined(_LIBCPP_HAS_NO_THREADS)
+
template <class _Tp>
class __thread_specific_ptr;
class _LIBCPP_EXPORTED_FROM_ABI __thread_struct;
@@ -118,7 +120,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> : public __unary_function<__thread
}
};
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {
@@ -143,7 +145,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {
__sstr << __id.__id_;
return __os << __sstr.str();
}
-#endif // _LIBCPP_HAS_NO_LOCALIZATION
+# endif // _LIBCPP_HAS_NO_LOCALIZATION
class _LIBCPP_EXPORTED_FROM_ABI thread {
__libcpp_thread_t __t_;
@@ -156,13 +158,13 @@ class _LIBCPP_EXPORTED_FROM_ABI thread {
typedef __libcpp_thread_t native_handle_type;
_LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
-#ifndef _LIBCPP_CXX03_LANG
+# ifndef _LIBCPP_CXX03_LANG
template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args);
-#else // _LIBCPP_CXX03_LANG
+# else // _LIBCPP_CXX03_LANG
template <class _Fp>
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp __f);
-#endif
+# endif
~thread();
_LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; }
@@ -186,7 +188,7 @@ class _LIBCPP_EXPORTED_FROM_ABI thread {
static unsigned hardware_concurrency() _NOEXCEPT;
};
-#ifndef _LIBCPP_CXX03_LANG
+# ifndef _LIBCPP_CXX03_LANG
template <class _TSp, class _Fp, class... _Args, size_t... _Indices>
inline _LIBCPP_HIDE_FROM_ABI void __thread_execute(tuple<_TSp, _Fp, _Args...>& __t, __tuple_indices<_Indices...>) {
@@ -216,7 +218,7 @@ thread::thread(_Fp&& __f, _Args&&... __args) {
__throw_system_error(__ec, "thread constructor failed");
}
-#else // _LIBCPP_CXX03_LANG
+# else // _LIBCPP_CXX03_LANG
template <class _Fp>
struct __thread_invoke_pair {
@@ -248,10 +250,12 @@ thread::thread(_Fp __f) {
__throw_system_error(__ec, "thread constructor failed");
}
-#endif // _LIBCPP_CXX03_LANG
+# endif // _LIBCPP_CXX03_LANG
inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); }
+#endif // !defined(_LIBCPP_HAS_NO_THREADS)
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index a77b7ce06f2aaa..1cc3bd8858e122 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -215,7 +215,7 @@ _LIBCPP_PUSH_MACROS
# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
#endif
-#if !defined(_LIBCPP_HAS_NO_FILESYSTEM)
+#if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -1560,7 +1560,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_HAS_NO_FILESYSTEM
+#endif // !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/iomanip b/libcxx/include/iomanip
index fb4f15b9a58533..70c8c354e86f21 100644
--- a/libcxx/include/iomanip
+++ b/libcxx/include/iomanip
@@ -43,12 +43,15 @@ template <class charT, class traits, class Allocator>
*/
#include <__config>
-#include <istream>
-#include <version>
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+# include <istream>
+# include <version>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -231,9 +234,9 @@ public:
template <class _CharT, class _Traits, class _MoneyT>
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s) {
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
@@ -243,11 +246,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) {
__mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
__is.setstate(__err);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__is.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return __is;
}
@@ -280,9 +283,9 @@ public:
template <class _CharT, class _Traits, class _MoneyT>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s) {
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
@@ -291,11 +294,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) {
if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
__os.setstate(ios_base::badbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return __os;
}
@@ -328,9 +331,9 @@ public:
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s) {
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
@@ -340,11 +343,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) {
__tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
__is.setstate(__err);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__is.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return __is;
}
@@ -377,9 +380,9 @@ public:
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
if (__s) {
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
@@ -389,11 +392,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) {
.failed())
__os.setstate(ios_base::badbit);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
return __os;
}
@@ -505,7 +508,7 @@ __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT
return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
}
-#if _LIBCPP_STD_VER >= 14
+# if _LIBCPP_STD_VER >= 14
template <class _CharT>
_LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {
@@ -535,8 +538,10 @@ quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _C
return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape);
}
-#endif // _LIBCPP_STD_VER >= 14
+# endif // _LIBCPP_STD_VER >= 14
_LIBCPP_END_NAMESPACE_STD
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
#endif // _LIBCPP_IOMANIP
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 7c65a24bc313d9..8ee29ba3302f2f 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -159,26 +159,29 @@ template <class Stream, class T>
*/
#include <__config>
-#include <__fwd/istream.h>
-#include <__iterator/istreambuf_iterator.h>
-#include <__ostream/basic_ostream.h>
-#include <__type_traits/conjunction.h>
-#include <__type_traits/enable_if.h>
-#include <__type_traits/is_base_of.h>
-#include <__type_traits/make_unsigned.h>
-#include <__utility/declval.h>
-#include <__utility/forward.h>
-#include <bitset>
-#include <ios>
-#include <locale>
-#include <version>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+# include <__fwd/istream.h>
+# include <__iterator/istreambuf_iterator.h>
+# include <__ostream/basic_ostream.h>
+# include <__type_traits/conjunction.h>
+# include <__type_traits/enable_if.h>
+# include <__type_traits/is_base_of.h>
+# include <__type_traits/make_unsigned.h>
+# include <__utility/declval.h>
+# include <__utility/forward.h>
+# include <bitset>
+# include <ios>
+# include <locale>
+# include <version>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
+# include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -354,13 +357,13 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
@@ -368,7 +371,7 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
throw;
}
}
-#endif
+# endif
__is.setstate(__state);
}
return __is;
@@ -435,9 +438,9 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __s(__is);
if (__s) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
long __temp;
@@ -451,7 +454,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
} else {
__n = static_cast<_Tp>(__temp);
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
@@ -459,7 +462,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
__is.setstate(__state);
}
return __is;
@@ -481,9 +484,9 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif
+# endif
_CharT* __s = __p;
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
while (__s != __p + (__n - 1)) {
@@ -502,7 +505,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
__is.width(0);
if (__s == __p)
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
@@ -510,13 +513,13 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
throw;
}
}
-#endif
+# endif
__is.setstate(__state);
}
return __is;
}
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _CharT, class _Traits, size_t _Np>
inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
@@ -539,7 +542,7 @@ operator>>(basic_istream<char, _Traits>& __is, signed char (&__buf)[_Np]) {
return __is >> (char(&)[_Np])__buf;
}
-#else
+# else
template <class _CharT, class _Traits>
inline _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
@@ -562,22 +565,22 @@ operator>>(basic_istream<char, _Traits>& __is, signed char* __s) {
return __is >> (char*)__s;
}
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
template <class _CharT, class _Traits>
_LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) {
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif
+# endif
typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
__state |= ios_base::eofbit | ios_base::failbit;
else
__c = _Traits::to_char_type(__i);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
@@ -585,7 +588,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_
throw;
}
}
-#endif
+# endif
__is.setstate(__state);
}
return __is;
@@ -611,9 +614,9 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
sentry __s(*this, true);
if (__s) {
if (__sb) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
while (true) {
typename traits_type::int_type __i = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__i, _Traits::eof())) {
@@ -627,7 +630,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
}
if (__gc_ == 0)
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
if (__gc_ == 0)
@@ -638,7 +641,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
} else {
__state |= ios_base::failbit;
}
@@ -654,22 +657,22 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>
int_type __r = traits_type::eof();
sentry __s(*this, true);
if (__s) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif
+# endif
__r = this->rdbuf()->sbumpc();
if (traits_type::eq_int_type(__r, traits_type::eof()))
__state |= ios_base::failbit | ios_base::eofbit;
else
__gc_ = 1;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__setstate_nothrow(this->rdstate() | ios_base::badbit);
if (this->exceptions() & ios_base::badbit) {
throw;
}
}
-#endif
+# endif
this->setstate(__state);
}
return __r;
@@ -682,9 +685,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _
sentry __sen(*this, true);
if (__sen) {
if (__n > 0) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif
+# endif
while (__gc_ < __n - 1) {
int_type __i = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__i, traits_type::eof())) {
@@ -700,7 +703,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _
}
if (__gc_ == 0)
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -710,7 +713,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _
throw;
}
}
-#endif
+# endif
} else {
__state |= ios_base::failbit;
}
@@ -731,9 +734,9 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
__gc_ = 0;
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
while (true) {
typename traits_type::int_type __i = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__i, traits_type::eof())) {
@@ -748,12 +751,12 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s
__inc_gcount();
this->rdbuf()->sbumpc();
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
// according to the spec, exceptions here are caught but not rethrown
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (__gc_ == 0)
__state |= ios_base::failbit;
this->setstate(__state);
@@ -768,9 +771,9 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
__gc_ = 0;
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
while (true) {
typename traits_type::int_type __i = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__i, traits_type::eof())) {
@@ -791,7 +794,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
this->rdbuf()->sbumpc();
__inc_gcount();
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -803,7 +806,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
if (__n > 0)
*__s = char_type();
@@ -819,9 +822,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
__gc_ = 0;
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (__n == numeric_limits<streamsize>::max()) {
while (true) {
typename traits_type::int_type __i = this->rdbuf()->sbumpc();
@@ -845,7 +848,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
break;
}
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -853,7 +856,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
@@ -866,13 +869,13 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>
int_type __r = traits_type::eof();
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
__r = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__r, traits_type::eof()))
__state |= ios_base::eofbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -880,7 +883,7 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits>
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@@ -892,13 +895,13 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type*
__gc_ = 0;
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
__gc_ = this->rdbuf()->sgetn(__s, __n);
if (__gc_ != __n)
__state |= ios_base::failbit | ios_base::eofbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -906,7 +909,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type*
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
} else {
__state |= ios_base::failbit;
}
@@ -920,9 +923,9 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _
__gc_ = 0;
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
streamsize __c = this->rdbuf()->in_avail();
switch (__c) {
case -1:
@@ -937,7 +940,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _
__state |= ios_base::failbit | ios_base::eofbit;
break;
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -945,7 +948,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
} else {
__state |= ios_base::failbit;
}
@@ -960,12 +963,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ
this->clear(__state);
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof())
__state |= ios_base::badbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -973,7 +976,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
} else {
__state |= ios_base::failbit;
}
@@ -988,12 +991,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() {
this->clear(__state);
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof())
__state |= ios_base::badbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -1001,7 +1004,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() {
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
} else {
__state |= ios_base::failbit;
}
@@ -1018,14 +1021,14 @@ int basic_istream<_CharT, _Traits>::sync() {
int __r = 0;
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf()->pubsync() == -1) {
__state |= ios_base::badbit;
__r = -1;
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -1033,7 +1036,7 @@ int basic_istream<_CharT, _Traits>::sync() {
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@@ -1045,11 +1048,11 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits>
pos_type __r(-1);
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
__r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -1057,7 +1060,7 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits>
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return __r;
@@ -1069,12 +1072,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _
this->clear(__state);
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -1082,7 +1085,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
@@ -1094,12 +1097,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _
this->clear(__state);
sentry __sen(*this, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
this->__setstate_nothrow(__state);
@@ -1107,7 +1110,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
this->setstate(__state);
}
return *this;
@@ -1118,9 +1121,9 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
while (true) {
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
@@ -1132,7 +1135,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _
break;
__is.rdbuf()->sbumpc();
}
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
@@ -1140,7 +1143,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
__is.setstate(__state);
}
return __is;
@@ -1208,9 +1211,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif
+# endif
__str.clear();
using _Size = typename basic_string<_CharT, _Traits, _Allocator>::size_type;
streamsize const __width = __is.width();
@@ -1240,7 +1243,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _
__is.width(0);
if (__c == 0)
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
@@ -1248,7 +1251,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _
throw;
}
}
-#endif
+# endif
__is.setstate(__state);
}
return __is;
@@ -1260,9 +1263,9 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif
+# endif
__str.clear();
streamsize __extr = 0;
while (true) {
@@ -1283,7 +1286,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All
}
if (__extr == 0)
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
@@ -1291,7 +1294,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All
throw;
}
}
-#endif
+# endif
__is.setstate(__state);
}
return __is;
@@ -1321,9 +1324,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {
ios_base::iostate __state = ios_base::goodbit;
typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
if (__sen) {
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif
+# endif
basic_string<_CharT, _Traits> __str;
const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__is.getloc());
size_t __c = 0;
@@ -1345,7 +1348,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {
__x = bitset<_Size>(__str);
if (_Size > 0 && __c == 0)
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
__is.__setstate_nothrow(__state);
@@ -1353,20 +1356,22 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) {
throw;
}
}
-#endif
+# endif
__is.setstate(__state);
}
return __is;
}
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>;
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>;
-#endif
+# endif
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
_LIBCPP_END_NAMESPACE_STD
+#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <concepts>
# include <iosfwd>
diff --git a/libcxx/include/ostream b/libcxx/include/ostream
index 359d3c0e19c4cf..83742882f7bb67 100644
--- a/libcxx/include/ostream
+++ b/libcxx/include/ostream
@@ -174,17 +174,21 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
#include <__config>
-#include <__ostream/basic_ostream.h>
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
-#if _LIBCPP_STD_VER >= 23
-# include <__ostream/print.h>
-#endif
+# include <__ostream/basic_ostream.h>
-#include <version>
+# if _LIBCPP_STD_VER >= 23
+# include <__ostream/print.h>
+# endif
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+# include <version>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
+
+#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <atomic>
diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index 78a7f2d5901d26..553cc08b122cfe 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -313,21 +313,24 @@ typedef basic_stringstream<wchar_t> wstringstream;
// clang-format on
#include <__config>
-#include <__fwd/sstream.h>
-#include <__ostream/basic_ostream.h>
-#include <__type_traits/is_convertible.h>
-#include <__utility/swap.h>
-#include <istream>
-#include <string>
-#include <string_view>
-#include <version>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+# include <__fwd/sstream.h>
+# include <__ostream/basic_ostream.h>
+# include <__type_traits/is_convertible.h>
+# include <__utility/swap.h>
+# include <istream>
+# include <string>
+# include <string_view>
+# include <version>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
+# include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -370,7 +373,7 @@ public:
str(__s);
}
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const allocator_type& __a)
: basic_stringbuf(ios_base::in | ios_base::out, __a) {}
@@ -404,9 +407,9 @@ public:
: __str_(__s), __hm_(nullptr), __mode_(__wch) {
__init_buf_ptrs();
}
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
template <class _Tp>
requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
@@ -428,37 +431,37 @@ public:
__init_buf_ptrs();
}
-#endif // _LIBCPP_STD_VER >= 26
+# endif // _LIBCPP_STD_VER >= 26
basic_stringbuf(const basic_stringbuf&) = delete;
basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); }
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI basic_stringbuf(basic_stringbuf&& __rhs, const allocator_type& __a)
: basic_stringbuf(__rhs.__mode_, __a) {
__move_init(std::move(__rhs));
}
-#endif
+# endif
// [stringbuf.assign] Assign and swap:
basic_stringbuf& operator=(const basic_stringbuf&) = delete;
basic_stringbuf& operator=(basic_stringbuf&& __rhs);
void swap(basic_stringbuf& __rhs)
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value ||
allocator_traits<allocator_type>::is_always_equal::value)
-#endif
+# endif
;
// [stringbuf.members] Member functions:
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const noexcept { return __str_.get_allocator(); }
-#endif
+# endif
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
+# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
string_type str() const;
-#else
+# else
_LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); }
_LIBCPP_HIDE_FROM_ABI string_type str() && {
@@ -472,9 +475,9 @@ public:
__init_buf_ptrs();
return __result;
}
-#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
+# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _SAlloc>
requires __is_allocator<_SAlloc>::value
_LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
@@ -482,14 +485,14 @@ public:
}
_LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept;
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
void str(const string_type& __s) {
__str_ = __s;
__init_buf_ptrs();
}
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _SAlloc>
requires(!is_same_v<_SAlloc, allocator_type>)
_LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
@@ -501,9 +504,9 @@ public:
__str_ = std::move(__s);
__init_buf_ptrs();
}
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
template <class _Tp>
requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
@@ -513,7 +516,7 @@ public:
__init_buf_ptrs();
}
-#endif // _LIBCPP_STD_VER >= 26
+# endif // _LIBCPP_STD_VER >= 26
protected:
// [stringbuf.virtuals] Overridden virtual functions:
@@ -609,10 +612,10 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
template <class _CharT, class _Traits, class _Allocator>
void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
noexcept(allocator_traits<_Allocator>::propagate_on_container_swap::value ||
allocator_traits<_Allocator>::is_always_equal::value)
-#endif
+# endif
{
char_type* __p = const_cast<char_type*>(__rhs.__str_.data());
ptrdiff_t __rbinp = -1;
@@ -682,14 +685,14 @@ void basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_HIDE_FROM_ABI void
swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
noexcept(noexcept(__x.swap(__y)))
-#endif
+# endif
{
__x.swap(__y);
}
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
+# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
template <class _CharT, class _Traits, class _Allocator>
basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allocator>::str() const {
if (__mode_ & ios_base::out) {
@@ -700,7 +703,7 @@ basic_string<_CharT, _Traits, _Allocator> basic_stringbuf<_CharT, _Traits, _Allo
return string_type(this->eback(), this->egptr(), __str_.get_allocator());
return string_type(__str_.get_allocator());
}
-#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
+# endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_buf_ptrs() {
@@ -726,7 +729,7 @@ _LIBCPP_HIDE_FROM_ABI void basic_stringbuf<_CharT, _Traits, _Allocator>::__init_
}
}
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_HIDE_FROM_ABI basic_string_view<_CharT, _Traits>
basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept {
@@ -738,7 +741,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::view() const noexcept {
return basic_string_view<_CharT, _Traits>(this->eback(), this->egptr());
return basic_string_view<_CharT, _Traits>();
}
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
template <class _CharT, class _Traits, class _Allocator>
typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
@@ -781,9 +784,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {
if (this->pptr() == this->epptr()) {
if (!(__mode_ & ios_base::out))
return traits_type::eof();
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
ptrdiff_t __nout = this->pptr() - this->pbase();
ptrdiff_t __hm = __hm_ - this->pbase();
__str_.push_back(char_type());
@@ -792,11 +795,11 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {
this->setp(__p, __p + __str_.size());
this->__pbump(__nout);
__hm_ = this->pbase() + __hm;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
return traits_type::eof();
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
__hm_ = std::max(this->pptr() + 1, __hm_);
if (__mode_ & ios_base::in) {
@@ -881,7 +884,7 @@ public:
_LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in)
: basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI basic_istringstream(ios_base::openmode __wch, const _Allocator& __a)
: basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::in, __a) {}
@@ -901,9 +904,9 @@ public:
_LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
ios_base::openmode __wch = ios_base::in)
: basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
template <class _Tp>
requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
@@ -920,7 +923,7 @@ public:
_LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
: basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {}
-#endif // _LIBCPP_STD_VER >= 26
+# endif // _LIBCPP_STD_VER >= 26
basic_istringstream(const basic_istringstream&) = delete;
_LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs)
@@ -945,15 +948,15 @@ public:
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_));
}
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
+# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
-#else
+# else
_LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
_LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
-#endif
+# endif
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _SAlloc>
requires __is_allocator<_SAlloc>::value
_LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
@@ -961,26 +964,26 @@ public:
}
_LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _SAlloc>
_LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
__sb_.str(__s);
}
_LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
template <class _Tp>
requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
_LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
rdbuf()->str(__t);
}
-#endif // _LIBCPP_STD_VER >= 26
+# endif // _LIBCPP_STD_VER >= 26
};
template <class _CharT, class _Traits, class _Allocator>
@@ -1017,7 +1020,7 @@ public:
_LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const string_type& __s, ios_base::openmode __wch = ios_base::out)
: basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI basic_ostringstream(ios_base::openmode __wch, const _Allocator& __a)
: basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch | ios_base::out, __a) {}
@@ -1038,9 +1041,9 @@ public:
_LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
ios_base::openmode __wch = ios_base::out)
: basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
template <class _Tp>
requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
@@ -1057,7 +1060,7 @@ public:
_LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
: basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {}
-#endif // _LIBCPP_STD_VER >= 26
+# endif // _LIBCPP_STD_VER >= 26
basic_ostringstream(const basic_ostringstream&) = delete;
_LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs)
@@ -1083,15 +1086,15 @@ public:
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_));
}
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
+# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
-#else
+# else
_LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
_LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
-#endif
+# endif
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _SAlloc>
requires __is_allocator<_SAlloc>::value
_LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
@@ -1099,26 +1102,26 @@ public:
}
_LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _SAlloc>
_LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
__sb_.str(__s);
}
_LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
template <class _Tp>
requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
_LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
rdbuf()->str(__t);
}
-#endif // _LIBCPP_STD_VER >= 26
+# endif // _LIBCPP_STD_VER >= 26
};
template <class _CharT, class _Traits, class _Allocator>
@@ -1156,7 +1159,7 @@ public:
ios_base::openmode __wch = ios_base::in | ios_base::out)
: basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI basic_stringstream(ios_base::openmode __wch, const _Allocator& __a)
: basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__wch, __a) {}
@@ -1178,9 +1181,9 @@ public:
_LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const basic_string<_CharT, _Traits, _SAlloc>& __s,
ios_base::openmode __wch = ios_base::out | ios_base::in)
: basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
template <class _Tp>
requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
@@ -1198,7 +1201,7 @@ public:
_LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
: basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {}
-#endif // _LIBCPP_STD_VER >= 26
+# endif // _LIBCPP_STD_VER >= 26
basic_stringstream(const basic_stringstream&) = delete;
_LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs)
@@ -1223,15 +1226,15 @@ public:
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(std::addressof(__sb_));
}
-#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
+# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
-#else
+# else
_LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
_LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
-#endif
+# endif
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _SAlloc>
requires __is_allocator<_SAlloc>::value
_LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
@@ -1239,26 +1242,26 @@ public:
}
_LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
_LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
-#if _LIBCPP_STD_VER >= 20
+# if _LIBCPP_STD_VER >= 20
template <class _SAlloc>
_LIBCPP_HIDE_FROM_ABI void str(const basic_string<char_type, traits_type, _SAlloc>& __s) {
__sb_.str(__s);
}
_LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
-#if _LIBCPP_STD_VER >= 26
+# if _LIBCPP_STD_VER >= 26
template <class _Tp>
requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
_LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
rdbuf()->str(__t);
}
-#endif // _LIBCPP_STD_VER >= 26
+# endif // _LIBCPP_STD_VER >= 26
};
template <class _CharT, class _Traits, class _Allocator>
@@ -1267,17 +1270,19 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_C
__x.swap(__y);
}
-#if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
+# if _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>;
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>;
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>;
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>;
-#endif
+# endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#endif // !_LIBCPP_HAS_NO_LOCALIZATION
+
#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
# include <ostream>
# include <type_traits>
diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf
index 5a3c17ef7c99e7..906340ef03335e 100644
--- a/libcxx/include/streambuf
+++ b/libcxx/include/streambuf
@@ -107,23 +107,26 @@ protected:
*/
-#include <__assert>
#include <__config>
-#include <__fwd/streambuf.h>
-#include <__locale>
-#include <__type_traits/is_same.h>
-#include <__utility/is_valid_range.h>
-#include <climits>
-#include <ios>
-#include <iosfwd>
-#include <version>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+# include <__assert>
+# include <__fwd/streambuf.h>
+# include <__locale>
+# include <__type_traits/is_same.h>
+# include <__utility/is_valid_range.h>
+# include <climits>
+# include <ios>
+# include <iosfwd>
+# include <version>
+
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
+# include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -430,14 +433,16 @@ typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Tra
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
-#endif
+# endif
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <cstdint>
#endif
diff --git a/libcxx/include/syncstream b/libcxx/include/syncstream
index fea4c66b8e118f..fe9aa07fcdaa8c 100644
--- a/libcxx/include/syncstream
+++ b/libcxx/include/syncstream
@@ -118,33 +118,36 @@ namespace std {
*/
#include <__config>
-#include <__utility/move.h>
-#include <ios>
-#include <iosfwd> // required for declaration of default arguments
-#include <streambuf>
-#include <string>
-
-#ifndef _LIBCPP_HAS_NO_THREADS
-# include <map>
-# include <mutex>
-# include <shared_mutex>
-#endif
+
+#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
+# include <__utility/move.h>
+# include <ios>
+# include <iosfwd> // required for declaration of default arguments
+# include <streambuf>
+# include <string>
+
+# ifndef _LIBCPP_HAS_NO_THREADS
+# include <map>
+# include <mutex>
+# include <shared_mutex>
+# endif
// standard-mandated includes
// [syncstream.syn]
-#include <ostream>
+# include <ostream>
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
+# include <__undef_macros>
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
+# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
// [syncstream.syncbuf.overview]/1
// Class template basic_syncbuf stores character data written to it,
@@ -157,7 +160,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
//
// This helper singleton is used to implement the required
// synchronisation guarantees.
-# ifndef _LIBCPP_HAS_NO_THREADS
+# ifndef _LIBCPP_HAS_NO_THREADS
class __wrapped_streambuf_mutex {
_LIBCPP_HIDE_FROM_ABI __wrapped_streambuf_mutex() = default;
@@ -230,7 +233,7 @@ private:
return __it;
}
};
-# endif // _LIBCPP_HAS_NO_THREADS
+# endif // _LIBCPP_HAS_NO_THREADS
// basic_syncbuf
@@ -270,14 +273,14 @@ public:
}
_LIBCPP_HIDE_FROM_ABI ~basic_syncbuf() {
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-# endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
emit();
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
}
-# endif // _LIBCPP_HAS_NO_EXCEPTIONS
+# endif // _LIBCPP_HAS_NO_EXCEPTIONS
__dec_reference();
}
@@ -334,9 +337,9 @@ protected:
return traits_type::not_eof(__c);
if (this->pptr() == this->epptr()) {
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-# endif
+# endif
size_t __size = __str_.size();
__str_.resize(__str_.capacity() + 1);
_LIBCPP_ASSERT_INTERNAL(__str_.size() > __size, "the buffer hasn't grown");
@@ -345,11 +348,11 @@ protected:
this->setp(__p, __p + __str_.size());
this->pbump(__size);
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
return traits_type::eof();
}
-# endif
+# endif
}
return this->sputc(traits_type::to_char_type(__c));
@@ -370,9 +373,9 @@ private:
if (!__wrapped_)
return false;
-# ifndef _LIBCPP_HAS_NO_THREADS
+# ifndef _LIBCPP_HAS_NO_THREADS
lock_guard<mutex> __lock = __wrapped_streambuf_mutex::__instance().__get_lock(__wrapped_);
-# endif
+# endif
bool __result = true;
if (this->pptr() != this->pbase()) {
@@ -404,24 +407,24 @@ private:
}
_LIBCPP_HIDE_FROM_ABI void __inc_reference() {
-# ifndef _LIBCPP_HAS_NO_THREADS
+# ifndef _LIBCPP_HAS_NO_THREADS
if (__wrapped_)
__wrapped_streambuf_mutex::__instance().__inc_reference(__wrapped_);
-# endif
+# endif
}
_LIBCPP_HIDE_FROM_ABI void __dec_reference() noexcept {
-# ifndef _LIBCPP_HAS_NO_THREADS
+# ifndef _LIBCPP_HAS_NO_THREADS
if (__wrapped_)
__wrapped_streambuf_mutex::__instance().__dec_reference(__wrapped_);
-# endif
+# endif
}
};
using std::syncbuf;
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
using std::wsyncbuf;
-# endif
+# endif
// [syncstream.syncbuf.special], specialized algorithms
template <class _CharT, class _Traits, class _Allocator>
@@ -477,17 +480,17 @@ public:
// TODO validate other unformatted output functions.
typename basic_ostream<char_type, traits_type>::sentry __s(*this);
if (__s) {
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
try {
-# endif
+# endif
if (__sb_.emit() == false)
this->setstate(ios::badbit);
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
} catch (...) {
this->__set_badbit_and_consider_rethrow();
}
-# endif
+# endif
}
}
@@ -502,14 +505,16 @@ private:
};
using std::osyncstream;
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
using std::wosyncstream;
-# endif
+# endif
-#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
+# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
+
#endif // _LIBCPP_SYNCSTREAM
More information about the libcxx-commits
mailing list