ostream_handle_impl.h
Go to the documentation of this file.
1 #ifndef cetlib_detail_ostream_handle_impl_h
2 #define cetlib_detail_ostream_handle_impl_h
3 
4 #include <fstream>
5 #include <ostream>
6 #include <string>
7 
8 namespace cet::detail {
9 
10  // Interface
12  public:
13  virtual ~ostream_handle_base() = default;
14  std::ostream&
16  {
17  return get_stream();
18  }
19 
20  private:
21  virtual std::ostream& get_stream() = 0;
22  };
23 
24  // Concrete types below
26  public:
27  ostream_observer(std::ostream& os) : os_{os} {}
28 
29  private:
30  std::ostream& os_;
31  std::ostream&
32  get_stream() override
33  {
34  return os_;
35  }
36  };
37 
38  template <typename OSTREAM,
39  typename =
40  std::enable_if_t<std::is_base_of_v<std::ostream, OSTREAM>>>
42  public:
43  ostream_owner(OSTREAM&& os) : os_(std::move(os)) {}
44 
45  private:
46  OSTREAM os_;
47  std::ostream&
48  get_stream() override
49  {
50  return os_;
51  }
52  };
53 }
54 
55 #endif /* cetlib_detail_ostream_handle_impl_h */
56 
57 // Local variables:
58 // mode: c++
59 // End:
STL namespace.
std::ostream & get_stream() override
def move(depos, offset)
Definition: depos.py:107
virtual std::ostream & get_stream()=0
virtual ~ostream_handle_base()=default
std::ostream & get_stream() override