1 // Copyright 2018 Hans Dembinski
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_HISTOGRAM_TEST_UTILITY_HISTOGRAM_HPP
8 #define BOOST_HISTOGRAM_TEST_UTILITY_HISTOGRAM_HPP
10 #include <boost/histogram/axis/category.hpp>
11 #include <boost/histogram/axis/integer.hpp>
12 #include <boost/histogram/axis/regular.hpp>
13 #include <boost/histogram/axis/variable.hpp>
14 #include <boost/histogram/axis/variant.hpp>
15 #include <boost/histogram/make_histogram.hpp>
16 #include <boost/mp11/algorithm.hpp>
17 #include <type_traits>
23 template <class... Ts>
24 auto make_axis_vector(const Ts&... ts) {
25 // make sure the variant is never trivial (contains only one type)
26 using R = axis::regular<double, boost::use_default, axis::null_type>;
27 using I = axis::integer<int, axis::null_type, axis::option::none_t>;
28 using V = axis::variable<double, axis::null_type>;
29 using C = axis::category<int, axis::null_type>;
30 using Var = boost::mp11::mp_unique<axis::variant<Ts..., R, I, V, C>>;
31 return std::vector<Var>({Var(ts)...});
34 struct static_tag : std::false_type {};
35 struct dynamic_tag : std::true_type {};
37 template <class... Axes>
38 auto make(static_tag, const Axes&... axes) {
39 return make_histogram(axes...);
42 template <class S, class... Axes>
43 auto make_s(static_tag, S&& s, const Axes&... axes) {
44 return make_histogram_with(s, axes...);
47 template <class... Axes>
48 auto make(dynamic_tag, const Axes&... axes) {
49 return make_histogram(make_axis_vector(axes...));
52 template <class S, class... Axes>
53 auto make_s(dynamic_tag, S&& s, const Axes&... axes) {
54 return make_histogram_with(s, make_axis_vector(axes...));
57 } // namespace histogram