// Copyright Louis Dionne 2013-2017 // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include namespace hana = boost::hana; // // Make sure that http://stackoverflow.com/q/32702383/627587 works. // auto at = [](auto& map, auto key) -> auto& { return map[key]; }; template auto& traverse(Map& map, Keys const& keys){ return hana::fold_left(keys, map, at); } int main() { auto xs = hana::make_map(hana::make_pair(hana::int_c<0>, hana::make_map(hana::make_pair(hana::int_c<1>, hana::make_map(hana::make_pair(hana::int_c<2>, hana::make_map(hana::make_pair(hana::int_c<3>, 10)))))))); int& i = traverse(xs, hana::range_c); BOOST_HANA_RUNTIME_CHECK(i == 10); i = 99; BOOST_HANA_RUNTIME_CHECK(traverse(xs, hana::range_c) == 99); }