Files
MapLibreParticleLab/include/mbgl/util/convert.hpp
Tim Sylvester 82ec59a2b0 Metal setup merge (#1616)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Alex Cristici <alex.cristici@gmail.com>
Co-authored-by: mwilsnd <mwilsnd@gmail.com>
Co-authored-by: Stefan Karschti <stefan.karschti@gmail.com>
Co-authored-by: Bart Louwers <bart@emeel.net>
Co-authored-by: Alex Cristici <alex@skoon.energy>
Co-authored-by: Bart Louwers <bart.louwers@gmail.com>
Co-authored-by: Wei Chen <alanchenboy@gmail.com>
Co-authored-by: Siarhei Fedartsou <siarhei.fedartsou@gmail.com>
Co-authored-by: tdcosta100 <tdcosta100@gmail.com>
2023-09-13 18:35:20 +00:00

29 lines
878 B
C++

#pragma once
#include <mbgl/util/util.hpp>
#include <algorithm>
#include <array>
#include <cstddef>
#include <type_traits>
namespace mbgl {
namespace util {
template <typename To, typename From, std::size_t Size, typename = std::enable_if_t<std::is_convertible_v<From, To>>>
MBGL_CONSTEXPR std::array<To, Size> convert(const std::array<From, Size>& from) {
std::array<To, Size> to{{}};
std::copy(std::begin(from), std::end(from), std::begin(to));
return to;
}
template <typename To, typename From, std::size_t Size, typename = std::enable_if_t<std::is_assignable_v<To&, From>>>
MBGL_CONSTEXPR std::array<To, Size> cast(const std::array<From, Size>& from) {
std::array<To, Size> to{{}};
std::transform(std::begin(from), std::end(from), std::begin(to), [](From x) { return static_cast<To>(x); });
return to;
}
} // namespace util
} // namespace mbgl