1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#ifndef DataFormats_Common_GetProduct_h
#define DataFormats_Common_GetProduct_h
// -*- C++ -*-
//
// Package: Common
// Class : GetProduct
//
/**\class GetProduct GetProduct.h DataFormats/Common/interface/GetProduct.h
Description: Controls how edm::View and edm::Ptr interact with containers
Usage:
Override this class in order to specialize edm::View or edm::Ptr's interaction with a container
*/
//
// Original Author: Chris Jones
// Created: Sat Oct 20 10:20:20 EDT 2007
//
// system include files
#include <memory>
#include <vector>
// user include files
// forward declarations
namespace edm {
namespace detail {
template <typename COLLECTION>
struct GetProduct {
typedef typename COLLECTION::value_type element_type;
typedef typename COLLECTION::const_iterator iter;
static const element_type* address(const iter& i) { return &*i; }
};
// Specialize for vector<unique_ptr<T>>>
template <typename T, typename D, typename A>
struct GetProduct<std::vector<std::unique_ptr<T, D>, A> > {
using element_type = T;
using iter = typename std::vector<std::unique_ptr<T, D>, A>::const_iterator;
static const element_type* address(const iter& i) { return i->get(); }
};
} // namespace detail
} // namespace edm
#endif
|