From 121b4ca9ca0fdf4d46c296ffc0372beca80b1cb6 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Wed, 15 Jun 2016 16:33:14 +0300 Subject: [core] Added mbgl::util::convert helper function Converts a given std::array into another using a different (convertible) type. --- include/mbgl/util/convert.hpp | 17 +++++++++++++++++ src/mbgl/util/convert.cpp | 9 +++++++++ 2 files changed, 26 insertions(+) create mode 100644 include/mbgl/util/convert.hpp create mode 100644 src/mbgl/util/convert.cpp diff --git a/include/mbgl/util/convert.hpp b/include/mbgl/util/convert.hpp new file mode 100644 index 0000000000..c2b3d9950d --- /dev/null +++ b/include/mbgl/util/convert.hpp @@ -0,0 +1,17 @@ +#include +#include +#include + +namespace mbgl { +namespace util { + +template::value>> +constexpr std::array convert(const std::array&from) { + std::array to {}; + std::copy(std::begin(from), std::end(from), std::begin(to)); + return to; +} + +} // namespace util +} // namespace mbgl diff --git a/src/mbgl/util/convert.cpp b/src/mbgl/util/convert.cpp new file mode 100644 index 0000000000..97bfe9108d --- /dev/null +++ b/src/mbgl/util/convert.cpp @@ -0,0 +1,9 @@ +#include + +namespace mbgl { +namespace util { + +template std::array convert(const std::array&); + +} // namespace util +} // namespace mbgl -- cgit v1.2.1