2010-05-12 03:42:16 +08:00
|
|
|
// -*- C++ -*-
|
|
|
|
//===-------------------------- ostream -----------------------------------===//
|
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_OSTREAM
|
|
|
|
#define _LIBCPP_OSTREAM
|
|
|
|
|
|
|
|
/*
|
|
|
|
ostream synopsis
|
|
|
|
|
|
|
|
template <class charT, class traits = char_traits<charT> >
|
|
|
|
class basic_ostream
|
|
|
|
: virtual public basic_ios<charT,traits>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// types (inherited from basic_ios (27.5.4)):
|
|
|
|
typedef charT char_type;
|
|
|
|
typedef traits traits_type;
|
|
|
|
typedef typename traits_type::int_type int_type;
|
|
|
|
typedef typename traits_type::pos_type pos_type;
|
|
|
|
typedef typename traits_type::off_type off_type;
|
|
|
|
|
|
|
|
// 27.7.2.2 Constructor/destructor:
|
|
|
|
explicit basic_ostream(basic_streambuf<char_type,traits>* sb);
|
|
|
|
basic_ostream(basic_ostream&& rhs);
|
|
|
|
virtual ~basic_ostream();
|
|
|
|
|
|
|
|
// 27.7.2.3 Assign/swap
|
2013-08-14 23:15:28 +08:00
|
|
|
basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream& operator=(basic_ostream&& rhs);
|
|
|
|
void swap(basic_ostream& rhs);
|
|
|
|
|
|
|
|
// 27.7.2.4 Prefix/suffix:
|
|
|
|
class sentry;
|
|
|
|
|
|
|
|
// 27.7.2.6 Formatted output:
|
|
|
|
basic_ostream& operator<<(basic_ostream& (*pf)(basic_ostream&));
|
|
|
|
basic_ostream& operator<<(basic_ios<charT, traits>& (*pf)(basic_ios<charT,traits>&));
|
|
|
|
basic_ostream& operator<<(ios_base& (*pf)(ios_base&));
|
|
|
|
basic_ostream& operator<<(bool n);
|
|
|
|
basic_ostream& operator<<(short n);
|
|
|
|
basic_ostream& operator<<(unsigned short n);
|
|
|
|
basic_ostream& operator<<(int n);
|
|
|
|
basic_ostream& operator<<(unsigned int n);
|
|
|
|
basic_ostream& operator<<(long n);
|
|
|
|
basic_ostream& operator<<(unsigned long n);
|
|
|
|
basic_ostream& operator<<(long long n);
|
|
|
|
basic_ostream& operator<<(unsigned long long n);
|
|
|
|
basic_ostream& operator<<(float f);
|
|
|
|
basic_ostream& operator<<(double f);
|
|
|
|
basic_ostream& operator<<(long double f);
|
|
|
|
basic_ostream& operator<<(const void* p);
|
|
|
|
basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
|
2019-07-02 00:20:25 +08:00
|
|
|
basic_ostream& operator<<(nullptr_t);
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
// 27.7.2.7 Unformatted output:
|
|
|
|
basic_ostream& put(char_type c);
|
|
|
|
basic_ostream& write(const char_type* s, streamsize n);
|
|
|
|
basic_ostream& flush();
|
|
|
|
|
|
|
|
// 27.7.2.5 seeks:
|
|
|
|
pos_type tellp();
|
|
|
|
basic_ostream& seekp(pos_type);
|
|
|
|
basic_ostream& seekp(off_type, ios_base::seekdir);
|
2014-09-16 23:27:01 +08:00
|
|
|
protected:
|
|
|
|
basic_ostream(const basic_ostream& rhs) = delete;
|
|
|
|
basic_ostream(basic_ostream&& rhs);
|
|
|
|
// 27.7.3.3 Assign/swap
|
|
|
|
basic_ostream& operator=(basic_ostream& rhs) = delete;
|
|
|
|
basic_ostream& operator=(const basic_ostream&& rhs);
|
|
|
|
void swap(basic_ostream& rhs);
|
2010-05-12 03:42:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// 27.7.2.6.4 character inserters
|
|
|
|
|
|
|
|
template<class charT, class traits>
|
|
|
|
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, charT);
|
|
|
|
|
|
|
|
template<class charT, class traits>
|
|
|
|
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, char);
|
|
|
|
|
|
|
|
template<class traits>
|
|
|
|
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, char);
|
|
|
|
|
|
|
|
// signed and unsigned
|
|
|
|
|
|
|
|
template<class traits>
|
|
|
|
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, signed char);
|
|
|
|
|
|
|
|
template<class traits>
|
|
|
|
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, unsigned char);
|
|
|
|
|
|
|
|
// NTBS
|
|
|
|
template<class charT, class traits>
|
|
|
|
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const charT*);
|
|
|
|
|
|
|
|
template<class charT, class traits>
|
|
|
|
basic_ostream<charT,traits>& operator<<(basic_ostream<charT,traits>&, const char*);
|
|
|
|
|
|
|
|
template<class traits>
|
|
|
|
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const char*);
|
|
|
|
|
|
|
|
// signed and unsigned
|
|
|
|
template<class traits>
|
|
|
|
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const signed char*);
|
|
|
|
|
|
|
|
template<class traits>
|
|
|
|
basic_ostream<char,traits>& operator<<(basic_ostream<char,traits>&, const unsigned char*);
|
|
|
|
|
|
|
|
// swap:
|
|
|
|
template <class charT, class traits>
|
|
|
|
void swap(basic_ostream<charT, traits>& x, basic_ostream<charT, traits>& y);
|
|
|
|
|
|
|
|
template <class charT, class traits>
|
|
|
|
basic_ostream<charT,traits>& endl(basic_ostream<charT,traits>& os);
|
|
|
|
|
|
|
|
template <class charT, class traits>
|
|
|
|
basic_ostream<charT,traits>& ends(basic_ostream<charT,traits>& os);
|
|
|
|
|
|
|
|
template <class charT, class traits>
|
|
|
|
basic_ostream<charT,traits>& flush(basic_ostream<charT,traits>& os);
|
|
|
|
|
|
|
|
// rvalue stream insertion
|
|
|
|
template <class charT, class traits, class T>
|
|
|
|
basic_ostream<charT, traits>&
|
|
|
|
operator<<(basic_ostream<charT, traits>&& os, const T& x);
|
|
|
|
|
|
|
|
} // std
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <__config>
|
|
|
|
#include <ios>
|
|
|
|
#include <streambuf>
|
|
|
|
#include <locale>
|
|
|
|
#include <iterator>
|
|
|
|
#include <bitset>
|
2018-12-11 12:35:44 +08:00
|
|
|
#include <version>
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2011-10-18 04:05:10 +08:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2010-05-12 03:42:16 +08:00
|
|
|
#pragma GCC system_header
|
2011-10-18 04:05:10 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
2017-01-05 07:56:00 +08:00
|
|
|
class _LIBCPP_TEMPLATE_VIS basic_ostream
|
2010-05-12 03:42:16 +08:00
|
|
|
: virtual public basic_ios<_CharT, _Traits>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// types (inherited from basic_ios (27.5.4)):
|
|
|
|
typedef _CharT char_type;
|
|
|
|
typedef _Traits traits_type;
|
|
|
|
typedef typename traits_type::int_type int_type;
|
|
|
|
typedef typename traits_type::pos_type pos_type;
|
|
|
|
typedef typename traits_type::off_type off_type;
|
|
|
|
|
|
|
|
// 27.7.2.2 Constructor/destructor:
|
2018-10-17 03:26:23 +08:00
|
|
|
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
|
[libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility
Summary:
GCC and Clang handle visibility attributes on the out-of-line definition of externally instantiated templates differently. For example in the reproducer below Clang will emit both 'foo' and 'bar' with default visibility while GCC only emits a non-hidden 'foo'.
```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))
template <class T>
struct Foo {
void foo();
void bar();
};
template <class T>
void Foo<T>::foo() {}
template <class T>
inline INLINE_VISIBILITY
void Foo<T>::bar() {}
template struct Foo<int>;
```
This difference creates ABI incompatibilities between Clang and GCC built dylibs. Specifically GCC built dylibs lack definitions for various member functions of `basic_string`, `basic_istream`, `basic_ostream`, `basic_iostream`, and `basic_streambuf` (All of these types are externally instantiated).
Surprisingly these missing symbols don't cause many problems because the functions are marked `always_inline` therefore the dylib definition is rarely needed. However when an out-of-line definition is required then GCC built dylibs will fail to link. For example [GCC built dylibs cannot build Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).
This patch works around this issue by adding `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally instantiated member functions as always inline. When building the library `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to "default" instead of "hidden", otherwise it acts exactly the same as `_LIBCPP_INLINE_VISIBILITY`.
After applying this patch GCC dylibs now contain:
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRS3_S4_E`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getEPwl`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5pbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetcEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKcl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetnEPwl`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetnEPcl`
* `_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6sbumpcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputnEPKwl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRS3_S4_E`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwl`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputcEw`
This patch has no effect on Clang based builds.
Reviewers: mclow.lists, eugenis, danalbert, jroelofs, EricWF
Subscribers: beanz, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D24600
llvm-svn: 281681
2016-09-16 08:00:48 +08:00
|
|
|
explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb)
|
|
|
|
{ this->init(__sb); }
|
2010-05-12 03:42:16 +08:00
|
|
|
virtual ~basic_ostream();
|
|
|
|
protected:
|
2017-04-19 07:38:41 +08:00
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
[libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility
Summary:
GCC and Clang handle visibility attributes on the out-of-line definition of externally instantiated templates differently. For example in the reproducer below Clang will emit both 'foo' and 'bar' with default visibility while GCC only emits a non-hidden 'foo'.
```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))
template <class T>
struct Foo {
void foo();
void bar();
};
template <class T>
void Foo<T>::foo() {}
template <class T>
inline INLINE_VISIBILITY
void Foo<T>::bar() {}
template struct Foo<int>;
```
This difference creates ABI incompatibilities between Clang and GCC built dylibs. Specifically GCC built dylibs lack definitions for various member functions of `basic_string`, `basic_istream`, `basic_ostream`, `basic_iostream`, and `basic_streambuf` (All of these types are externally instantiated).
Surprisingly these missing symbols don't cause many problems because the functions are marked `always_inline` therefore the dylib definition is rarely needed. However when an out-of-line definition is required then GCC built dylibs will fail to link. For example [GCC built dylibs cannot build Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).
This patch works around this issue by adding `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally instantiated member functions as always inline. When building the library `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to "default" instead of "hidden", otherwise it acts exactly the same as `_LIBCPP_INLINE_VISIBILITY`.
After applying this patch GCC dylibs now contain:
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRS3_S4_E`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getEPwl`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5pbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetcEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKcl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetnEPwl`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetnEPcl`
* `_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6sbumpcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputnEPKwl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRS3_S4_E`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwl`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputcEw`
This patch has no effect on Clang based builds.
Reviewers: mclow.lists, eugenis, danalbert, jroelofs, EricWF
Subscribers: beanz, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D24600
llvm-svn: 281681
2016-09-16 08:00:48 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream(basic_ostream&& __rhs);
|
|
|
|
|
|
|
|
// 27.7.2.3 Assign/swap
|
[libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility
Summary:
GCC and Clang handle visibility attributes on the out-of-line definition of externally instantiated templates differently. For example in the reproducer below Clang will emit both 'foo' and 'bar' with default visibility while GCC only emits a non-hidden 'foo'.
```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))
template <class T>
struct Foo {
void foo();
void bar();
};
template <class T>
void Foo<T>::foo() {}
template <class T>
inline INLINE_VISIBILITY
void Foo<T>::bar() {}
template struct Foo<int>;
```
This difference creates ABI incompatibilities between Clang and GCC built dylibs. Specifically GCC built dylibs lack definitions for various member functions of `basic_string`, `basic_istream`, `basic_ostream`, `basic_iostream`, and `basic_streambuf` (All of these types are externally instantiated).
Surprisingly these missing symbols don't cause many problems because the functions are marked `always_inline` therefore the dylib definition is rarely needed. However when an out-of-line definition is required then GCC built dylibs will fail to link. For example [GCC built dylibs cannot build Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).
This patch works around this issue by adding `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally instantiated member functions as always inline. When building the library `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to "default" instead of "hidden", otherwise it acts exactly the same as `_LIBCPP_INLINE_VISIBILITY`.
After applying this patch GCC dylibs now contain:
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRS3_S4_E`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getEPwl`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5pbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetcEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKcl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetnEPwl`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetnEPcl`
* `_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6sbumpcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputnEPKwl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRS3_S4_E`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwl`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputcEw`
This patch has no effect on Clang based builds.
Reviewers: mclow.lists, eugenis, danalbert, jroelofs, EricWF
Subscribers: beanz, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D24600
llvm-svn: 281681
2016-09-16 08:00:48 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream& operator=(basic_ostream&& __rhs);
|
|
|
|
#endif
|
2018-10-17 03:26:23 +08:00
|
|
|
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
|
[libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility
Summary:
GCC and Clang handle visibility attributes on the out-of-line definition of externally instantiated templates differently. For example in the reproducer below Clang will emit both 'foo' and 'bar' with default visibility while GCC only emits a non-hidden 'foo'.
```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))
template <class T>
struct Foo {
void foo();
void bar();
};
template <class T>
void Foo<T>::foo() {}
template <class T>
inline INLINE_VISIBILITY
void Foo<T>::bar() {}
template struct Foo<int>;
```
This difference creates ABI incompatibilities between Clang and GCC built dylibs. Specifically GCC built dylibs lack definitions for various member functions of `basic_string`, `basic_istream`, `basic_ostream`, `basic_iostream`, and `basic_streambuf` (All of these types are externally instantiated).
Surprisingly these missing symbols don't cause many problems because the functions are marked `always_inline` therefore the dylib definition is rarely needed. However when an out-of-line definition is required then GCC built dylibs will fail to link. For example [GCC built dylibs cannot build Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).
This patch works around this issue by adding `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally instantiated member functions as always inline. When building the library `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to "default" instead of "hidden", otherwise it acts exactly the same as `_LIBCPP_INLINE_VISIBILITY`.
After applying this patch GCC dylibs now contain:
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRS3_S4_E`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getEPwl`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5pbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetcEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKcl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetnEPwl`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetnEPcl`
* `_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6sbumpcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputnEPKwl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRS3_S4_E`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwl`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputcEw`
This patch has no effect on Clang based builds.
Reviewers: mclow.lists, eugenis, danalbert, jroelofs, EricWF
Subscribers: beanz, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D24600
llvm-svn: 281681
2016-09-16 08:00:48 +08:00
|
|
|
void swap(basic_ostream& __rhs)
|
|
|
|
{ basic_ios<char_type, traits_type>::swap(__rhs); }
|
2014-09-16 23:27:01 +08:00
|
|
|
|
2017-01-07 04:58:25 +08:00
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
2014-09-16 23:33:53 +08:00
|
|
|
basic_ostream (const basic_ostream& __rhs) = delete;
|
|
|
|
basic_ostream& operator=(const basic_ostream& __rhs) = delete;
|
2014-09-16 23:27:01 +08:00
|
|
|
#else
|
2014-09-17 09:58:15 +08:00
|
|
|
basic_ostream (const basic_ostream& __rhs); // not defined
|
|
|
|
basic_ostream& operator=(const basic_ostream& __rhs); // not defined
|
2014-09-16 23:27:01 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
public:
|
|
|
|
|
|
|
|
// 27.7.2.4 Prefix/suffix:
|
2017-01-05 07:56:00 +08:00
|
|
|
class _LIBCPP_TEMPLATE_VIS sentry;
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
// 27.7.2.6 Formatted output:
|
2018-10-17 03:26:23 +08:00
|
|
|
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
|
[libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility
Summary:
GCC and Clang handle visibility attributes on the out-of-line definition of externally instantiated templates differently. For example in the reproducer below Clang will emit both 'foo' and 'bar' with default visibility while GCC only emits a non-hidden 'foo'.
```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))
template <class T>
struct Foo {
void foo();
void bar();
};
template <class T>
void Foo<T>::foo() {}
template <class T>
inline INLINE_VISIBILITY
void Foo<T>::bar() {}
template struct Foo<int>;
```
This difference creates ABI incompatibilities between Clang and GCC built dylibs. Specifically GCC built dylibs lack definitions for various member functions of `basic_string`, `basic_istream`, `basic_ostream`, `basic_iostream`, and `basic_streambuf` (All of these types are externally instantiated).
Surprisingly these missing symbols don't cause many problems because the functions are marked `always_inline` therefore the dylib definition is rarely needed. However when an out-of-line definition is required then GCC built dylibs will fail to link. For example [GCC built dylibs cannot build Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).
This patch works around this issue by adding `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally instantiated member functions as always inline. When building the library `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to "default" instead of "hidden", otherwise it acts exactly the same as `_LIBCPP_INLINE_VISIBILITY`.
After applying this patch GCC dylibs now contain:
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRS3_S4_E`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getEPwl`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5pbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetcEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKcl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetnEPwl`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetnEPcl`
* `_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6sbumpcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputnEPKwl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRS3_S4_E`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwl`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputcEw`
This patch has no effect on Clang based builds.
Reviewers: mclow.lists, eugenis, danalbert, jroelofs, EricWF
Subscribers: beanz, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D24600
llvm-svn: 281681
2016-09-16 08:00:48 +08:00
|
|
|
basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
|
|
|
|
{ return __pf(*this); }
|
|
|
|
|
2018-10-17 03:26:23 +08:00
|
|
|
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream& operator<<(basic_ios<char_type, traits_type>&
|
[libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility
Summary:
GCC and Clang handle visibility attributes on the out-of-line definition of externally instantiated templates differently. For example in the reproducer below Clang will emit both 'foo' and 'bar' with default visibility while GCC only emits a non-hidden 'foo'.
```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))
template <class T>
struct Foo {
void foo();
void bar();
};
template <class T>
void Foo<T>::foo() {}
template <class T>
inline INLINE_VISIBILITY
void Foo<T>::bar() {}
template struct Foo<int>;
```
This difference creates ABI incompatibilities between Clang and GCC built dylibs. Specifically GCC built dylibs lack definitions for various member functions of `basic_string`, `basic_istream`, `basic_ostream`, `basic_iostream`, and `basic_streambuf` (All of these types are externally instantiated).
Surprisingly these missing symbols don't cause many problems because the functions are marked `always_inline` therefore the dylib definition is rarely needed. However when an out-of-line definition is required then GCC built dylibs will fail to link. For example [GCC built dylibs cannot build Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).
This patch works around this issue by adding `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally instantiated member functions as always inline. When building the library `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to "default" instead of "hidden", otherwise it acts exactly the same as `_LIBCPP_INLINE_VISIBILITY`.
After applying this patch GCC dylibs now contain:
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRS3_S4_E`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getEPwl`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5pbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetcEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKcl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetnEPwl`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetnEPcl`
* `_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6sbumpcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputnEPKwl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRS3_S4_E`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwl`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputcEw`
This patch has no effect on Clang based builds.
Reviewers: mclow.lists, eugenis, danalbert, jroelofs, EricWF
Subscribers: beanz, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D24600
llvm-svn: 281681
2016-09-16 08:00:48 +08:00
|
|
|
(*__pf)(basic_ios<char_type,traits_type>&))
|
|
|
|
{ __pf(*this); return *this; }
|
|
|
|
|
2018-10-17 03:26:23 +08:00
|
|
|
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
|
[libc++] Add _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY to support GCC ABI compatibility
Summary:
GCC and Clang handle visibility attributes on the out-of-line definition of externally instantiated templates differently. For example in the reproducer below Clang will emit both 'foo' and 'bar' with default visibility while GCC only emits a non-hidden 'foo'.
```
// RUN: g++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
// RUN: clang++ -std=c++11 -shared -O3 test.cpp && sym_extract.py a.out
#define INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline))
template <class T>
struct Foo {
void foo();
void bar();
};
template <class T>
void Foo<T>::foo() {}
template <class T>
inline INLINE_VISIBILITY
void Foo<T>::bar() {}
template struct Foo<int>;
```
This difference creates ABI incompatibilities between Clang and GCC built dylibs. Specifically GCC built dylibs lack definitions for various member functions of `basic_string`, `basic_istream`, `basic_ostream`, `basic_iostream`, and `basic_streambuf` (All of these types are externally instantiated).
Surprisingly these missing symbols don't cause many problems because the functions are marked `always_inline` therefore the dylib definition is rarely needed. However when an out-of-line definition is required then GCC built dylibs will fail to link. For example [GCC built dylibs cannot build Clang](http://stackoverflow.com/questions/39454262/clang-build-errors).
This patch works around this issue by adding `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` which is used to mark externally instantiated member functions as always inline. When building the library `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` sets the symbol's visibility to "default" instead of "hidden", otherwise it acts exactly the same as `_LIBCPP_INLINE_VISIBILITY`.
After applying this patch GCC dylibs now contain:
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5gbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9sputbackcEc`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6snextcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE9pubsetbufEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_9basic_iosIwS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5pbumpEi`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE7getlineEPcl`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetcEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6sbumpcEv`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getERc`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6snextcEv`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEmw`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getERw`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEmc`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE3getEPcl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRNS_9basic_iosIcS2_EES6_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputcEc`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE6getlocEv`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5gbumpEi`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRS3_S4_E`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE3getEPwl`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEElsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEEC1EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEEC2EPNS_15basic_streambufIwS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5pbumpEi`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetcEv`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sputnEPKcl`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sgetnEPwl`
* `_ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEElsEPFRNS_8ios_baseES5_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_`
* `_ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE5sgetnEPcl`
* `_ZNKSt3__115basic_streambufIwNS_11char_traitsIwEEE6getlocEv`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE`
* `_ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcmm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6sbumpcEv`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC2EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__113basic_istreamIwNS_11char_traitsIwEEErsEPFRS3_S4_E`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw`
* `_ZNSt3__112basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEE6__initEPKwm`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputnEPKwl`
* `_ZNSt3__113basic_istreamIcNS_11char_traitsIcEEErsEPFRS3_S4_E`
* `_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEEC1EPNS_15basic_streambufIcS2_EE`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwl`
* `_ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE5sputcEw`
This patch has no effect on Clang based builds.
Reviewers: mclow.lists, eugenis, danalbert, jroelofs, EricWF
Subscribers: beanz, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D24600
llvm-svn: 281681
2016-09-16 08:00:48 +08:00
|
|
|
basic_ostream& operator<<(ios_base& (*__pf)(ios_base&))
|
|
|
|
{ __pf(*this); return *this; }
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream& operator<<(bool __n);
|
|
|
|
basic_ostream& operator<<(short __n);
|
|
|
|
basic_ostream& operator<<(unsigned short __n);
|
|
|
|
basic_ostream& operator<<(int __n);
|
|
|
|
basic_ostream& operator<<(unsigned int __n);
|
|
|
|
basic_ostream& operator<<(long __n);
|
|
|
|
basic_ostream& operator<<(unsigned long __n);
|
|
|
|
basic_ostream& operator<<(long long __n);
|
|
|
|
basic_ostream& operator<<(unsigned long long __n);
|
|
|
|
basic_ostream& operator<<(float __f);
|
|
|
|
basic_ostream& operator<<(double __f);
|
|
|
|
basic_ostream& operator<<(long double __f);
|
|
|
|
basic_ostream& operator<<(const void* __p);
|
|
|
|
basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
|
|
|
|
|
2019-07-02 00:20:25 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
|
|
|
basic_ostream& operator<<(nullptr_t)
|
|
|
|
{ return *this << "nullptr"; }
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
// 27.7.2.7 Unformatted output:
|
|
|
|
basic_ostream& put(char_type __c);
|
|
|
|
basic_ostream& write(const char_type* __s, streamsize __n);
|
|
|
|
basic_ostream& flush();
|
|
|
|
|
|
|
|
// 27.7.2.5 seeks:
|
2018-10-17 03:26:23 +08:00
|
|
|
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
|
2010-05-12 03:42:16 +08:00
|
|
|
pos_type tellp();
|
2018-10-17 03:26:23 +08:00
|
|
|
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream& seekp(pos_type __pos);
|
2018-10-17 03:26:23 +08:00
|
|
|
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
|
|
|
|
|
|
|
|
protected:
|
2018-07-12 07:14:33 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream() {} // extension, intentially does not initialize
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
2017-01-05 07:56:00 +08:00
|
|
|
class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
bool __ok_;
|
|
|
|
basic_ostream<_CharT, _Traits>& __os_;
|
|
|
|
|
|
|
|
sentry(const sentry&); // = delete;
|
|
|
|
sentry& operator=(const sentry&); // = delete;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit sentry(basic_ostream<_CharT, _Traits>& __os);
|
|
|
|
~sentry();
|
|
|
|
|
2018-07-12 07:14:33 +08:00
|
|
|
_LIBCPP_INLINE_VISIBILITY
|
2012-02-22 05:46:43 +08:00
|
|
|
_LIBCPP_EXPLICIT
|
2010-05-12 03:42:16 +08:00
|
|
|
operator bool() const {return __ok_;}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os)
|
|
|
|
: __ok_(false),
|
|
|
|
__os_(__os)
|
|
|
|
{
|
|
|
|
if (__os.good())
|
|
|
|
{
|
|
|
|
if (__os.tie())
|
|
|
|
__os.tie()->flush();
|
|
|
|
__ok_ = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>::sentry::~sentry()
|
|
|
|
{
|
|
|
|
if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf)
|
|
|
|
&& !uncaught_exception())
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__os_.rdbuf()->pubsync() == -1)
|
|
|
|
__os_.setstate(ios_base::badbit);
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-19 07:38:41 +08:00
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs)
|
|
|
|
{
|
|
|
|
this->move(__rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs)
|
|
|
|
{
|
|
|
|
swap(__rhs);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2017-04-19 07:38:41 +08:00
|
|
|
#endif // _LIBCPP_CXX03_LANG
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
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_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
|
|
|
if (__sb)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
|
|
|
|
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
|
|
|
|
_Ip __i(__sb);
|
|
|
|
_Ip __eof;
|
|
|
|
_Op __o(*this);
|
2010-05-12 03:42:16 +08:00
|
|
|
size_t __c = 0;
|
|
|
|
for (; __i != __eof; ++__i, ++__o, ++__c)
|
|
|
|
{
|
|
|
|
*__o = *__i;
|
|
|
|
if (__o.failed())
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (__c == 0)
|
|
|
|
this->setstate(ios_base::failbit);
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_failbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
this->setstate(ios_base::badbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(bool __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), __n).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(short __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
|
|
|
ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(),
|
|
|
|
__flags == ios_base::oct || __flags == ios_base::hex ?
|
|
|
|
static_cast<long>(static_cast<unsigned short>(__n)) :
|
|
|
|
static_cast<long>(__n)).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(int __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
|
|
|
ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(),
|
|
|
|
__flags == ios_base::oct || __flags == ios_base::hex ?
|
|
|
|
static_cast<long>(static_cast<unsigned int>(__n)) :
|
|
|
|
static_cast<long>(__n)).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(long __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), __n).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), __n).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(long long __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), __n).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), __n).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(float __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(double __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), __n).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(long double __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), __n).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::operator<<(const void* __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
|
|
|
|
const _Fp& __f = use_facet<_Fp>(this->getloc());
|
2010-05-12 03:42:16 +08:00
|
|
|
if (__f.put(*this, *this, this->fill(), __n).failed())
|
|
|
|
this->setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
2013-12-11 03:25:49 +08:00
|
|
|
__put_character_sequence(basic_ostream<_CharT, _Traits>& __os,
|
|
|
|
const _CharT* __str, size_t __len)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
|
|
|
|
if (__pad_and_output(_Ip(__os),
|
2013-12-11 03:25:49 +08:00
|
|
|
__str,
|
2010-05-12 03:42:16 +08:00
|
|
|
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
2013-12-11 03:25:49 +08:00
|
|
|
__str + __len :
|
|
|
|
__str,
|
|
|
|
__str + __len,
|
2010-05-12 03:42:16 +08:00
|
|
|
__os,
|
|
|
|
__os.fill()).failed())
|
|
|
|
__os.setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
__os.__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return __os;
|
|
|
|
}
|
|
|
|
|
2018-09-20 07:31:34 +08:00
|
|
|
|
2013-12-11 03:25:49 +08:00
|
|
|
template<class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
return _VSTD::__put_character_sequence(__os, &__c, 1);
|
2013-12-11 03:25:49 +08:00
|
|
|
}
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template<class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
|
|
|
|
if (__s)
|
|
|
|
{
|
|
|
|
_CharT __c = __os.widen(__cn);
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
|
|
|
|
if (__pad_and_output(_Ip(__os),
|
2010-05-12 03:42:16 +08:00
|
|
|
&__c,
|
|
|
|
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
|
|
|
&__c + 1 :
|
|
|
|
&__c,
|
|
|
|
&__c + 1,
|
|
|
|
__os,
|
|
|
|
__os.fill()).failed())
|
|
|
|
__os.setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
__os.__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return __os;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class _Traits>
|
|
|
|
basic_ostream<char, _Traits>&
|
|
|
|
operator<<(basic_ostream<char, _Traits>& __os, char __c)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
return _VSTD::__put_character_sequence(__os, &__c, 1);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class _Traits>
|
|
|
|
basic_ostream<char, _Traits>&
|
|
|
|
operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class _Traits>
|
|
|
|
basic_ostream<char, _Traits>&
|
|
|
|
operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
return _VSTD::__put_character_sequence(__os, (char *) &__c, 1);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
|
2010-05-12 03:42:16 +08:00
|
|
|
size_t __len = char_traits<char>::length(__strn);
|
|
|
|
const int __bs = 100;
|
|
|
|
_CharT __wbb[__bs];
|
|
|
|
_CharT* __wb = __wbb;
|
|
|
|
unique_ptr<_CharT, void(*)(void*)> __h(0, free);
|
|
|
|
if (__len > __bs)
|
|
|
|
{
|
|
|
|
__wb = (_CharT*)malloc(__len*sizeof(_CharT));
|
|
|
|
if (__wb == 0)
|
|
|
|
__throw_bad_alloc();
|
|
|
|
__h.reset(__wb);
|
|
|
|
}
|
|
|
|
for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
|
|
|
|
*__p = __os.widen(*__strn);
|
2011-11-30 02:15:50 +08:00
|
|
|
if (__pad_and_output(_Ip(__os),
|
2010-05-12 03:42:16 +08:00
|
|
|
__wb,
|
|
|
|
(__os.flags() & ios_base::adjustfield) == ios_base::left ?
|
|
|
|
__wb + __len :
|
|
|
|
__wb,
|
|
|
|
__wb + __len,
|
|
|
|
__os,
|
|
|
|
__os.fill()).failed())
|
|
|
|
__os.setstate(ios_base::badbit | ios_base::failbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
__os.__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return __os;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class _Traits>
|
|
|
|
basic_ostream<char, _Traits>&
|
|
|
|
operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
return _VSTD::__put_character_sequence(__os, __str, _Traits::length(__str));
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class _Traits>
|
|
|
|
basic_ostream<char, _Traits>&
|
|
|
|
operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
const char *__s = (const char *) __str;
|
|
|
|
return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template<class _Traits>
|
|
|
|
basic_ostream<char, _Traits>&
|
|
|
|
operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
const char *__s = (const char *) __str;
|
|
|
|
return _VSTD::__put_character_sequence(__os, __s, _Traits::length(__s));
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::put(char_type __c)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
2011-11-30 02:15:50 +08:00
|
|
|
typedef ostreambuf_iterator<_CharT, _Traits> _Op;
|
|
|
|
_Op __o(*this);
|
2010-05-12 03:42:16 +08:00
|
|
|
*__o = __c;
|
|
|
|
if (__o.failed())
|
|
|
|
this->setstate(ios_base::badbit);
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n)
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
sentry __sen(*this);
|
|
|
|
if (__sen && __n)
|
|
|
|
{
|
2013-01-16 01:22:03 +08:00
|
|
|
if (this->rdbuf()->sputn(__s, __n) != __n)
|
|
|
|
this->setstate(ios_base::badbit);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::flush()
|
|
|
|
{
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
try
|
|
|
|
{
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
if (this->rdbuf())
|
|
|
|
{
|
|
|
|
sentry __s(*this);
|
|
|
|
if (__s)
|
|
|
|
{
|
|
|
|
if (this->rdbuf()->pubsync() == -1)
|
|
|
|
this->setstate(ios_base::badbit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifndef _LIBCPP_NO_EXCEPTIONS
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
this->__set_badbit_and_consider_rethrow();
|
|
|
|
}
|
2010-08-22 08:02:43 +08:00
|
|
|
#endif // _LIBCPP_NO_EXCEPTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
typename basic_ostream<_CharT, _Traits>::pos_type
|
|
|
|
basic_ostream<_CharT, _Traits>::tellp()
|
|
|
|
{
|
|
|
|
if (this->fail())
|
|
|
|
return pos_type(-1);
|
|
|
|
return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)
|
|
|
|
{
|
2013-11-01 06:20:45 +08:00
|
|
|
sentry __s(*this);
|
2015-06-22 23:01:21 +08:00
|
|
|
if (!this->fail())
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
|
|
|
|
this->setstate(ios_base::failbit);
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)
|
|
|
|
{
|
2013-11-01 06:20:45 +08:00
|
|
|
sentry __s(*this);
|
2015-06-22 23:01:21 +08:00
|
|
|
if (!this->fail())
|
2013-11-01 06:20:45 +08:00
|
|
|
{
|
|
|
|
if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
|
|
|
|
this->setstate(ios_base::failbit);
|
|
|
|
}
|
2010-05-12 03:42:16 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
2020-07-13 23:53:48 +08:00
|
|
|
inline
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
endl(basic_ostream<_CharT, _Traits>& __os)
|
|
|
|
{
|
|
|
|
__os.put(__os.widen('\n'));
|
|
|
|
__os.flush();
|
|
|
|
return __os;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
2020-07-13 23:53:48 +08:00
|
|
|
inline
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
ends(basic_ostream<_CharT, _Traits>& __os)
|
|
|
|
{
|
|
|
|
__os.put(_CharT());
|
|
|
|
return __os;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class _CharT, class _Traits>
|
2020-07-13 23:53:48 +08:00
|
|
|
inline
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
flush(basic_ostream<_CharT, _Traits>& __os)
|
|
|
|
{
|
|
|
|
__os.flush();
|
|
|
|
return __os;
|
|
|
|
}
|
|
|
|
|
2017-04-19 07:38:41 +08:00
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template <class _Stream, class _Tp>
|
2016-01-09 03:21:02 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
typename enable_if
|
|
|
|
<
|
|
|
|
!is_lvalue_reference<_Stream>::value &&
|
|
|
|
is_base_of<ios_base, _Stream>::value,
|
2012-01-13 07:37:51 +08:00
|
|
|
_Stream&&
|
2010-05-12 03:42:16 +08:00
|
|
|
>::type
|
|
|
|
operator<<(_Stream&& __os, const _Tp& __x)
|
|
|
|
{
|
|
|
|
__os << __x;
|
2012-01-13 07:37:51 +08:00
|
|
|
return _VSTD::move(__os);
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
2017-04-19 07:38:41 +08:00
|
|
|
#endif // _LIBCPP_CXX03_LANG
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
template<class _CharT, class _Traits, class _Allocator>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
|
|
|
const basic_string<_CharT, _Traits, _Allocator>& __str)
|
|
|
|
{
|
2014-02-16 09:57:26 +08:00
|
|
|
return _VSTD::__put_character_sequence(__os, __str.data(), __str.size());
|
2010-05-12 03:42:16 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 13:31:24 +08:00
|
|
|
template<class _CharT, class _Traits>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os,
|
2019-09-26 02:56:54 +08:00
|
|
|
basic_string_view<_CharT, _Traits> __sv)
|
2016-07-21 13:31:24 +08:00
|
|
|
{
|
|
|
|
return _VSTD::__put_character_sequence(__os, __sv.data(), __sv.size());
|
|
|
|
}
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _CharT, class _Traits>
|
2016-01-09 03:21:02 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec)
|
|
|
|
{
|
|
|
|
return __os << __ec.category().name() << ':' << __ec.value();
|
|
|
|
}
|
|
|
|
|
2011-11-30 02:15:50 +08:00
|
|
|
template<class _CharT, class _Traits, class _Yp>
|
2016-01-09 03:21:02 +08:00
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
2010-05-12 03:42:16 +08:00
|
|
|
basic_ostream<_CharT, _Traits>&
|
2011-11-30 02:15:50 +08:00
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
return __os << __p.get();
|
|
|
|
}
|
|
|
|
|
2017-11-27 23:51:36 +08:00
|
|
|
template<class _CharT, class _Traits, class _Yp, class _Dp>
|
|
|
|
inline _LIBCPP_INLINE_VISIBILITY
|
|
|
|
typename enable_if
|
|
|
|
<
|
2018-03-23 02:27:28 +08:00
|
|
|
is_same<void, typename __void_t<decltype((declval<basic_ostream<_CharT, _Traits>&>() << declval<typename unique_ptr<_Yp, _Dp>::pointer>()))>::type>::value,
|
2017-11-27 23:51:36 +08:00
|
|
|
basic_ostream<_CharT, _Traits>&
|
|
|
|
>::type
|
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
|
|
|
|
{
|
|
|
|
return __os << __p.get();
|
|
|
|
}
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
template <class _CharT, class _Traits, size_t _Size>
|
|
|
|
basic_ostream<_CharT, _Traits>&
|
2011-04-05 22:55:28 +08:00
|
|
|
operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
|
2010-05-12 03:42:16 +08:00
|
|
|
{
|
|
|
|
return __os << __x.template to_string<_CharT, _Traits>
|
|
|
|
(use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
|
|
|
|
use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
|
|
|
|
}
|
|
|
|
|
2018-12-06 08:24:58 +08:00
|
|
|
#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB
|
2016-09-16 06:27:07 +08:00
|
|
|
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>)
|
|
|
|
_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>)
|
2017-05-05 01:08:54 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
|
|
|
#endif // _LIBCPP_OSTREAM
|