CMS 3D CMS Logo

rep_type.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_CORE_DDI_REP_TYPE_H
2 #define DETECTOR_DESCRIPTION_CORE_DDI_REP_TYPE_H
3 
4 #include <memory>
5 
6 namespace DDI {
7 
8  template< class N, class I >
9  struct rep_traits
10  {
11  using name_type = N;
12  using pointer = typename I::pointer;
13  using reference = typename I::reference;
14  };
15 
16  template <class N, class I>
17  struct rep_traits< N, I* >
18  {
19  using name_type = N;
20  using pointer = I*;
21  using reference = I&;
22  };
23 
24  template <class N, class I>
25  struct rep_traits< N, std::unique_ptr<I>>
26  {
27  using name_type = N;
28  using pointer = I*;
29  using reference = I&;
30  };
31 
32  template< class N, class I >
33  struct rep_type
34  {
35  rep_type() : second( nullptr ), init_( false ) {}
36  rep_type( const N & n, I i ) : first( n ), second( std::move( i )), init_( false )
37  { if( i ) init_ = true; }
40 
41  const typename rep_traits< N, I >::name_type & name() const { return first; }
42  const typename rep_traits< N, I >::reference rep() const { return *second; }
43 
44  I swap( I i )
45  {
46  I tmp( second );
47  second = i;
48  init_ = false;
49  if( i ) init_ = true;
50  return tmp;
51  }
52  operator bool() const { return init_; }
53 
54  private:
55  bool init_;
56  };
57 }
58 
59 #endif
bool init_
Definition: rep_type.h:55
#define nullptr
U second(std::pair< T, U > const &p)
const std::complex< double > I
Definition: I.h:8
typename I::pointer pointer
Definition: rep_type.h:12
rep_type(const N &n, I i)
Definition: rep_type.h:36
I swap(I i)
Definition: rep_type.h:44
#define N
Definition: blowfish.cc:9
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
typename I::reference reference
Definition: rep_type.h:13
const rep_traits< N, I >::reference rep() const
Definition: rep_type.h:42
const rep_traits< N, I >::name_type & name() const
Definition: rep_type.h:41
def move(src, dest)
Definition: eostools.py:511