1 // Copyright 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_SAMPLE_HPP
8 #define BOOST_HISTOGRAM_SAMPLE_HPP
9 
10 #include <tuple>
11 #include <utility>
12 
13 namespace boost {
14 namespace histogram {
15 
16 /** Sample holder and type envelope.
17 
18   You should not construct these directly, use the sample() helper function.
19 
20   @tparam Underlying type.
21 */
22 template <class T>
23 struct sample_type {
24   T value;
25 };
26 
27 /** Helper function to mark arguments as sample.
28 
29   @param ts arguments to be forwarded to the accumulator.
30 */
31 template <class... Ts>
sample(Ts &&...ts)32 auto sample(Ts&&... ts) noexcept {
33   return sample_type<std::tuple<Ts...>>{std::forward_as_tuple(std::forward<Ts>(ts)...)};
34 }
35 
36 } // namespace histogram
37 } // namespace boost
38 
39 #endif
40