//===----------------------------------------------------------------------===// // // 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 // //===----------------------------------------------------------------------===// // // template // constexpr OutIter // copy(CharT* first, CharT* last, ostreambuf_iterator result); // UNSUPPORTED: no-localization #include #include #include #include #include #include "stream_types.h" #include "test_macros.h" template void test() { using CharT = typename std::remove_cv::type; { std::basic_ostringstream oss; CCharT buff[] = {'B', 'a', 'n', 'a', 'n', 'e'}; std::copy(std::begin(buff), std::end(buff), std::ostreambuf_iterator(oss)); assert(oss.str() == std::basic_string_view(buff, 6)); } { failing_streambuf fsb(4); std::basic_ostream oss(&fsb); CCharT buff[] = {'B', 'a', 'n', 'a', 'n', 'e'}; auto res = std::copy(std::begin(buff), std::end(buff), std::ostreambuf_iterator(oss)); assert(res.failed()); assert(fsb.str() == std::basic_string_view(buff, 4)); } } int main(int, char**) { test(); test(); #ifndef TEST_HAS_NO_WIDE_CHARACTERS test(); test(); #endif return 0; }