mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-22 16:37:40 +08:00

Summary: Before this patch, we would only ever throw an exception if the badbit was set on the stream. The Standard is currently very unclear on how exceptions should be propagated and what error flags should be set by the input stream operations. This commit changes libc++ to behave under a different (but valid) interpretation of the Standard. This interpretation of the Standard matches what other implementations are doing. I will submit a paper in San Diego to clarify the Standard such that the interpretation used in this commit (and other implementations) is the only possible one. PR21586 PR15949 rdar://problem/15347558 Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D49863 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357531 91177308-0d34-0410-b5e6-96231b3b80d8
28 lines
733 B
C++
28 lines
733 B
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// test:
|
|
|
|
// template <class charT, class traits, size_t N>
|
|
// basic_ostream<charT, traits>&
|
|
// operator<<(basic_ostream<charT, traits>& os, const bitset<N>& x);
|
|
|
|
#include <bitset>
|
|
#include <sstream>
|
|
#include <cassert>
|
|
|
|
int main(int, char**)
|
|
{
|
|
std::ostringstream os;
|
|
std::bitset<8> b(0x5A);
|
|
os << b;
|
|
assert(os.str() == "01011010");
|
|
|
|
return 0;
|
|
}
|