SeqAn3  3.1.0-rc.1
The Modern C++ library for sequence analysis.
istreambuf_view.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4 // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5 // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6 // -----------------------------------------------------------------------------------------------------
7 
13 #pragma once
14 
15 #include <iosfwd>
16 
17 #include <seqan3/std/iterator>
18 #include <seqan3/std/ranges>
19 
22 
23 namespace seqan3::detail
24 {
25 
26 // ============================================================================
27 // istreambuf_fn (adaptor definition)
28 // ============================================================================
29 
32 struct istreambuf_fn
33 {
40  template <typename stream_char_t, typename stream_traits_t>
41  constexpr auto operator()(std::basic_streambuf<stream_char_t, stream_traits_t> & s) const
42  {
43  return std::ranges::subrange<detail::fast_istreambuf_iterator<stream_char_t, stream_traits_t>,
44  std::default_sentinel_t>
45  {
46  detail::fast_istreambuf_iterator<stream_char_t, stream_traits_t>{s},
47  std::default_sentinel_t{}
48  };
49  }
50 
56  template <input_stream stream_t>
57  constexpr auto operator()(stream_t & s) const
58  {
59  return this->operator()(*s.rdbuf());
60  }
61 };
62 
63 } // namespace seqan3::detail
64 
65 // ============================================================================
66 // detail::istreambuf (adaptor instance definition)
67 // ============================================================================
68 
69 namespace seqan3::detail
70 {
110 inline constexpr auto istreambuf = detail::istreambuf_fn{};
111 
112 } // namespace seqan3::detail
Provides seqan3::detail::fast_istreambuf_iterator.
Stream concepts.
Provides C++20 additions to the <iterator> header.
Adaptations of concepts from the Ranges TS.