namespace histogram {
namespace axis {
-/**
- Maps at a set of unique values to bin indices.
-
- The axis maps a set of values to bins, following the order of arguments in the
- constructor. The optional overflow bin for this axis counts input values that
- are not part of the set. Binning has O(N) complexity, but with a very small
- factor. For small N (the typical use case) it beats other kinds of lookup.
-
- @tparam Value input value type, must be equal-comparable.
- @tparam MetaData type to store meta data.
- @tparam Options see boost::histogram::axis::option.
- @tparam Allocator allocator to use for dynamic memory management.
-
- The options `underflow` and `circular` are not allowed. The options `growth`
- and `overflow` are mutually exclusive.
-*/
+/** Maps at a set of unique values to bin indices.
+
+ The axis maps a set of values to bins, following the order of arguments in the
+ constructor. The optional overflow bin for this axis counts input values that
+ are not part of the set. Binning has O(N) complexity, but with a very small
+ factor. For small N (the typical use case) it beats other kinds of lookup.
+
+ @tparam Value input value type, must be equal-comparable.
+ @tparam MetaData type to store meta data.
+ @tparam Options see boost::histogram::axis::option.
+ @tparam Allocator allocator to use for dynamic memory management.
+
+ The options `underflow` and `circular` are not allowed. The options `growth`
+ and `overflow` are mutually exclusive.
+ */
template <class Value, class MetaData, class Options, class Allocator>
class category : public iterator_mixin<category<Value, MetaData, Options, Allocator>>,
public metadata_base_t<MetaData> {
explicit category(allocator_type alloc) : vec_(alloc) {}
/** Construct from iterator range of unique values.
- *
- * \param begin begin of category range of unique values.
- * \param end end of category range of unique values.
- * \param meta description of the axis.
- * \param alloc allocator instance to use.
+
+ @param begin begin of category range of unique values.
+ @param end end of category range of unique values.
+ @param meta description of the axis (optional).
+ @param options see boost::histogram::axis::option (optional).
+ @param alloc allocator instance to use (optional).
*/
template <class It, class = detail::requires_iterator<It>>
- category(It begin, It end, metadata_type meta = {}, allocator_type alloc = {})
+ category(It begin, It end, metadata_type meta = {}, options_type options = {},
+ allocator_type alloc = {})
: metadata_base(std::move(meta)), vec_(alloc) {
+ (void)options;
if (std::distance(begin, end) < 0)
BOOST_THROW_EXCEPTION(
std::invalid_argument("end must be reachable by incrementing begin"));
while (begin != end) vec_.emplace_back(*begin++);
}
+ // kept for backward compatibility
+ template <class It, class = detail::requires_iterator<It>>
+ category(It begin, It end, metadata_type meta, allocator_type alloc)
+ : category(begin, end, std::move(meta), {}, std::move(alloc)) {}
+
/** Construct axis from iterable sequence of unique values.
- *
- * \param iterable sequence of unique values.
- * \param meta description of the axis.
- * \param alloc allocator instance to use.
+
+ @param iterable sequence of unique values.
+ @param meta description of the axis.
+ @param options see boost::histogram::axis::option (optional).
+ @param alloc allocator instance to use.
*/
template <class C, class = detail::requires_iterable<C>>
- category(const C& iterable, metadata_type meta = {}, allocator_type alloc = {})
- : category(std::begin(iterable), std::end(iterable), std::move(meta),
+ category(const C& iterable, metadata_type meta = {}, options_type options = {},
+ allocator_type alloc = {})
+ : category(std::begin(iterable), std::end(iterable), std::move(meta), options,
+ std::move(alloc)) {}
+
+ // kept for backward compatibility
+ template <class C, class = detail::requires_iterable<C>>
+ category(const C& iterable, metadata_type meta, allocator_type alloc)
+ : category(std::begin(iterable), std::end(iterable), std::move(meta), {},
std::move(alloc)) {}
/** Construct axis from an initializer list of unique values.
- *
- * \param list `std::initializer_list` of unique values.
- * \param meta description of the axis.
- * \param alloc allocator instance to use.
+
+ @param list `std::initializer_list` of unique values.
+ @param meta description of the axis.
+ @param options see boost::histogram::axis::option (optional).
+ @param alloc allocator instance to use.
*/
template <class U>
category(std::initializer_list<U> list, metadata_type meta = {},
- allocator_type alloc = {})
- : category(list.begin(), list.end(), std::move(meta), std::move(alloc)) {}
+ options_type options = {}, allocator_type alloc = {})
+ : category(list.begin(), list.end(), std::move(meta), options, std::move(alloc)) {}
+
+ // kept for backward compatibility
+ template <class U>
+ category(std::initializer_list<U> list, metadata_type meta, allocator_type alloc)
+ : category(list.begin(), list.end(), std::move(meta), {}, std::move(alloc)) {}
/// Constructor used by algorithm::reduce to shrink and rebin (not for users).
category(const category& src, index_type begin, index_type end, unsigned merge)
// LCOV_EXCL_START: gcc-8 is missing the delegated ctor for no reason
- : category(src.vec_.begin() + begin, src.vec_.begin() + end, src.metadata(),
+ : category(src.vec_.begin() + begin, src.vec_.begin() + end, src.metadata(), {},
src.get_allocator())
// LCOV_EXCL_STOP
{
template <class T>
category(std::initializer_list<T>)
- ->category<detail::replace_cstring<std::decay_t<T>>, null_type>;
+ -> category<detail::replace_cstring<std::decay_t<T>>, null_type>;
template <class T, class M>
category(std::initializer_list<T>, M)
- ->category<detail::replace_cstring<std::decay_t<T>>,
- detail::replace_cstring<std::decay_t<M>>>;
+ -> category<detail::replace_cstring<std::decay_t<T>>,
+ detail::replace_cstring<std::decay_t<M>>>;
+
+template <class T, class M, unsigned B>
+category(std::initializer_list<T>, M, const option::bitset<B>&)
+ -> category<detail::replace_cstring<std::decay_t<T>>,
+ detail::replace_cstring<std::decay_t<M>>, option::bitset<B>>;
#endif