1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #ifndef BOOST_HISTOGRAM_AXIS_BOOLEAN_HPP
- #define BOOST_HISTOGRAM_AXIS_BOOLEAN_HPP
- #include <boost/core/nvp.hpp>
- #include <boost/histogram/axis/iterator.hpp>
- #include <boost/histogram/axis/metadata_base.hpp>
- #include <boost/histogram/axis/option.hpp>
- #include <boost/histogram/detail/relaxed_equal.hpp>
- #include <boost/histogram/detail/replace_type.hpp>
- #include <boost/histogram/fwd.hpp>
- #include <string>
- namespace boost {
- namespace histogram {
- namespace axis {
- template <class MetaData>
- class boolean : public iterator_mixin<boolean<MetaData>>,
- public metadata_base_t<MetaData> {
- using value_type = bool;
- using metadata_base = metadata_base_t<MetaData>;
- using metadata_type = typename metadata_base::metadata_type;
- public:
-
- explicit boolean(metadata_type meta = {}) : metadata_base(std::move(meta)) {}
-
- index_type index(value_type x) const noexcept { return static_cast<index_type>(x); }
-
- value_type value(index_type i) const noexcept { return static_cast<value_type>(i); }
-
- value_type bin(index_type i) const noexcept { return value(i); }
-
- index_type size() const noexcept { return 2; }
-
- static constexpr bool inclusive() noexcept { return true; }
-
- static constexpr unsigned options() noexcept { return option::none_t::value; }
- template <class M>
- bool operator==(const boolean<M>& o) const noexcept {
- return detail::relaxed_equal{}(this->metadata(), o.metadata());
- }
- template <class M>
- bool operator!=(const boolean<M>& o) const noexcept {
- return !operator==(o);
- }
- template <class Archive>
- void serialize(Archive& ar, unsigned /* version */) {
- ar& make_nvp("meta", this->metadata());
- }
- private:
- template <class M>
- friend class boolean;
- };
- #if __cpp_deduction_guides >= 201606
- boolean()->boolean<null_type>;
- template <class M>
- boolean(M) -> boolean<detail::replace_type<std::decay_t<M>, const char*, std::string>>;
- #endif
- }
- }
- }
- #endif
|