]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/lazy/comonad.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / lazy / comonad.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/eval.hpp>
7 #include <boost/hana/extend.hpp>
8 #include <boost/hana/extract.hpp>
9 #include <boost/hana/lazy.hpp>
10
11 #include <sstream>
12 namespace hana = boost::hana;
13
14
15 int main() {
16 std::stringstream s("1 2 3");
17 auto i = hana::make_lazy([&] {
18 int i;
19 s >> i;
20 return i;
21 })();
22
23 auto i_plus_one = hana::extend(i, [](auto lazy_int) {
24 return hana::eval(lazy_int) + 1;
25 });
26
27 BOOST_HANA_RUNTIME_CHECK(hana::extract(i_plus_one) == 2);
28 BOOST_HANA_RUNTIME_CHECK(hana::extract(i_plus_one) == 3);
29 BOOST_HANA_RUNTIME_CHECK(hana::extract(i_plus_one) == 4);
30 }