Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:52:58

0001 #ifndef DataFormats_Common_GetProduct_h
0002 #define DataFormats_Common_GetProduct_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Common
0006 // Class  :     GetProduct
0007 //
0008 /**\class GetProduct GetProduct.h DataFormats/Common/interface/GetProduct.h
0009 
0010  Description: Controls how edm::View and edm::Ptr interact with containers
0011 
0012  Usage:
0013     Override this class in order to specialize edm::View or edm::Ptr's interaction with a container
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Sat Oct 20 10:20:20 EDT 2007
0019 //
0020 
0021 // system include files
0022 
0023 #include <memory>
0024 #include <vector>
0025 
0026 // user include files
0027 
0028 // forward declarations
0029 
0030 namespace edm {
0031   namespace detail {
0032     template <typename COLLECTION>
0033     struct GetProduct {
0034       typedef typename COLLECTION::value_type element_type;
0035       typedef typename COLLECTION::const_iterator iter;
0036       static const element_type* address(const iter& i) { return &*i; }
0037     };
0038 
0039     // Specialize for vector<unique_ptr<T>>>
0040     template <typename T, typename D, typename A>
0041     struct GetProduct<std::vector<std::unique_ptr<T, D>, A> > {
0042       using element_type = T;
0043       using iter = typename std::vector<std::unique_ptr<T, D>, A>::const_iterator;
0044       static const element_type* address(const iter& i) { return i->get(); }
0045     };
0046   }  // namespace detail
0047 }  // namespace edm
0048 
0049 #endif