• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <boost/core/lightweight_test.hpp>
8 #include <boost/core/lightweight_test_trait.hpp>
9 #include <boost/histogram/detail/accumulator_traits.hpp>
10 #include <boost/histogram/weight.hpp>
11 #include <tuple>
12 
13 namespace dtl = boost::histogram::detail;
14 
main()15 int main() {
16   using boost::histogram::weight_type;
17 
18   struct A1 {
19     void operator()();
20   };
21 
22   BOOST_TEST_NOT(dtl::accumulator_traits<A1>::weight_support);
23   BOOST_TEST_TRAIT_SAME(typename dtl::accumulator_traits<A1>::args, std::tuple<>);
24 
25   struct A2 {
26     void operator()(int, double);
27   };
28 
29   BOOST_TEST_NOT(dtl::accumulator_traits<A2>::weight_support);
30   BOOST_TEST_TRAIT_SAME(typename dtl::accumulator_traits<A2>::args,
31                         std::tuple<int, double>);
32 
33   struct A3 {
34     void operator()();
35     void operator()(weight_type<int>);
36   };
37 
38   BOOST_TEST(dtl::accumulator_traits<A3>::weight_support);
39   BOOST_TEST_TRAIT_SAME(typename dtl::accumulator_traits<A3>::args, std::tuple<>);
40 
41   struct A4 {
42     void operator()(int, double, char);
43     void operator()(weight_type<int>, int, double, char);
44   };
45 
46   BOOST_TEST(dtl::accumulator_traits<A4>::weight_support);
47   BOOST_TEST_TRAIT_SAME(typename dtl::accumulator_traits<A4>::args,
48                         std::tuple<int, double, char>);
49 
50   struct A5 {
51     void operator()(const weight_type<int>, int);
52   };
53 
54   BOOST_TEST(dtl::accumulator_traits<A5>::weight_support);
55   BOOST_TEST_TRAIT_SAME(typename dtl::accumulator_traits<A5>::args, std::tuple<int>);
56 
57   struct A6 {
58     void operator()(const weight_type<int>&, const int);
59   };
60 
61   BOOST_TEST(dtl::accumulator_traits<A6>::weight_support);
62   BOOST_TEST_TRAIT_SAME(typename dtl::accumulator_traits<A6>::args, std::tuple<int>);
63 
64   struct A7 {
65     void operator()(weight_type<int>&&, int&&);
66   };
67 
68   BOOST_TEST(dtl::accumulator_traits<A7>::weight_support);
69   BOOST_TEST_TRAIT_SAME(typename dtl::accumulator_traits<A7>::args, std::tuple<int&&>);
70 
71   struct B {
72     int operator+=(int);
73   };
74 
75   BOOST_TEST(dtl::accumulator_traits<B>::weight_support);
76   BOOST_TEST_TRAIT_SAME(typename dtl::accumulator_traits<B>::args, std::tuple<>);
77 
78   BOOST_TEST(dtl::accumulator_traits<int>::weight_support);
79   BOOST_TEST_TRAIT_SAME(dtl::accumulator_traits<int>::args, std::tuple<>);
80 
81   return boost::report_errors();
82 }
83