42 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// basic_istringstream(ios_base::openmode which, const Allocator& a);17 18#include <sstream>19#include <cassert>20 21#include "test_allocator.h"22#include "test_macros.h"23#include "operator_hijacker.h"24 25template <class CharT, class Allocator>26static void test(const Allocator& a) {27 const std::basic_istringstream<CharT, std::char_traits<CharT>, Allocator> ss(std::ios_base::binary, a);28 assert(ss.rdbuf()->get_allocator() == a);29 assert(ss.view().empty());30}31 32int main(int, char**) {33 test<char>(test_allocator<char>(2));34 test<char>(operator_hijacker_allocator<char>());35#ifndef TEST_HAS_NO_WIDE_CHARACTERS36 test<wchar_t>(test_allocator<wchar_t>(2));37 test<wchar_t>(operator_hijacker_allocator<wchar_t>());38#endif39 40 return 0;41}42