set_ptr_customization_t.cc
Go to the documentation of this file.
1 #define BOOST_TEST_MODULE (Tests setPtr customization)
2 #include "boost/test/unit_test.hpp"
3 
6 
7 #include <type_traits>
8 #include <vector>
9 
10 namespace custom {
11  template <typename T>
12  struct collection {
13  using impl = std::vector<T>;
15  using value_type = typename impl::value_type;
17  cbegin() const
18  {
19  return v.cbegin();
20  }
22  };
23 }
24 
25 namespace {
26  struct customization_honored {};
27  auto always_true = [](customization_honored) { return true; };
28 }
29 
30 namespace art {
31  template <typename T>
32  struct has_setPtr<custom::collection<T>> : std::true_type {};
33 }
34 
35 namespace custom {
36  template <class T>
37  [[noreturn]] void
39  std::type_info const&,
40  unsigned long,
41  void const*&)
42  {
43  throw customization_honored{};
44  }
45 
46  template <typename T>
47  [[noreturn]] void
49  std::type_info const&,
50  std::vector<unsigned long> const&,
51  std::vector<void const*>&)
52  {
53  throw customization_honored{};
54  }
55 }
56 
57 BOOST_AUTO_TEST_SUITE(ptr_customizations_t)
58 
60 {
62  BOOST_CHECK_EXCEPTION(w.getElementAddress(typeid(int), {}),
63  customization_honored,
64  always_true);
65 }
66 
67 BOOST_AUTO_TEST_CASE(getElementAddresses_t)
68 {
70  BOOST_CHECK_EXCEPTION(w.getElementAddresses(typeid(int), {}),
71  customization_honored,
72  always_true);
73 }
74 
75 BOOST_AUTO_TEST_SUITE_END()
typename impl::const_iterator const_iterator
void getElementAddresses(collection< T > const &, std::type_info const &, std::vector< unsigned long > const &, std::vector< void const * > &)
const_iterator cbegin() const
BOOST_AUTO_TEST_CASE(setPtr_t)
intermediate_table::const_iterator const_iterator
typename impl::value_type value_type
std::vector< void const * > getElementAddresses(std::type_info const &toType, std::vector< unsigned long > const &indices) const
Definition: EDProduct.cc:20
void setPtr(collection< T > const &, std::type_info const &, unsigned long, void const *&)
void const * getElementAddress(std::type_info const &toType, unsigned long index) const
Definition: EDProduct.cc:13