summaryrefslogtreecommitdiff
path: root/include/mbgl/util/convert.hpp
blob: 02ec7feef97a3082c33dc79b5e12ddcd73d10f42 (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