You can define your custom_array, which is inherited from standard std::array.
template<typename _T, size_t _size>
class custom_array : public std::array<_T, _size> {
public:
custom_array(std::array<_T, _size> arr,
size_t start,
size_t end) {
size_t itr = 0;
while (itr < this->size() &&
start < arr.size() &&
start <= end) {
this->_Elems[itr++] = arr[start++];
}
}
custom_array(std::array<_T, _size>::iterator start,
std::array<_T, _size>::iterator end) {
size_t itr = 0;
while (itr < this->size()) {
this->_Elems[itr++] = *start;
start++;
if (start == end) { break; }
}
}
};
Then you can declare your custom_array as you wish, example:
std::array<int, 4> arr = { 1, 2, 3, 4 };
custom_array<int, 4> arr_1(a, 0, 4);
custom_array<int, 4> arr_2(a.begin(), a.end());