Wayverb
buffer.h
1 #pragma once
2 
3 #include <memory>
4 
5 namespace frequency_domain {
6 
7 template <typename T>
8 class buffer final {
9 public:
10  using value_type = T;
11 
12  explicit buffer(size_t buffer_size = 0);
13  buffer(const buffer& rhs);
14  buffer& operator=(buffer rhs);
15 
16  buffer(buffer&& rhs) noexcept = default;
17  buffer& operator=(buffer&& rhs) noexcept = default;
18 
19  void swap(buffer& rhs) noexcept;
20 
21  size_t size() const noexcept;
22  T* data();
23  const T* data() const;
24 
25  T* begin();
26  const T* begin() const;
27 
28  T* end();
29  const T* end() const;
30 
31  void zero();
32 
33 private:
34  struct destructor final {
35  void operator()(T* t) const noexcept;
36  };
37 
38  size_t size_;
39  std::unique_ptr<T[], destructor> buf_;
40 };
41 
42 using rbuf = buffer<float>;
43 
44 } // namespace frequency_domain
Definition: buffer.h:8
Definition: buffer.h:5