]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | // Copyright 2018 Hans Dembinski |
2 | // | |
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) | |
6 | ||
7 | #ifndef BOOST_HISTOGRAM_TEST_UTILITY_HISTOGRAM_HPP | |
8 | #define BOOST_HISTOGRAM_TEST_UTILITY_HISTOGRAM_HPP | |
9 | ||
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> | |
18 | #include <vector> | |
19 | ||
20 | namespace boost { | |
21 | namespace histogram { | |
22 | ||
f67539c2 | 23 | template <class... Ts> |
92f5a8d4 TL |
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)...}); | |
32 | } | |
33 | ||
20effc67 TL |
34 | struct static_tag : std::false_type {}; |
35 | struct dynamic_tag : std::true_type {}; | |
92f5a8d4 | 36 | |
f67539c2 | 37 | template <class... Axes> |
92f5a8d4 TL |
38 | auto make(static_tag, const Axes&... axes) { |
39 | return make_histogram(axes...); | |
40 | } | |
41 | ||
f67539c2 | 42 | template <class S, class... Axes> |
92f5a8d4 TL |
43 | auto make_s(static_tag, S&& s, const Axes&... axes) { |
44 | return make_histogram_with(s, axes...); | |
45 | } | |
46 | ||
f67539c2 | 47 | template <class... Axes> |
92f5a8d4 TL |
48 | auto make(dynamic_tag, const Axes&... axes) { |
49 | return make_histogram(make_axis_vector(axes...)); | |
50 | } | |
51 | ||
f67539c2 | 52 | template <class S, class... Axes> |
92f5a8d4 TL |
53 | auto make_s(dynamic_tag, S&& s, const Axes&... axes) { |
54 | return make_histogram_with(s, make_axis_vector(axes...)); | |
55 | } | |
56 | ||
57 | } // namespace histogram | |
58 | } // namespace boost | |
59 | ||
60 | #endif |