123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #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 = {}) noexcept(
- std::is_nothrow_move_constructible<metadata_type>::value)
- : 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
|