CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
getWrapperBasePtr.h
Go to the documentation of this file.
1 #ifndef IOPool_Common_getWrapperBasePtr_h
2 #define IOPool_Common_getWrapperBasePtr_h
3 
4 #include <cassert>
5 #include <memory>
6 #include "TClass.h"
8 
9 namespace edm {
10  inline
11  std::unique_ptr<WrapperBase> getWrapperBasePtr(void* p, int offset) {
12  // A union is used to avoid possible copies during the triple cast that would otherwise be needed.
13  // std::unique_ptr<WrapperBase> edp(static_cast<WrapperBase *>(static_cast<void *>(static_cast<unsigned char *>(p) + branchInfo.offsetToWrapperBase_)));
14  union {
15  void* vp;
16  unsigned char* ucp;
17  WrapperBase* edp;
18  } pointerUnion;
19  assert(p != nullptr);
20  pointerUnion.vp = p;
21  pointerUnion.ucp += offset;
22  std::unique_ptr<WrapperBase> edp(pointerUnion.edp);
23  return(std::move(edp));
24  }
25 }
26 
27 #endif
unsigned int offset(bool)
std::unique_ptr< WrapperBase > getWrapperBasePtr(void *p, int offset)