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