1// Copyright Louis Dionne 2013-2022
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/ext/std/integer_sequence.hpp>
7#include <boost/hana/unpack.hpp>
8
9#include <tuple>
10#include <utility>
11namespace hana = boost::hana;
12
13
14auto add = [](auto a, auto b, auto c) { return a + b + c; };
15
16int main() {
17 std::tuple<int, long, double> tuple{1, 2l, 3.3};
18
19 auto sum = hana::unpack(std::integer_sequence<int, 0, 1, 2>{}, [&](auto ...i) {
20 // the `i`s are `std::integral_constant<int, ...>`s
21 return add(std::get<decltype(i)::value>(tuple)...);
22 });
23
24 BOOST_HANA_RUNTIME_CHECK(sum == 6.3);
25}
26

source code of boost/libs/hana/example/ext/std/integer_sequence/foldable.cpp