]>
git.proxmox.com Git - ceph.git/blob - 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)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/core/to.hpp>
7 #include <boost/hana/core/when.hpp>
10 namespace hana
= boost::hana
;
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
>
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
));
29 BOOST_HANA_RUNTIME_CHECK(
30 hana::to
<std::vector
<int>>(std::vector
<float>{1.1, 2.2, 3.3})
32 std::vector
<int>{1, 2, 3}
35 static_assert(!hana::is_embedded
<std::vector
<float>, std::vector
<int>>{}, "");