]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/histogram/axis/option.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / histogram / axis / option.hpp
CommitLineData
92f5a8d4
TL
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
19namespace boost {
20namespace histogram {
21namespace axis {
22namespace option {
23
24/// Holder of axis options.
25template <unsigned Bits>
26struct bitset : std::integral_constant<unsigned, Bits> {
20effc67 27
92f5a8d4
TL
28 /// Returns true if all option flags in the argument are set and false otherwise.
29 template <unsigned B>
30 static constexpr auto test(bitset<B>) {
20effc67
TL
31 // B + 0 needed to avoid false positive -Wtautological-compare in gcc-6
32 return std::integral_constant<bool, static_cast<bool>((Bits & B) == (B + 0))>{};
92f5a8d4
TL
33 }
34};
35
36/// Set union of the axis option arguments.
37template <unsigned B1, unsigned B2>
38constexpr auto operator|(bitset<B1>, bitset<B2>) {
39 return bitset<(B1 | B2)>{};
40}
41
42/// Set intersection of the option arguments.
43template <unsigned B1, unsigned B2>
44constexpr auto operator&(bitset<B1>, bitset<B2>) {
45 return bitset<(B1 & B2)>{};
46}
47
48/// Set difference of the option arguments.
49template <unsigned B1, unsigned B2>
50constexpr auto operator-(bitset<B1>, bitset<B2>) {
51 return bitset<(B1 & ~B2)>{};
52}
53
54/**
55 Single option flag.
56
57 @tparam Pos position of the bit in the set.
58*/
59template <unsigned Pos>
1e59de90
TL
60#ifndef BOOST_HISTOGRAM_DOXYGEN_INVOKED
61using bit = bitset<(1 << Pos)>;
62#else
63struct bit;
64#endif
92f5a8d4
TL
65
66/// All options off.
67using none_t = bitset<0>;
92f5a8d4
TL
68/// Axis has an underflow bin. Mutually exclusive with `circular`.
69using underflow_t = bit<0>;
92f5a8d4
TL
70/// Axis has overflow bin.
71using overflow_t = bit<1>;
92f5a8d4
TL
72/// Axis is circular. Mutually exclusive with `growth` and `underflow`.
73using circular_t = bit<2>;
92f5a8d4
TL
74/// Axis can grow. Mutually exclusive with `circular`.
75using growth_t = bit<3>;
20effc67
TL
76
77constexpr none_t none{}; ///< Instance of `none_t`.
78constexpr underflow_t underflow{}; ///< Instance of `underflow_t`.
79constexpr overflow_t overflow{}; ///< Instance of `overflow_t`.
80constexpr circular_t circular{}; ///< Instance of `circular_t`.
81constexpr growth_t growth{}; ///< Instance of `growth_t`.
92f5a8d4
TL
82
83} // namespace option
84} // namespace axis
85} // namespace histogram
86} // namespace boost
87
88#endif