6 #include <boost/any.hpp>
14 class array /* final */
16 array(const array<std::uint8_t>&);
17 array& operator=(const array<std::uint8_t>&);
19 template<typename> friend class array;
27 explicit array(std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage)
30 , cacheable_(cacheable)
31 , storage_(new boost::any(std::forward<T>(storage)))
38 , cacheable_(other.cacheable_)
39 , storage_(std::move(other.storage_))
41 CASPAR_ASSERT(storage_);
46 array& operator=(array&& other)
48 std::swap(ptr_, other.ptr_);
49 std::swap(size_, other.size_);
50 std::swap(storage_, other.storage_);
51 std::swap(cacheable_, other.cacheable_);
53 CASPAR_ASSERT(storage_);
60 T* begin() const {return ptr_;}
61 T* data() const {return ptr_;}
62 T* end() const {return reinterpret_cast<T*>(reinterpret_cast<char*>(ptr_) + size_);}
63 std::size_t size() const {return size_;}
64 bool empty() const {return size() == 0;}
65 bool cacheable() const {return cacheable_;}
70 return boost::any_cast<T>(storage_.get());
76 std::unique_ptr<boost::any> storage_;
80 class array<const T> /* final */
89 explicit array(const std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage)
92 , cacheable_(cacheable)
93 , storage_(new boost::any(std::forward<T>(storage)))
97 array(const array& other)
100 , cacheable_(other.cacheable_)
101 , storage_(other.storage_)
103 CASPAR_ASSERT(storage_);
106 array(array<T>&& other)
109 , cacheable_(other.cacheable_)
110 , storage_(std::move(other.storage_))
112 CASPAR_ASSERT(storage_);
117 array& operator=(array other)
123 void swap(array& other)
125 std::swap(ptr_, other.ptr_);
126 std::swap(size_, other.size_);
127 std::swap(storage_, other.storage_);
128 std::swap(cacheable_, other.cacheable_);
133 const T* begin() const {return ptr_;}
134 const T* data() const {return ptr_;}
135 const T* end() const {return reinterpret_cast<const T*>(reinterpret_cast<const char*>(ptr_) + size_);}
136 std::size_t size() const {return size_;}
137 bool empty() const {return size() == 0;}
138 bool cacheable() const {return cacheable_;}
143 return boost::any_cast<T>(storage_.get());
150 std::shared_ptr<boost::any> storage_;
158 void swap(caspar::array<const T>& lhs, caspar::array<const T>& rhs)