CMS 3D CMS Logo

produce_helpers.h
Go to the documentation of this file.
1 #ifndef Framework_produce_helpers_h
2 #define Framework_produce_helpers_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : produce_helpers
7 //
16 //
17 // Author: Chris Jones
18 // Created: Fri Apr 15 10:25:20 EDT 2005
19 //
20 
21 // system include files
22 #include <memory>
23 // user include files
24 
25 // forward declarations
26 namespace edm {
27  namespace eventsetup {
28 
29  namespace produce { struct Null;}
30 
31  template<typename FromT, typename ToT> void copyFromTo(FromT& iFrom,
32  ToT & iTo) {
33  iTo = iFrom;
34  }
35 
36  template<typename FromT, typename ToT> void copyFromTo(std::unique_ptr<FromT>& iFrom, ToT & iTo) {
37  iTo = std::move(iFrom);
38  }
39 
40  namespace produce {
41  struct Null {};
42  template <typename T> struct EndList {
43  typedef T tail_type;
44  typedef Null head_type;
45  };
46  template <typename T> struct product_traits {
47  typedef T type;
48  };
49  template< typename T> struct product_traits<T*> {
50  typedef EndList<T*> type;
51  };
52  template< typename T> struct product_traits<std::unique_ptr<T> > {
54  };
55  template< typename T> struct product_traits<std::shared_ptr<T> > {
57  };
58 
59 
60  template<typename T> struct size {
61  typedef typename product_traits<T>::type type;
63  };
64  template<> struct size<Null> {
65  enum { value = 0 };
66  };
67 
68  template<typename T> struct smart_pointer_traits {
69  typedef typename T::element_type type;
70  };
71 
72  template<typename T> struct smart_pointer_traits<T*> {
73  typedef T type;
74  };
75  template<typename T> struct smart_pointer_traits< T const *> {
76  typedef T type;
77  };
78 
79  template<typename FromT, typename ToT> void copyFromTo(FromT& iFrom,
80  ToT & iTo) {
81  iTo = iFrom;
82  }
83 
84  template<typename FromT, typename ToT> void copyFromTo(std::unique_ptr<FromT>& iFrom, ToT & iTo) {
85  iTo = std::move(iFrom);
86  }
87 
88 
89  template<typename ContainerT, typename EntryT, typename FindT> struct find_index_impl {
92  };
93  template<typename ContainerT, typename T> struct find_index_impl<ContainerT, T,T> {
94  enum { value = 0 };
95  };
96 
97  template<typename T, typename FindT> struct find_index {
100  };
101  namespace test {
102  template<typename T> const char* name(const T*);
103  }
104 
105  }
106  }
107 }
108 
109 #endif
const char * name(const T *)
void copyFromTo(FromT &iFrom, ToT &iTo)
Definition: value.py:1
product_traits< T >::type container_type
HLT enums.
product_traits< T >::type type
long double T
def move(src, dest)
Definition: eostools.py:510
product_traits< ContainerT >::type container_type