]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/histogram/axis/option.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / histogram / axis / option.hpp
1 // Copyright 2015-2019 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_AXIS_OPTION_HPP
8 #define BOOST_HISTOGRAM_AXIS_OPTION_HPP
9
10 #include <type_traits>
11
12 /**
13 \file option.hpp Options for builtin axis types.
14
15 Options `circular` and `growth` are mutually exclusive.
16 Options `circular` and `underflow` are mutually exclusive.
17 */
18
19 namespace boost {
20 namespace histogram {
21 namespace axis {
22 namespace option {
23
24 /// Holder of axis options.
25 template <unsigned Bits>
26 struct bitset : std::integral_constant<unsigned, Bits> {
27 /// Returns true if all option flags in the argument are set and false otherwise.
28 template <unsigned B>
29 static constexpr auto test(bitset<B>) {
30 return std::integral_constant<bool, static_cast<bool>((Bits & B) == B)>{};
31 }
32 };
33
34 /// Set union of the axis option arguments.
35 template <unsigned B1, unsigned B2>
36 constexpr auto operator|(bitset<B1>, bitset<B2>) {
37 return bitset<(B1 | B2)>{};
38 }
39
40 /// Set intersection of the option arguments.
41 template <unsigned B1, unsigned B2>
42 constexpr auto operator&(bitset<B1>, bitset<B2>) {
43 return bitset<(B1 & B2)>{};
44 }
45
46 /// Set difference of the option arguments.
47 template <unsigned B1, unsigned B2>
48 constexpr auto operator-(bitset<B1>, bitset<B2>) {
49 return bitset<(B1 & ~B2)>{};
50 }
51
52 /**
53 Single option flag.
54
55 @tparam Pos position of the bit in the set.
56 */
57 template <unsigned Pos>
58 struct bit : bitset<(1 << Pos)> {};
59
60 /// All options off.
61 using none_t = bitset<0>;
62 constexpr none_t none{}; ///< Instance of `none_t`.
63 /// Axis has an underflow bin. Mutually exclusive with `circular`.
64 using underflow_t = bit<0>;
65 constexpr underflow_t underflow{}; ///< Instance of `underflow_t`.
66 /// Axis has overflow bin.
67 using overflow_t = bit<1>;
68 constexpr overflow_t overflow{}; ///< Instance of `overflow_t`.
69 /// Axis is circular. Mutually exclusive with `growth` and `underflow`.
70 using circular_t = bit<2>;
71 constexpr circular_t circular{}; ///< Instance of `circular_t`.
72 /// Axis can grow. Mutually exclusive with `circular`.
73 using growth_t = bit<3>;
74 constexpr growth_t growth{}; ///< Instance of `growth_t`.
75
76 } // namespace option
77 } // namespace axis
78 } // namespace histogram
79 } // namespace boost
80
81 #endif