]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add default template argument to basic_istream_view
authorJonathan Wakely <jwakely@redhat.com>
Mon, 23 Aug 2021 15:16:05 +0000 (16:16 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 23 Aug 2021 15:17:10 +0000 (16:17 +0100)
The standard shows this default template argument in the <ranges>
synopsis, but it was missing in libstdc++.

libstdc++-v3/ChangeLog:

* include/std/ranges (basic_istream_view): Add default template
argument.
* testsuite/std/ranges/istream_view.cc: Check it.

libstdc++-v3/include/std/ranges
libstdc++-v3/testsuite/std/ranges/istream_view.cc

index 3d49a26ee79c44020ec58282c1e6cc17027111c5..b373e4f05c07156029299ba96823b616eec4254e 100644 (file)
@@ -679,7 +679,8 @@ namespace views
        = requires(basic_istream<_CharT, _Traits>& is, _Val& t) { is >> t; };
   } // namespace __detail
 
-  template<movable _Val, typename _CharT, typename _Traits>
+  template<movable _Val, typename _CharT,
+          typename _Traits = char_traits<_CharT>>
     requires default_initializable<_Val>
       && __detail::__stream_extractable<_Val, _CharT, _Traits>
     class basic_istream_view
index 2f15f787250342f95825f6ebbe45764a1e09cacf..f5c0c2a6bb01bf92b5bf25bad140a2124be8491f 100644 (file)
@@ -94,6 +94,15 @@ test05()
     ;
 }
 
+void
+test06()
+{
+  // Default template argument
+  using V = std::ranges::basic_istream_view<int, char>;
+  using W = std::ranges::basic_istream_view<int, char, std::char_traits<char>>;
+  static_assert( std::is_same_v<V, W> );
+}
+
 int
 main()
 {
@@ -102,4 +111,5 @@ main()
   test03();
   test04();
   test05();
+  test06();
 }