104 lines
3.2 KiB
C++
104 lines
3.2 KiB
C++
// =====================================================================================================================
|
|
// fennec, a free and open source game engine
|
|
// Copyright © 2025 Medusa Slockbower
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
// =====================================================================================================================
|
|
|
|
///
|
|
/// \file ranges.h
|
|
/// \brief
|
|
///
|
|
///
|
|
/// \details
|
|
/// \author Medusa Slockbower
|
|
///
|
|
/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html))
|
|
///
|
|
///
|
|
|
|
#ifndef FENNEC_LANG_RANGES_H
|
|
#define FENNEC_LANG_RANGES_H
|
|
|
|
#include <fennec/lang/types.h>
|
|
|
|
namespace fennec
|
|
{
|
|
|
|
///
|
|
/// \brief C++ Iterator Specification `begin()`
|
|
/// \tparam ContainerT the container type
|
|
/// \param c the container to iterate on
|
|
/// \returns an iterator at the start of the container
|
|
template<typename ContainerT>
|
|
inline constexpr auto begin(ContainerT& c) noexcept(noexcept(c.begin())) -> decltype(c.begin()) {
|
|
return c.begin();
|
|
}
|
|
|
|
///
|
|
/// \brief C++ Iterator Specification `begin()`
|
|
/// \tparam ContainerT the container type
|
|
/// \param c the container to iterate on
|
|
/// \returns an iterator at the start of the container
|
|
template<typename ContainerT>
|
|
inline constexpr auto begin(const ContainerT& c) noexcept(noexcept(c.begin())) -> decltype(c.begin()) {
|
|
return c.begin();
|
|
}
|
|
|
|
///
|
|
/// \brief C++ Iterator Specification `begin()`
|
|
/// \tparam T the element type
|
|
/// \tparam N the bounds of the array
|
|
/// \param arr a bounded array to iterate on
|
|
/// \returns an iterator at the start of the array
|
|
template<typename T, size_t N>
|
|
inline constexpr T* begin(T (&arr)[N]) noexcept {
|
|
return arr;
|
|
}
|
|
|
|
|
|
///
|
|
/// \brief C++ Iterator Specification `end()`
|
|
/// \tparam ContainerT the container type
|
|
/// \param c the container to iterate on
|
|
/// \returns an iterator at the end of the container
|
|
template<typename ContainerT>
|
|
inline constexpr auto end(ContainerT& c) noexcept(noexcept(c.end())) -> decltype(c.end()) {
|
|
return c.end();
|
|
}
|
|
|
|
///
|
|
/// \brief C++ Iterator Specification `end()`
|
|
/// \tparam ContainerT the container type
|
|
/// \param c the container to iterate on
|
|
/// \returns an iterator at the end of the container
|
|
template<typename ContainerT>
|
|
inline constexpr auto end(const ContainerT& c) noexcept(noexcept(c.end())) -> decltype(c.end()) {
|
|
return c.end();
|
|
}
|
|
|
|
///
|
|
/// \brief C++ Iterator Specification `end()`
|
|
/// \tparam T the element type
|
|
/// \tparam N the bounds of the array
|
|
/// \param arr a bounded array to iterate on
|
|
/// \returns an iterator at the end of the array
|
|
template<typename T, size_t N>
|
|
inline constexpr T* end(T (&arr)[N]) noexcept {
|
|
return arr + N;
|
|
}
|
|
|
|
}
|
|
|
|
#endif // FENNEC_LANG_RANGES_H
|