]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/core/convert/embedding.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / core / convert / embedding.cpp
1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/core/to.hpp>
7 #include <boost/hana/core/when.hpp>
8
9 #include <vector>
10 namespace hana = boost::hana;
11
12
13 namespace boost { namespace hana {
14 template <typename To, typename From>
15 struct to_impl<std::vector<To>, std::vector<From>,
16 when<is_convertible<From, To>::value>>
17 : embedding<is_embedded<From, To>::value>
18 {
19 static std::vector<To> apply(std::vector<From> const& xs) {
20 std::vector<To> result;
21 for (auto const& x: xs)
22 result.push_back(to<To>(x));
23 return result;
24 }
25 };
26 }}
27
28 int main() {
29 BOOST_HANA_RUNTIME_CHECK(
30 hana::to<std::vector<int>>(std::vector<float>{1.1, 2.2, 3.3})
31 ==
32 std::vector<int>{1, 2, 3}
33 );
34
35 static_assert(!hana::is_embedded<std::vector<float>, std::vector<int>>{}, "");
36 }