summaryrefslogtreecommitdiff
path: root/include/mbgl/util/convert.hpp
blob: bedb1a4a08ffa25bfab7ce9a07f028df263f9f68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <mbgl/util/util.hpp>

#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>>
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;
}

} // namespace util
} // namespace mbgl