]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/struct/foldable.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / hana / example / struct / foldable.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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/define_struct.hpp>
7#include <boost/hana/fold_left.hpp>
8#include <boost/hana/second.hpp>
9namespace hana = boost::hana;
10
11
92f5a8d4
TL
12struct Kitten {
13 BOOST_HANA_DEFINE_STRUCT(Kitten,
14 (int, extremely_cute),
15 (int, cute),
16 (int, not_so_cute)
7c673cae
FG
17 );
18};
19
20int main() {
92f5a8d4 21 constexpr Kitten kitten{5, 10, 0};
7c673cae
FG
22
23 BOOST_HANA_CONSTEXPR_CHECK(
92f5a8d4 24 hana::fold_left(kitten, 0, [](auto total, auto member) {
7c673cae 25 // first(member) is the name of the member, here
92f5a8d4
TL
26 // "extremely_cute", or "cute" or "not_so_cute",
27 // and second(member) is its value.
7c673cae 28 return hana::second(member) + total;
92f5a8d4 29 }) == (5 + 10 + 0)
7c673cae
FG
30 );
31}