File indexing completed on 2024-04-06 12:03:50
0001 #ifndef DataFormats_Common_AssociationMapKeyVal_h
0002 #define DataFormats_Common_AssociationMapKeyVal_h
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "DataFormats/Provenance/interface/ProductID.h"
0012 #include "FWCore/Utilities/interface/EDMException.h"
0013
0014 #include <utility>
0015
0016 namespace edm {
0017
0018 class EDProductGetter;
0019
0020 namespace helpers {
0021 template <typename K, typename V>
0022 struct KeyVal {
0023 typedef K key_type;
0024 typedef V value_type;
0025 KeyVal() : key(), val() {}
0026 KeyVal(const K& k, const V& v) : key(k), val(v) {}
0027 template <typename K_, typename V_>
0028 KeyVal(K_&& k, V_&& v) : key(std::forward<K_>(k)), val(std::forward<V_>(v)) {}
0029
0030 KeyVal(EDProductGetter const* getter) : key(ProductID(), getter), val(ProductID(), getter) {}
0031
0032 K key;
0033 V val;
0034 };
0035
0036 template <typename K>
0037 struct Key {
0038 typedef K key_type;
0039 Key() {}
0040 Key(const K& k) : key(k) {}
0041 template <typename K_>
0042 Key(K_&& k) : key(std::forward<K_>(k)) {}
0043
0044 Key(EDProductGetter const* getter) : key(ProductID(), getter) {}
0045
0046 K key;
0047 };
0048
0049
0050 template <typename RP, typename R>
0051 void checkRef(const RP& rp, const R& r) {
0052 if (rp.id() != r.id()) {
0053 Exception::throwThis(edm::errors::InvalidReference, "invalid reference");
0054 }
0055 }
0056 }
0057 }
0058
0059 #endif