161d2a9b3SPiotr Fusik //===----------------------------------------------------------------------===//
261d2a9b3SPiotr Fusik //
361d2a9b3SPiotr Fusik // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
461d2a9b3SPiotr Fusik // See https://llvm.org/LICENSE.txt for license information.
561d2a9b3SPiotr Fusik // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
661d2a9b3SPiotr Fusik //
761d2a9b3SPiotr Fusik //===----------------------------------------------------------------------===//
861d2a9b3SPiotr Fusik 
961d2a9b3SPiotr Fusik // UNSUPPORTED: c++03, c++11, c++14, c++17
1061d2a9b3SPiotr Fusik 
1161d2a9b3SPiotr Fusik // <sstream>
1261d2a9b3SPiotr Fusik 
1361d2a9b3SPiotr Fusik // template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
1461d2a9b3SPiotr Fusik // class basic_istringstream
1561d2a9b3SPiotr Fusik 
1661d2a9b3SPiotr Fusik // explicit basic_istringstream(basic_string<char_type, traits_type, allocator_type>&& s, ios_base::openmode which = ios_base::in);
1761d2a9b3SPiotr Fusik 
1861d2a9b3SPiotr Fusik #include <sstream>
1961d2a9b3SPiotr Fusik #include <cassert>
2061d2a9b3SPiotr Fusik 
2161d2a9b3SPiotr Fusik #include "make_string.h"
2261d2a9b3SPiotr Fusik #include "test_macros.h"
23*4dee6411SMark de Wever #include "operator_hijacker.h"
2461d2a9b3SPiotr Fusik 
2561d2a9b3SPiotr Fusik #define STR(S) MAKE_STRING(CharT, S)
2661d2a9b3SPiotr Fusik 
2761d2a9b3SPiotr Fusik template <class CharT>
2861d2a9b3SPiotr Fusik static void test() {
2961d2a9b3SPiotr Fusik   {
3061d2a9b3SPiotr Fusik     std::basic_string<CharT> s(STR("testing"));
3161d2a9b3SPiotr Fusik     const std::basic_istringstream<CharT> ss(std::move(s));
3261d2a9b3SPiotr Fusik     assert(ss.str() == STR("testing"));
3361d2a9b3SPiotr Fusik   }
3461d2a9b3SPiotr Fusik   {
35*4dee6411SMark de Wever     std::basic_string<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>> s(STR("testing"));
36*4dee6411SMark de Wever     const std::basic_istringstream<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>> ss(std::move(s));
37*4dee6411SMark de Wever     assert((ss.str() ==
38*4dee6411SMark de Wever             std::basic_string<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>>(STR("testing"))));
39*4dee6411SMark de Wever   }
40*4dee6411SMark de Wever   {
4161d2a9b3SPiotr Fusik     std::basic_string<CharT> s(STR("testing"));
4261d2a9b3SPiotr Fusik     const std::basic_istringstream<CharT> ss(std::move(s), std::ios_base::binary);
4361d2a9b3SPiotr Fusik     assert(ss.str() == STR("testing"));
4461d2a9b3SPiotr Fusik   }
45*4dee6411SMark de Wever   {
46*4dee6411SMark de Wever     std::basic_string<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>> s(STR("testing"));
47*4dee6411SMark de Wever     const std::basic_istringstream<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>> ss(
48*4dee6411SMark de Wever         std::move(s), std::ios_base::binary);
49*4dee6411SMark de Wever     assert((ss.str() ==
50*4dee6411SMark de Wever             std::basic_string<CharT, std::char_traits<CharT>, operator_hijacker_allocator<CharT>>(STR("testing"))));
51*4dee6411SMark de Wever   }
5261d2a9b3SPiotr Fusik }
5361d2a9b3SPiotr Fusik 
5461d2a9b3SPiotr Fusik int main(int, char**) {
5561d2a9b3SPiotr Fusik   test<char>();
5661d2a9b3SPiotr Fusik #ifndef TEST_HAS_NO_WIDE_CHARACTERS
5761d2a9b3SPiotr Fusik   test<wchar_t>();
5861d2a9b3SPiotr Fusik #endif
5961d2a9b3SPiotr Fusik   return 0;
6061d2a9b3SPiotr Fusik }
61