]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/struct/foldable.cpp
1 // Copyright Louis Dionne 2013-2016
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/define_struct.hpp>
7 #include <boost/hana/fold_left.hpp>
8 #include <boost/hana/second.hpp>
9 namespace hana
= boost::hana
;
13 BOOST_HANA_DEFINE_STRUCT(Classroom
,
14 (unsigned short, boys
),
15 (unsigned short, girls
)
20 constexpr Classroom compsci
{20, 3};
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
;