Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:53

0001 #ifndef DataFormats_Common_RefKeyTrait_h
0002 #define DataFormats_Common_RefKeyTrait_h
0003 #include "FWCore/Utilities/interface/EDMException.h"
0004 
0005 namespace edm {
0006   template <typename C>
0007   class RefProd;
0008   namespace reftobase {
0009 
0010     struct RefKey {
0011       template <typename REF>
0012       static size_t key(const REF& r) {
0013         return r.key();
0014       }
0015     };
0016 
0017     struct RefProdKey {
0018       template <typename REF>
0019       static size_t key(const REF& r) {
0020         Exception::throwThis(errors::InvalidReference,
0021                              "attempting get key from a RefToBase containing a RefProd.\n"
0022                              "You can use key only with RefToBase containing a Ref.");
0023         return 0;
0024       }
0025     };
0026 
0027     template <typename REF>
0028     struct RefKeyTrait {
0029       typedef RefKey type;
0030     };
0031 
0032     template <typename C>
0033     struct RefKeyTrait<RefProd<C> > {
0034       typedef RefProdKey type;
0035     };
0036   }  // namespace reftobase
0037 }  // namespace edm
0038 
0039 #endif