brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · c7f7cac Raw
61 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// <sstream>12 13// template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>14// class basic_istringstream15 16// explicit basic_istringstream(basic_string<char_type, traits_type, allocator_type>&& s, ios_base::openmode which = ios_base::in);17 18#include <sstream>19#include <cassert>20 21#include "make_string.h"22#include "test_macros.h"23#include "operator_hijacker.h"24 25#define STR(S) MAKE_STRING(CharT, S)26 27template <class CharT>28static void test() {29  {30    std::basic_string<CharT> s(STR("testing"));31    const std::basic_istringstream<CharT> ss(std::move(s));32    assert(ss.str() == STR("testing"));33  }34  {35    std::basic_string<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>> s(STR("testing"));36    const std::basic_istringstream<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>> ss(std::move(s));37    assert((ss.str() ==38            std::basic_string<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>>(STR("testing"))));39  }40  {41    std::basic_string<CharT> s(STR("testing"));42    const std::basic_istringstream<CharT> ss(std::move(s), std::ios_base::binary);43    assert(ss.str() == STR("testing"));44  }45  {46    std::basic_string<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>> s(STR("testing"));47    const std::basic_istringstream<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>> ss(48        std::move(s), std::ios_base::binary);49    assert((ss.str() ==50            std::basic_string<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>>(STR("testing"))));51  }52}53 54int main(int, char**) {55  test<char>();56#ifndef TEST_HAS_NO_WIDE_CHARACTERS57  test<wchar_t>();58#endif59  return 0;60}61