1.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // { dg-options "-std=gnu++17" }
  2. // Copyright (C) 2013-2022 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // You should have received a copy of the GNU General Public License along
  14. // with this library; see the file COPYING3. If not see
  15. // <http://www.gnu.org/licenses/>.
  16. // inserters
  17. // NB: This file is predicated on sstreams, istreams, and ostreams
  18. // working, not to mention other major details like char_traits, and
  19. // all of the string_view class.
  20. #include <string_view>
  21. #include <stdexcept>
  22. #include <sstream>
  23. #include <fstream>
  24. #include <iostream>
  25. #include <testsuite_hooks.h>
  26. void
  27. test01()
  28. {
  29. typedef std::string_view::size_type csize_type;
  30. typedef std::string_view::const_reference cref;
  31. typedef std::string_view::reference ref;
  32. const std::string_view str01("sailing grand traverse bay\n"
  33. "\t\t\t from Elk Rapids to the point reminds me of miles");
  34. // ostream& operator<<(ostream&, const basic_string_view&)
  35. std::ostringstream ostrs01;
  36. try
  37. {
  38. ostrs01 << str01;
  39. VERIFY( ostrs01.str() == str01 );
  40. }
  41. catch(std::exception& fail)
  42. {
  43. VERIFY( false );
  44. }
  45. std::string_view hello_world;
  46. std::cout << hello_world;
  47. }
  48. int
  49. main()
  50. {
  51. test01();
  52. return 0;
  53. }