1 //===---------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===---------------------------------------------------------------------===//
9 #ifndef _LIBCPP___OSTREAM_PUT_CHARACTER_SEQUENCE_H
10 #define _LIBCPP___OSTREAM_PUT_CHARACTER_SEQUENCE_H
14 #if _LIBCPP_HAS_LOCALIZATION
16 # include <__cstddef/size_t.h>
17 # include <__fwd/ostream.h>
18 # include <__iterator/ostreambuf_iterator.h>
19 # include <__locale_dir/pad_and_output.h>
22 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23 # pragma GCC system_header
26 _LIBCPP_BEGIN_NAMESPACE_STD
28 template <class _CharT
, class _Traits
>
29 _LIBCPP_HIDE_FROM_ABI basic_ostream
<_CharT
, _Traits
>&
30 __put_character_sequence(basic_ostream
<_CharT
, _Traits
>& __os
, const _CharT
* __str
, size_t __len
) {
31 # if _LIBCPP_HAS_EXCEPTIONS
33 # endif // _LIBCPP_HAS_EXCEPTIONS
34 typename basic_ostream
<_CharT
, _Traits
>::sentry
__s(__os
);
36 typedef ostreambuf_iterator
<_CharT
, _Traits
> _Ip
;
37 if (std::__pad_and_output(
40 (__os
.flags() & ios_base::adjustfield
) == ios_base::left
? __str
+ __len
: __str
,
45 __os
.setstate(ios_base::badbit
| ios_base::failbit
);
47 # if _LIBCPP_HAS_EXCEPTIONS
49 __os
.__set_badbit_and_consider_rethrow();
51 # endif // _LIBCPP_HAS_EXCEPTIONS
55 _LIBCPP_END_NAMESPACE_STD
57 #endif // _LIBCPP_HAS_LOCALIZATION
59 #endif // _LIBCPP___OSTREAM_PUT_CHARACTER_SEQUENCE_H