3 #include "../spl/memory.h"
\r
4 #include "../forward.h"
\r
6 #include <boost/any.hpp>
\r
11 FORWARD1(boost, template<typename> class shared_future);
\r
15 template<typename T>
\r
18 array(const array<std::uint8_t>&);
\r
19 array& operator=(const array<std::uint8_t>&);
\r
21 template<typename> friend class array;
\r
28 template<typename T>
\r
29 explicit array(std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage)
\r
32 , cacheable_(cacheable)
\r
33 , storage_(new boost::any(std::forward<T>(storage)))
\r
37 array(array&& other)
\r
39 , size_(other.size_)
\r
40 , cacheable_(other.cacheable_)
\r
41 , storage_(std::move(other.storage_))
\r
43 CASPAR_ASSERT(storage_);
\r
48 array& operator=(array&& other)
\r
51 size_ = other.size_;
\r
52 cacheable_ = other.cacheable_;
\r
53 storage_ = std::move(other.storage_);
\r
55 CASPAR_ASSERT(storage_);
\r
62 T* begin() const {return ptr_;}
\r
63 T* data() const {return ptr_;}
\r
64 T* end() const {return reinterpret_cast<T*>(reinterpret_cast<char*>(ptr_) + size_);}
\r
65 std::size_t size() const {return size_;}
\r
66 bool empty() const {return size() == 0;}
\r
67 bool cacheable() const {return cacheable_;}
\r
69 template<typename T>
\r
72 return boost::any_cast<T>(*storage_);
\r
78 std::unique_ptr<boost::any> storage_;
\r
81 template<typename T>
\r
82 class array<const T> sealed
\r
90 template<typename T>
\r
91 explicit array(const std::uint8_t* ptr, std::size_t size, bool cacheable, T&& storage)
\r
94 , cacheable_(cacheable)
\r
95 , storage_(new boost::any(std::forward<T>(storage)))
\r
99 array(const array& other)
\r
101 , size_(other.size_)
\r
102 , cacheable_(other.cacheable_)
\r
103 , storage_(other.storage_)
\r
105 CASPAR_ASSERT(storage_);
\r
108 array(array<T>&& other)
\r
110 , size_(other.size_)
\r
111 , cacheable_(other.cacheable_)
\r
112 , storage_(std::move(other.storage_))
\r
114 CASPAR_ASSERT(storage_);
\r
119 array& operator=(array other)
\r
125 void swap(array& other)
\r
128 size_ = other.size_;
\r
129 storage_ = other.storage_;
\r
130 cacheable_ = other.cacheable_;
\r
135 const T* begin() const {return ptr_;}
\r
136 const T* data() const {return ptr_;}
\r
137 const T* end() const {return reinterpret_cast<const T*>(reinterpret_cast<const char*>(ptr_) + size_);}
\r
138 std::size_t size() const {return size_;}
\r
139 bool empty() const {return size() == 0;}
\r
140 bool cacheable() const {return cacheable_;}
\r
142 template<typename T>
\r
145 return boost::any_cast<T>(*storage_);
\r
152 std::shared_ptr<boost::any> storage_;
\r
159 template<typename T>
\r
160 void swap(caspar::array<const T>& lhs, caspar::array<const T>& rhs)
\r