]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/struct/foldable.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / struct / foldable.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/define_struct.hpp>
7 #include <boost/hana/fold_left.hpp>
8 #include <boost/hana/second.hpp>
9 namespace hana = boost::hana;
10
11
12 struct Classroom {
13 BOOST_HANA_DEFINE_STRUCT(Classroom,
14 (unsigned short, boys),
15 (unsigned short, girls)
16 );
17 };
18
19 int main() {
20 constexpr Classroom compsci{20, 3};
21
22 BOOST_HANA_CONSTEXPR_CHECK(
23 hana::fold_left(compsci, 0, [](auto total, auto member) {
24 // first(member) is the name of the member, here
25 // "boys" or "girls", and second(member) is its value.
26 return hana::second(member) + total;
27 }) == 23
28 );
29 }