📄 ostream
字号:
_RWSTD_SPECIALIZED_FUNCTION
inline bool
basic_ostream<wchar_t, char_traits <wchar_t> >::_C_is_std () const
{
// upcast to a virtual base necessary
return _C_is_cout () || _C_is_cerr ()
|| _RWSTD_STATIC_CAST (const ios_base*, this) == __rw_std_streams [7];
}
#endif // _RWSTD_NO_WCHAR_T
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::flush ()
{
if (this->rdbuf ()) {
_RWSTD_MT_GUARD (this->_C_bufmutex ());
if (-1 == this->rdbuf ()->pubsync ())
this->setstate (ios_base::badbit);
}
return *this;
}
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp (pos_type __pos)
{
_RWSTD_ASSERT (0 != this->rdbuf ());
if (!this->fail ()) {
_RWSTD_MT_GUARD (this->_C_bufmutex ());
if (-1 == this->rdbuf ()->pubseekpos (__pos, ios_base::out))
this->setstate (ios_base::failbit); // lwg issue 129
}
return *this;
}
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::seekp (off_type __off, ios_base::seekdir __dir)
{
_RWSTD_ASSERT (0 != this->rdbuf ());
if (!this->fail ()) {
_RWSTD_MT_GUARD (this->_C_bufmutex ());
if (-1 == this->rdbuf()->pubseekoff (__off, __dir, ios_base::out))
this->setstate (ios_base::failbit); // lwg issue 129
}
return *this;
}
template<class _CharT, class _Traits>
inline _TYPENAME basic_ostream<_CharT, _Traits>::pos_type
basic_ostream<_CharT, _Traits>::tellp ()
{
_RWSTD_ASSERT (0 != this->rdbuf ());
if (!this->fail ()) {
_RWSTD_MT_GUARD (this->_C_bufmutex ());
return this->rdbuf()->pubseekoff (0, ios_base::cur, ios_base::out);
}
return pos_type (off_type (-1));
}
// 27.6.2.5.4 - Character inserter template functions
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<< (basic_ostream<_CharT, _Traits> &__strm, _CharT __c)
{
_RW::__rw_insert (__strm, &__c, 1, __strm.width ()).width (0);
return __strm;
}
#ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<< (basic_ostream<_CharT, _Traits> &__strm, char __c)
{
_RW::__rw_insert (__strm, &__c, 1, __strm.width ()).width (0);
return __strm;
}
#ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<< (basic_ostream<char, _Traits> &__strm, char __c)
{
_RW::__rw_insert (__strm, &__c, 1, __strm.width ()).width (0);
return __strm;
}
#else // if defined (_RWSTD_NO_FUNC_PARTIAL_SPEC)
inline basic_ostream<char, char_traits<char> >&
operator<< (basic_ostream<char, char_traits<char> > &__strm, char __c)
{
_RW::__rw_insert (__strm, &__c, 1, __strm.width ()).width (0);
return __strm;
}
#endif // _RWSTD_NO_FUNC_PARTIAL_SPEC
#endif // _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
_RWSTD_NAMESPACE_END // std
_RWSTD_NAMESPACE_BEGIN (__rw)
_RWSTD_INSTANTIATE_1 (
_RWSTD_EXPORT ostream&
__rw_insert (ostream&, char*, streamsize, streamsize)
);
#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_INSTANTIATE_1 (
_RWSTD_EXPORT wostream&
__rw_insert (wostream&, wchar_t*, streamsize, streamsize)
);
_RWSTD_INSTANTIATE_1 (
_RWSTD_EXPORT wostream&
__rw_insert (wostream&, char*, streamsize, streamsize)
);
#endif // _RWSTD_NO_WCHAR_T
_RWSTD_NAMESPACE_END // __rw
_RWSTD_NAMESPACE_BEGIN (std)
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<< (basic_ostream<_CharT, _Traits> &__strm, const _CharT *__s)
{
#if !defined (_MSC_VER) //|| _MSC_VER > 1300
_RW::__rw_insert (__strm, __s, _Traits::length (__s),
__strm.width ()).width (0);
#else
// template arguments explicitly provided to work around an MSVC bug
_RW::__rw_insert<_CharT, _Traits, _CharT>
(__strm, __s, _Traits::length (__s), __strm.width ()).width (0);
#endif
return __strm;
}
#ifndef _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
operator<< (basic_ostream<_CharT, _Traits> &__strm, const char *__s)
{
_RW::__rw_insert (__strm, __s, char_traits<char>::length (__s),
__strm.width ()).width (0);
return __strm;
}
#ifndef _RWSTD_NO_FUNC_PARTIAL_SPEC
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<< (basic_ostream<char, _Traits> &__strm, const char *__s)
{
_RW::__rw_insert (__strm, __s, char_traits<char>::length (__s),
__strm.width ()).width (0);
return __strm;
}
#else // if defined (_RWSTD_NO_FUNC_PARTIAL_SPEC)
inline basic_ostream<char, char_traits<char> >&
operator<< (basic_ostream<char, char_traits<char> >& __strm, const char *__s)
{
_RW::__rw_insert (__strm, __s, char_traits<char>::length (__s),
__strm.width ()).width (0);
return __strm;
}
#endif // _RWSTD_NO_FUNC_PARTIAL_SPEC
#endif // _RWSTD_NO_OVERLOAD_OF_TEMPLATE_FUNCTION
#ifndef _RWSTD_NO_SIGNED_CHAR_IN_STREAMS
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<< (basic_ostream<char, _Traits> &__strm, unsigned char __c)
{
return __strm << _RWSTD_STATIC_CAST (char, __c);
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<< (basic_ostream<char, _Traits> &__strm, signed char __c)
{
return __strm << _RWSTD_STATIC_CAST (char, __c);
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<< (basic_ostream<char, _Traits> &__strm, const unsigned char *__s)
{
return __strm << _RWSTD_REINTERPRET_CAST (const char*, __s);
}
template <class _Traits>
inline basic_ostream<char, _Traits>&
operator<< (basic_ostream<char, _Traits>& __strm, const signed char *__s)
{
return __strm << _RWSTD_REINTERPRET_CAST (const char*, __s);
}
#endif // _RWSTD_NO_SIGNED_CHAR_IN_STREAMS
// 27.6.2.7, p1
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
endl (basic_ostream<_CharT, _Traits>& __strm)
{
return __strm.put (__strm.widen ('\n')).flush ();
}
// 27.6.2.7, p3
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
ends (basic_ostream<_CharT, _Traits>& __strm)
{
return __strm.put (_CharT ());
}
// 27.6.2.7, p5
template<class _CharT, class _Traits>
inline basic_ostream<_CharT, _Traits>&
flush (basic_ostream<_CharT, _Traits>& __strm)
{
return __strm.flush ();
}
// 21.3.7.9, p3 - defined here, declared inline in <string>
template<class _CharT, class _Traits, class _Allocator>
inline basic_ostream<_CharT, _Traits>&
operator<< (basic_ostream<_CharT, _Traits> & __strm,
const basic_string<_CharT, _Traits, _Allocator> &__str)
{
#if !defined (_MSC_VER) || (_MSC_VER > 1300)
// working around yet another of the variety of MSVC bugs
_RW::__rw_insert (__strm, __str.data (), __str.length (),
__strm.width ()).width (0);
#else
_RW::__rw_insert<_CharT, _Traits, _CharT>
(__strm, __str.data (), __str.length (), __strm.width ()).width (0);
#endif // !defined (_MSC_VER) || (_MSC_VER > 1200)
return __strm;
}
#if defined (_MSC_VER) && _MSV_VER <= 1300
// working around an MSVC 6.0 bug that causes it to pick the member
// operator<<(const void*) over the above if overloaded in user code
_RWSTD_SPECIALIZED_FUNCTION
inline ostream& endl (ostream& __strm)
{
return __strm.put (__strm.widen ('\n')).flush ();
}
_RWSTD_SPECIALIZED_FUNCTION
inline ostream& ends (ostream& __strm)
{
return __strm.put (char ());
}
_RWSTD_SPECIALIZED_FUNCTION
inline ostream& flush (ostream& __strm)
{
return __strm.flush ();
}
#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_SPECIALIZED_FUNCTION
inline wostream& endl (wostream& __strm)
{
return __strm.put (__strm.widen ('\n')).flush ();
}
_RWSTD_SPECIALIZED_FUNCTION
inline wostream& ends (wostream& __strm)
{
return __strm.put (char ());
}
_RWSTD_SPECIALIZED_FUNCTION
inline wostream& flush (wostream& __strm)
{
return __strm.flush ();
}
#endif // _RWSTD_NO_WCHAR_T
#else
// working around an MSVC 6.0 bug that causes:
// - warning C4660: template-class specialization is already instantiated
// - many linker errors for (inline or otherwise) members of basic_ostream
_RWSTD_INSTANTIATE_2 (class _RWSTD_EXPORT
basic_ostream<char, char_traits<char> >);
#ifndef _RWSTD_NO_WCHAR_T
_RWSTD_INSTANTIATE_2 (class _RWSTD_EXPORT
basic_ostream<wchar_t, char_traits<wchar_t> >);
#endif // _RWSTD_NO_WCHAR_T
#endif // !_MSC_VER || _MSC_VER > 1300
_RWSTD_NAMESPACE_END // std
#if _RWSTD_DEFINE_TEMPLATE (BASIC_OSTREAM)
# include <ostream.cc>
#endif
#endif // _RWSTD_OSTREAM_INCLUDED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -