Commit 13369e8f authored by Peter Griess's avatar Peter Griess Committed by Sara Golemon

Use libc++ equivalent of std::__ostream_insert()

Summary:
- In libstdc++, existing code uses the internal std::__ostream_insert()
method to write a formatted string that can include '\0' characters.
This internal method doesn't exist in libc++. Instead, use the
relevant internal bits.

Test Plan:
- fbconfig -r folly && fbmake runtests
- ./configure && make check on Mac OS X

Reviewed By: njormrod@fb.com

FB internal diff: D1108540
parent d5a04238
/* /*
* Copyright 2013 Facebook, Inc. * Copyright 2014 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -2312,7 +2312,29 @@ operator<<( ...@@ -2312,7 +2312,29 @@ operator<<(
std::basic_ostream<typename basic_fbstring<E, T, A, S>::value_type, std::basic_ostream<typename basic_fbstring<E, T, A, S>::value_type,
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
typename std::basic_ostream<
typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type>::sentry __s(os);
if (__s) {
typedef std::ostreambuf_iterator<
typename basic_fbstring<E, T, A, S>::value_type,
typename basic_fbstring<E, T, A, S>::traits_type> _Ip;
size_t __len = str.size();
bool __left =
(os.flags() & std::ios_base::adjustfield) == std::ios_base::left;
if (__pad_and_output(_Ip(os),
str.data(),
__left ? str.data() + __len : str.data(),
str.data() + __len,
os,
os.fill()).failed()) {
os.setstate(std::ios_base::badbit | std::ios_base::failbit);
}
}
#else
std::__ostream_insert(os, str.data(), str.size()); std::__ostream_insert(os, str.data(), str.size());
#endif
return os; return os;
} }
......
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