26#include "internal/ArrayImpl.h"
27#include "internal/ConfigMacros.h"
65template <
unsigned Dimension,
typename T>
66using ArrayD_t = Internal::MultiDimensionalArray_t<Dimension, T>;
105class Array :
private Internal::ArrayImpl<T> {
108 std::is_same<std::remove_cv_t<T>, T>::value,
109 "Amino::Array must have a non-const, non-volatile value_type");
112 using BaseClass = Internal::ArrayImpl<T>;
153 template <
typename InputIterator>
154 using enable_if_input_iterator_t = std::enable_if_t<std::is_convertible<
155 typename std::iterator_traits<InputIterator>::iterator_category,
156 std::input_iterator_tag>::value>;
160 template <
typename... Args>
161 using enable_if_constructible_t =
162 std::enable_if_t<std::is_constructible<T, Args...>::value>;
168 explicit Array() : BaseClass() { warn_if_unsupported_element<T>(); }
174 warn_if_unsupported_element<T>();
182 warn_if_unsupported_element<T>();
198 typename = enable_if_input_iterator_t<InputIterator>>
199 Array(InputIterator first, InputIterator last) : BaseClass(first, last) {
200 warn_if_unsupported_element<T>();
206 Array(std::initializer_list<value_type> init) : BaseClass(init) {
207 warn_if_unsupported_element<T>();
251 BaseClass::assign(init.begin(), init.end());
267 BaseClass::assign(count, value);
285 typename = enable_if_input_iterator_t<InputIterator>>
286 void assign(InputIterator first, InputIterator last) {
287 BaseClass::assign(first, last);
305 void assign(std::initializer_list<T> init) {
306 BaseClass::assign(init.begin(), init.end());
337 return BaseClass::operator[](n);
412 bool empty() const noexcept {
return BaseClass::empty(); }
455 void clear() noexcept { BaseClass::clear(); }
466 return BaseClass::insert(pos, value);
469 return BaseClass::insert(pos, std::move(value));
484 return BaseClass::insert(pos, count, value);
505 typename = enable_if_input_iterator_t<InputIterator>>
508 return BaseClass::insert(pos, first, last);
522 return BaseClass::insert(pos, init.begin(), init.end());
544 return BaseClass::erase(first, last);
551 BaseClass::push_back(std::move(value));
560 template <
typename... Args,
typename = enable_if_constructible_t<Args...>>
562 BaseClass::emplace_back(std::forward<Args>(args)...);
594 BaseClass::resize(count, value);
618template <Internal::TypeCategory>
620 static inline constexpr void amino_array_of_unsupported_element() {}
623struct MaybeWarn<Internal::TypeCategory::eUninstantiable> {
625 "The element type of this array is not supported in Amino.\n "
626 "All types must be default constructible, copy/move constructible,"
627 "copy/move assignable, and destructible.\n "
628 "Class types wrapped in Amino::Ptr must provide a default getter "
629 "(see Amino/Cpp/ClassDeclare.h and Amino/Cpp/ClassDefine.h).\n "
630 "It won't be type-erased, nor support virtualized operations.")
631 static inline constexpr
void amino_array_of_unsupported_element() {}
637 MaybeWarn<Internal::GetTypeCategory<T>::value>::
638 amino_array_of_unsupported_element();
Forward declaration of Amino Array.
AMINO_INTERNAL_DEPRECATED("Amino::isJobCancelled is deprecated and now always returns false. " "Use a 'StopToken const& jobport instead. ") inline bool isJobCancelled()
constexpr void warn_if_unsupported_element()
Helpers to produce a warning on unsupported element types when constructing Amino::Array of such type...
Internal::MultiDimensionalArray_t< Dimension, T > ArrayD_t
Helper alias for multidimensional array types.
void swap(Any &lhs, Any &rhs) noexcept
Swap the payloads of two instances of Any.
Define a Amino array of elements of type T.
iterator insert(const_iterator pos, const value_type &value)
Inserts value before pos.
reference operator[](size_type n)
Get a reference to the element at position n in the array.
const_iterator begin() const noexcept
Get a iterator pointing to the first element in the array.
const_reference operator[](size_type n) const
Get a reference to the element at position n in the array.
Array< T > & operator=(const Array< T > &other)=default
Copy assignment operator.
reference back()
Get a reference to the last element in the array.
Array()
Construct an empty array.
reference front()
Get a reference to the first element in the array.
typename BaseClass::reference reference
Type to represent a mutable reference to an array element value. Equivalent to value_type&.
void push_back(value_type &&value)
Appends the given element value to the end of the container.
Array(size_type n, const value_type &value)
Construct an array with n elements of value value.
iterator insert(const_iterator pos, value_type &&value)
Inserts value before pos.
void resize(size_type count, const value_type &value)
Resizes the container to contain count elements.
size_type size() const noexcept
Get the number of elements in the array.
~Array()=default
Destroys the array. This calls the destructor for each element, and releases all the storage allocate...
Array(size_type n)
Construct an array with n default initialized elements.
void push_back(const value_type &value)
Appends the given element value to the end of the container.
const_reference back() const
Get a reference to the last element in the array.
Array(std::initializer_list< value_type > init)
Construct an array with the contents of the initializer_list.
const_reference at(size_type n) const
Get a reference to the element at position n in the array.
typename BaseClass::difference_type difference_type
A signed integral type. Usually the same as ptrdiff_t.
const_iterator end() const noexcept
Get a iterator pointing to the element just past the last element in the array (past-the-end element)...
iterator erase(const_iterator first, const_iterator last)
Removes the elements in the range [first,last) from the container.
size_type capacity() const noexcept
Get the number of elements that the container has currently allocated space for.
void reserve(size_type new_capacity)
Increase the capacity of the array to a value that's greater or equal to new_capacity.
typename BaseClass::pointer pointer
Type to represent a mutable pointer to an array element value. Equivalent to value_type*.
typename BaseClass::const_pointer const_pointer
Type to represent a constant pointer to an array element value. Equivalent to value_type const*.
const_iterator cbegin() const noexcept
Get a iterator pointing to the first element in the array.
void emplace_back(Args &&... args)
Appends an element constructed from the given arguments to the end of the container.
Array(Array< T > &&other) noexcept=default
Move constructor.
iterator insert(const_iterator pos, InputIterator first, InputIterator last)
Inserts elements from range [first,last) before pos.
iterator insert(const_iterator pos, std::initializer_list< value_type > init)
inserts elements from initializer list init before pos.
Array(const Array< T > &other)=default
Copy constructor.
void swap(Array &other) noexcept
Exchange the content of the array by the content of other, which is another array object containing e...
size_type max_size() const
Return the maximum number of elements the array is able to hold due to system or library implementati...
typename BaseClass::size_type size_type
An unsigned integral that can represent any non-negative value of difference_type....
typename BaseClass::value_type value_type
The type of the value being stored in the array. Equivalent to T.
Array< T > & operator=(Array< T > &&other) noexcept=default
Move assignment operator.
const_pointer data() const noexcept
Get a pointer to the underlying storage of the array.
void clear() noexcept
Removes all elements from the container.
pointer data() noexcept
Get a pointer to the underlying storage of the array.
Array< T > & operator=(std::initializer_list< value_type > init)
Copy all the elements from init into the current array.
iterator end() noexcept
Get a iterator pointing to the element just past the last element in the array (past-the-end element)...
void shrink_to_fit() noexcept
Requests the removal of unused capacity.
Array(InputIterator first, InputIterator last)
Construct an array with the values in the range [first,last), in the same order.
bool empty() const noexcept
Check whether the array is empty (size() == 0).
void assign(size_type count, const value_type &value)
Replaces the contents of the container with count copies of value value.
typename BaseClass::const_iterator const_iterator
Type representing a random-access iterator to a const value_type.
void pop_back()
Removes the last element of the container.
void assign(std::initializer_list< T > init)
Replaces the contents of the container with the elements from the initializer list init.
const_reference front() const
Get a reference to the first element in the array.
iterator begin() noexcept
Get a iterator pointing to the first element in the array.
void resize(size_type count)
Resizes the container to contain count elements.
reference at(size_type n)
Get a reference to the element at position n in the array.
typename BaseClass::iterator iterator
Type representing a random-access iterator to a value_type.
void assign(InputIterator first, InputIterator last)
Replaces the contents of the container with copies of those in the range [first,last).
const_iterator cend() const noexcept
Get a iterator pointing to the element just past the last element in the array (past-the-end element)...
iterator erase(const_iterator pos)
Removes the element at pos from the container.
iterator insert(const_iterator pos, size_type count, const value_type &value)
Inserts count copies of the value before pos.
typename BaseClass::const_reference const_reference
Type to represent a constant reference to an array element value. Equivalent to value_type const&.