Files
MapLibreParticleLab/include/mbgl/util/convert.hpp
Bruno de Oliveira Abinader 121b4ca9ca [core] Added mbgl::util::convert helper function
Converts a given std::array into another using a different (convertible)
type.
2016-06-15 18:41:56 +03:00

18 lines
457 B
C++

#include <array>
#include <type_traits>
#include <utility>
namespace mbgl {
namespace util {
template<typename To, typename From, std::size_t Size,
typename = std::enable_if_t<std::is_convertible<From, To>::value>>
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;
}
} // namespace util
} // namespace mbgl