1 #ifndef canvas_Persistency_Common_setPtr_h 2 #define canvas_Persistency_Common_setPtr_h 6 #include "cetlib/map_vector.h" 7 #include "cetlib_except/demangle.h" 13 template <
class COLLECTION>
14 void setPtr(COLLECTION
const& coll,
15 std::type_info
const& iToType,
20 void setPtr(cet::map_vector<T>
const& obj,
21 std::type_info
const& iToType,
26 template <
class Collection>
29 std::type_info
const& iToType,
33 using product_type = Collection;
34 auto it = coll.begin();
35 if (iIndex >= coll.size()) {
38 "An out-of-bounds error was encountered while setting an art::Ptr.\n"}
39 <<
"An attempt was made to access an element with index " << iIndex
40 <<
" for a container with a size of " << coll.size() <<
".\n" 41 <<
"The container is of type " +
42 cet::demangle_symbol(
typeid(Collection).name())
53 std::type_info
const& iToType,
58 std::string
const wanted_type =
61 auto const it = obj.findOrThrow(cet::map_vector_key{iIndex});
62 assert(it != obj.end());
bool starts_with_pair(std::string const &type_name, size_t const pos)
std::string uniform_type_name(std::type_info const &tid)
void setPtr(COLLECTION const &coll, std::type_info const &iToType, unsigned long iIndex, void const *&oPtr)
static auto const * address(const_iterator const &i)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
void const * maybeCastObj(void const *address, std::type_info const &tiFrom, std::type_info const &tiTo)