1 #ifndef canvas_Utilities_ensurePointer_h 2 #define canvas_Utilities_ensurePointer_h 13 #include "cetlib_except/demangle.h" 16 #include <type_traits> 20 template <
typename WANTED_POINTER,
typename InputIterator>
24 template <
typename T1,
typename T2>
26 using T1P = std::remove_cv_t<std::remove_pointer_t<T1>>;
27 using T2P = std::remove_cv_t<std::remove_pointer_t<T2>>;
32 template <
typename TO,
typename FROM>
34 std::add_pointer_t<std::remove_pointer_t<TO>>>
40 template <
typename TO,
typename FROM>
43 std::add_pointer_t<std::remove_pointer_t<TO>>>
47 std::add_lvalue_reference_t<std::remove_pointer_t<TO>
>>(from);
50 template <
typename TO,
typename FROM>
55 return detail::addr<TO>(from);
60 return detail::addr<TO>(from);
64 template <
typename TO,
typename PFROM>
69 return detail::addr<TO>(*from);
75 template <
typename WANTED_POINTER,
typename InputIterator>
79 "Supplied template argument is not a pointer.");
82 typename std::iterator_traits<InputIterator>::value_type>{}(*it);
84 catch (std::bad_cast&) {
86 <<
"Iterator value type " 87 << cet::demangle_symbol(
88 typeid(
typename std::iterator_traits<InputIterator>::value_type)
90 <<
" and wanted pointer type " 91 << cet::demangle_symbol(
typeid(WANTED_POINTER).name())
92 <<
" are incompatible.\n";
std::remove_cv_t< std::remove_pointer_t< T1 >> T1P
constexpr TO operator()(FROM const &from) const
std::remove_cv_t< std::remove_pointer_t< T2 >> T2P
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string value(boost::any const &)
constexpr TO operator()(PFROM *from) const
static constexpr bool value
constexpr TO operator()(FROM &from) const
constexpr std::enable_if_t< are_cv_compatible< TO, FROM >::value, std::add_pointer_t< std::remove_pointer_t< TO > > > addr(FROM &from)
WANTED_POINTER ensurePointer(InputIterator it)