// Copyright 2015-2018 Hans Dembinski // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_HISTOGRAM_DETAIL_AT_HPP #define BOOST_HISTOGRAM_DETAIL_AT_HPP #include #include #include #include #include #include #include namespace boost { namespace histogram { namespace detail { template optional_index at(const A& axes, const std::tuple& args) noexcept { optional_index idx{0}; // offset not used by linearize_index mp11::mp_for_each>( [&, stride = static_cast(1)](auto i) mutable { stride *= linearize_index(idx, stride, axis_get(axes), static_cast(std::get(args))); }); return idx; } template optional_index at(const A& axes, const U& args) noexcept { optional_index idx{0}; using std::begin; for_each_axis(axes, [&, it = begin(args), stride = static_cast(1)](const auto& a) mutable { stride *= linearize_index(idx, stride, a, static_cast(*it++)); }); return idx; } } // namespace detail } // namespace histogram } // namespace boost #endif