Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/containers/Span.h
/* Copyright (C) 2022 Wildfire Games. | /* Copyright (C) 2023 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public: | ||||
constexpr span(iterator first, iterator last) | constexpr span(iterator first, iterator last) | ||||
: m_Pointer(first), m_Extent(static_cast<size_type>(last - first)) {} | : m_Pointer(first), m_Extent(static_cast<size_type>(last - first)) {} | ||||
template<typename OtherT, size_t N> | template<typename OtherT, size_t N> | ||||
constexpr span(const std::array<OtherT, N>& arr) | constexpr span(const std::array<OtherT, N>& arr) | ||||
: m_Pointer(arr.data()), m_Extent(arr.size()) {} | : m_Pointer(arr.data()), m_Extent(arr.size()) {} | ||||
template<typename ContinuousRange> | |||||
constexpr span(ContinuousRange& range) | |||||
: m_Pointer(range.data()), m_Extent(range.size()) {} | |||||
constexpr span(const span& other) = default; | constexpr span(const span& other) = default; | ||||
constexpr span& operator=(const span& other) = default; | constexpr span& operator=(const span& other) = default; | ||||
~span() = default; | ~span() = default; | ||||
constexpr size_type size() const { return m_Extent; } | constexpr size_type size() const { return m_Extent; } | ||||
constexpr bool empty() const { return size() == 0; } | constexpr bool empty() const { return size() == 0; } | ||||
Show All 19 Lines |
Wildfire Games · Phabricator