6 #include <boost/any.hpp>
16 class array /* final */
18 array(const array<std::uint8_t>&);
19 array& operator=(const array<std::uint8_t>&);
21 template<typename> friend class array;
29 explicit array(std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage)
32 , cacheable_(cacheable)
33 , storage_(new boost::any(std::forward<T>(storage)))
40 , cacheable_(other.cacheable_)
41 , storage_(std::move(other.storage_))
43 CASPAR_ASSERT(storage_);
48 array& operator=(array&& other)
50 std::swap(ptr_, other.ptr_);
51 std::swap(size_, other.size_);
52 std::swap(storage_, other.storage_);
53 std::swap(cacheable_, other.cacheable_);
55 CASPAR_ASSERT(storage_);
62 T* begin() const {return ptr_;}
63 T* data() const {return ptr_;}
64 T* end() const {return reinterpret_cast<T*>(reinterpret_cast<char*>(ptr_) + size_);}
65 std::size_t size() const {return size_;}
66 bool empty() const {return size() == 0;}
67 bool cacheable() const {return cacheable_;}
72 return boost::any_cast<T>(storage_.get());
78 std::unique_ptr<boost::any> storage_;
82 class array<const T> /* final */
89 array() = default; // Needed by std::future
92 explicit array(const std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage)
95 , cacheable_(cacheable)
96 , storage_(new boost::any(std::forward<T>(storage)))
100 array(const array& other)
103 , cacheable_(other.cacheable_)
104 , storage_(other.storage_)
106 CASPAR_ASSERT(storage_);
109 array(array<T>&& other)
112 , cacheable_(other.cacheable_)
113 , storage_(std::move(other.storage_))
115 CASPAR_ASSERT(storage_);
120 array& operator=(array other)
126 void swap(array& other)
128 std::swap(ptr_, other.ptr_);
129 std::swap(size_, other.size_);
130 std::swap(storage_, other.storage_);
131 std::swap(cacheable_, other.cacheable_);
136 const T* begin() const {return ptr_;}
137 const T* data() const {return ptr_;}
138 const T* end() const {return reinterpret_cast<const T*>(reinterpret_cast<const char*>(ptr_) + size_);}
139 std::size_t size() const {return size_;}
140 bool empty() const {return size() == 0;}
141 bool cacheable() const {return cacheable_;}
146 return boost::any_cast<T>(storage_.get());
153 std::shared_ptr<boost::any> storage_;
161 void swap(caspar::array<const T>& lhs, caspar::array<const T>& rhs)