| 47 | /// \see \ref vector "vector<T>" |
| 48 | template<class T, std::size_t N> |
| 49 | class array |
| 50 | { |
| 51 | public: |
| 52 | typedef T value_type; |
| 53 | typedef std::size_t size_type; |
| 54 | typedef ptrdiff_t difference_type; |
| 55 | typedef detail::buffer_value<T> reference; |
| 56 | typedef const detail::buffer_value<T> const_reference; |
| 57 | typedef T* pointer; |
| 58 | typedef const T* const_pointer; |
| 59 | typedef buffer_iterator<T> iterator; |
| 60 | typedef buffer_iterator<T> const_iterator; |
| 61 | typedef std::reverse_iterator<iterator> reverse_iterator; |
| 62 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; |
| 63 | |
| 64 | enum { |
| 65 | static_size = N |
| 66 | }; |
| 67 | |
| 68 | explicit array(const context &context = system::default_context()) |
| 69 | : m_buffer(context, sizeof(T) * N) |
| 70 | { |
| 71 | } |
| 72 | |
| 73 | array(const array<T, N> &other) |
| 74 | : m_buffer(other.m_buffer.get_context(), sizeof(T) * N) |
| 75 | { |
| 76 | boost::compute::copy(other.begin(), other.end(), begin()); |
| 77 | } |
| 78 | |
| 79 | array(const boost::array<T, N> &array, |
| 80 | const context &context = system::default_context()) |
| 81 | : m_buffer(context, sizeof(T) * N) |
| 82 | { |
| 83 | boost::compute::copy(array.begin(), array.end(), begin()); |
| 84 | } |
| 85 | |
| 86 | array<T, N>& operator=(const array<T, N> &other) |
| 87 | { |
| 88 | if(this != &other){ |
| 89 | boost::compute::copy(other.begin(), other.end(), begin()); |
| 90 | } |
| 91 | |
| 92 | return *this; |
| 93 | } |
| 94 | |
| 95 | array<T, N>& operator=(const boost::array<T, N> &array) |
| 96 | { |
| 97 | boost::compute::copy(array.begin(), array.end(), begin()); |
| 98 | |
| 99 | return *this; |
| 100 | } |
| 101 | |
| 102 | ~array() |
| 103 | { |
| 104 | } |
| 105 | |
| 106 | iterator begin() |