siplasplas
A library for C++ reflection and introspection
nonowning.hpp
1 #ifndef SIPLASPLAS_TYPEERASURE_ANYSTORAGE_NONOWNING_HPP
2 #define SIPLASPLAS_TYPEERASURE_ANYSTORAGE_NONOWNING_HPP
3 
4 #include <siplasplas/typeerasure/typeinfo.hpp>
5 
6 namespace cpp
7 {
8 
18 {
19 public:
26  ConstNonOwningStorage(const void* object) :
27  _reference{object}
28  {}
29 
36  void rebind(const void* object)
37  {
38  _reference = object;
39  }
40 
49  const void* storage(cpp::typeerasure::TypeInfo typeInfo) const
50  {
51  return _reference;
52  }
53 
54 private:
55  const void* _reference;
56 };
57 
67 {
68 public:
69 
76  NonOwningStorage(void* object) :
77  _reference{object}
78  {}
79 
86  void rebind(void* object)
87  {
88  _reference = object;
89  }
90 
99  void* storage(cpp::typeerasure::TypeInfo typeInfo) const
100  {
101  return _reference;
102  }
103 
104 private:
105  void* _reference;
106 };
107 }
108 
109 #endif // SIPLASPLAS_TYPEERASURE_ANYSTORAGE_NONOWNING_HPP
void * storage(cpp::typeerasure::TypeInfo typeInfo) const
Returns a pointer to the storage memory space.
Definition: nonowning.hpp:99
Definition: canary_allocator.hpp:7
void rebind(const void *object)
Reassigns the storage to reference another object.
Definition: nonowning.hpp:36
Implements a read-only non owning storage.
Definition: nonowning.hpp:17
NonOwningStorage(void *object)
Initializes the storage pointing it to the given object.
Definition: nonowning.hpp:76
const void * storage(cpp::typeerasure::TypeInfo typeInfo) const
Returns a pointer to the storage memory space.
Definition: nonowning.hpp:49
void rebind(void *object)
Reassigns the storage to reference another object.
Definition: nonowning.hpp:86
Implements a non owning storage.
Definition: nonowning.hpp:66
Contains minimal information to execute the value semantics operations of a type. ...
Definition: typeinfo.hpp:112
ConstNonOwningStorage(const void *object)
Initializes the storage pointing it to the given object.
Definition: nonowning.hpp:26