Commit ab7561be authored by Eric Niebler's avatar Eric Niebler Committed by Facebook Github Bot

replace #include <ios> in FBString.h with lighter #include <iosfwd>

Summary:
FBString.h doesn't really use any of the facilities defined in <ios>, such as the stream manipulators. No sense dragging it into FBString.h.

This could potentially break downstream users if they are not already including the io facilities they are using. It's unlikely though because the actual stream types (std::ostream, std::istream) and stream objects (std::cout, std::cin) are defined in other headers that #include <ios>.

Reviewed By: yfeldblum, Orvid

Differential Revision: D4886133

fbshipit-source-id: 56adb93280eeeef8b09320b30fb224d4f72707bf
parent 50708687
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <atomic> #include <atomic>
#include <cstddef> #include <cstddef>
#include <ios> #include <iosfwd>
#include <limits> #include <limits>
#include <type_traits> #include <type_traits>
...@@ -2643,13 +2643,13 @@ std::basic_istream< ...@@ -2643,13 +2643,13 @@ std::basic_istream<
std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type, std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>& is, typename basic_fbstring<E, T, A, S>::traits_type>& is,
basic_fbstring<E, T, A, S>& str) { basic_fbstring<E, T, A, S>& str) {
typename std::basic_istream<E, T>::sentry sentry(is); typedef std::basic_istream<
typedef std::basic_istream<typename basic_fbstring<E, T, A, S>::value_type, typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type> typename basic_fbstring<E, T, A, S>::traits_type>
__istream_type; _istream_type;
typedef typename __istream_type::ios_base __ios_base; typename _istream_type::sentry sentry(is);
size_t extracted = 0; size_t extracted = 0;
auto err = __ios_base::goodbit; auto err = _istream_type::goodbit;
if (sentry) { if (sentry) {
auto n = is.width(); auto n = is.width();
if (n <= 0) { if (n <= 0) {
...@@ -2658,7 +2658,7 @@ std::basic_istream< ...@@ -2658,7 +2658,7 @@ std::basic_istream<
str.erase(); str.erase();
for (auto got = is.rdbuf()->sgetc(); extracted != size_t(n); ++extracted) { for (auto got = is.rdbuf()->sgetc(); extracted != size_t(n); ++extracted) {
if (got == T::eof()) { if (got == T::eof()) {
err |= __ios_base::eofbit; err |= _istream_type::eofbit;
is.width(0); is.width(0);
break; break;
} }
...@@ -2670,7 +2670,7 @@ std::basic_istream< ...@@ -2670,7 +2670,7 @@ std::basic_istream<
} }
} }
if (!extracted) { if (!extracted) {
err |= __ios_base::failbit; err |= _istream_type::failbit;
} }
if (err) { if (err) {
is.setstate(err); is.setstate(err);
...@@ -2687,28 +2687,31 @@ operator<<( ...@@ -2687,28 +2687,31 @@ operator<<(
typename basic_fbstring<E, T, A, S>::traits_type>& os, typename basic_fbstring<E, T, A, S>::traits_type>& os,
const basic_fbstring<E, T, A, S>& str) { const basic_fbstring<E, T, A, S>& str) {
#if _LIBCPP_VERSION #if _LIBCPP_VERSION
typename std::basic_ostream< typedef std::basic_ostream<
typename basic_fbstring<E, T, A, S>::value_type, typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>::sentry __s(os); typename basic_fbstring<E, T, A, S>::traits_type>
if (__s) { _ostream_type;
typename _ostream_type::sentry _s(os);
if (_s) {
typedef std::ostreambuf_iterator< typedef std::ostreambuf_iterator<
typename basic_fbstring<E, T, A, S>::value_type, typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type> _Ip; typename basic_fbstring<E, T, A, S>::traits_type> _Ip;
size_t __len = str.size(); size_t __len = str.size();
bool __left = bool __left =
(os.flags() & std::ios_base::adjustfield) == std::ios_base::left; (os.flags() & _ostream_type::adjustfield) == _ostream_type::left;
if (__pad_and_output(_Ip(os), if (__pad_and_output(_Ip(os),
str.data(), str.data(),
__left ? str.data() + __len : str.data(), __left ? str.data() + __len : str.data(),
str.data() + __len, str.data() + __len,
os, os,
os.fill()).failed()) { os.fill()).failed()) {
os.setstate(std::ios_base::badbit | std::ios_base::failbit); os.setstate(_ostream_type::badbit | _ostream_type::failbit);
} }
} }
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
typedef decltype(os.precision()) streamsize;
// MSVC doesn't define __ostream_insert // MSVC doesn't define __ostream_insert
os.write(str.data(), std::streamsize(str.size())); os.write(str.data(), static_cast<streamsize>(str.size()));
#else #else
std::__ostream_insert(os, str.data(), str.size()); std::__ostream_insert(os, str.data(), str.size());
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment