/usr/include/boost/histogram
Edit: /usr/include/boost/histogram/make_histogram.hpp (5297B)
// Copyright 2015-2018 Hans Dembinski
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_HISTOGRAM_MAKE_HISTOGRAM_HPP
#define BOOST_HISTOGRAM_MAKE_HISTOGRAM_HPP
/**
\file boost/histogram/make_histogram.hpp
Collection of factory functions to conveniently create histograms.
*/
#include
#include
#include
#include
#include // = default_storage
#include
#include
#include
namespace boost {
namespace histogram {
/**
Make histogram from compile-time axis configuration and custom storage.
@param storage Storage or container with standard interface (any vector, array, or map).
@param axis First axis instance.
@param axes Other axis instances.
*/
template ,
class = detail::requires_axis>
auto make_histogram_with(Storage&& storage, Axis&& axis, Axes&&... axes) {
auto a = std::make_tuple(std::forward(axis), std::forward(axes)...);
using U = std::decay_t;
using S = mp11::mp_if, U, storage_adaptor>;
return histogram(std::move(a), S(std::forward(storage)));
}
/**
Make histogram from compile-time axis configuration and default storage.
@param axis First axis instance.
@param axes Other axis instances.
*/
template >
auto make_histogram(Axis&& axis, Axes&&... axes) {
return make_histogram_with(default_storage(), std::forward(axis),
std::forward(axes)...);
}
/**
Make histogram from compile-time axis configuration and weight-counting storage.
@param axis First axis instance.
@param axes Other axis instances.
*/
template >
auto make_weighted_histogram(Axis&& axis, Axes&&... axes) {
return make_histogram_with(weight_storage(), std::forward(axis),
std::forward(axes)...);
}
/**
Make histogram from iterable range and custom storage.
@param storage Storage or container with standard interface (any vector, array, or map).
@param iterable Iterable range of axis objects.
*/
template ,
class = detail::requires_sequence_of_any_axis>
auto make_histogram_with(Storage&& storage, Iterable&& iterable) {
using U = std::decay_t;
using S = mp11::mp_if, U, storage_adaptor>;
using It = std::decay_t;
using A = mp11::mp_if, It,
std::vector>>;
return histogram(std::forward(iterable),
S(std::forward(storage)));
}
/**
Make histogram from iterable range and default storage.
@param iterable Iterable range of axis objects.
*/
template >
auto make_histogram(Iterable&& iterable) {
return make_histogram_with(default_storage(), std::forward(iterable));
}
/**
Make histogram from iterable range and weight-counting storage.
@param iterable Iterable range of axis objects.
*/
template >
auto make_weighted_histogram(Iterable&& iterable) {
return make_histogram_with(weight_storage(), std::forward(iterable));
}
/**
Make histogram from iterator interval and custom storage.
@param storage Storage or container with standard interface (any vector, array, or map).
@param begin Iterator to range of axis objects.
@param end Iterator to range of axis objects.
*/
template ,
class = detail::requires_iterator>
auto make_histogram_with(Storage&& storage, Iterator begin, Iterator end) {
using T = std::decay_t;
return make_histogram_with(std::forward(storage), std::vector(begin, end));
}
/**
Make histogram from iterator interval and default storage.
@param begin Iterator to range of axis objects.
@param end Iterator to range of axis objects.
*/
template >
auto make_histogram(Iterator begin, Iterator end) {
return make_histogram_with(default_storage(), begin, end);
}
/**
Make histogram from iterator interval and weight-counting storage.
@param begin Iterator to range of axis objects.
@param end Iterator to range of axis objects.
*/
template >
auto make_weighted_histogram(Iterator begin, Iterator end) {
return make_histogram_with(weight_storage(), begin, end);
}
} // namespace histogram
} // namespace boost
#endif