16#ifndef dealii_smartpointer_h
17#define dealii_smartpointer_h
66template <
typename T,
typename P =
void>
145 operator T *()
const;
204 const std::string
id;
217template <
typename T,
typename P>
220 , id(typeid(P).name())
221 , pointed_to_object_is_alive(false)
226template <
typename T,
typename P>
229 , id(typeid(P).name())
230 , pointed_to_object_is_alive(false)
238template <
typename T,
typename P>
242 , pointed_to_object_is_alive(false)
250template <
typename T,
typename P>
255 , pointed_to_object_is_alive(false)
263template <
typename T,
typename P>
267 , pointed_to_object_is_alive(false)
275template <
typename T,
typename P>
278 if (pointed_to_object_is_alive && t !=
nullptr)
279 t->unsubscribe(&pointed_to_object_is_alive,
id);
284template <
typename T,
typename P>
288 if (pointed_to_object_is_alive && t !=
nullptr)
290 t->unsubscribe(&pointed_to_object_is_alive,
id);
299template <
typename T,
typename P>
308 if (pointed_to_object_is_alive && t !=
nullptr)
309 t->unsubscribe(&pointed_to_object_is_alive,
id);
312 tt->subscribe(&pointed_to_object_is_alive,
id);
318template <
typename T,
typename P>
329 if (pointed_to_object_is_alive && t !=
nullptr)
330 t->unsubscribe(&pointed_to_object_is_alive,
id);
331 t =
static_cast<T *
>(tt);
333 tt->subscribe(&pointed_to_object_is_alive,
id);
339template <
typename T,
typename P>
349 if (pointed_to_object_is_alive && t !=
nullptr)
350 t->unsubscribe(&pointed_to_object_is_alive,
id);
351 t =
static_cast<T *
>(tt);
353 tt->subscribe(&pointed_to_object_is_alive,
id);
359template <
typename T,
typename P>
367template <
typename T,
typename P>
372 Assert(pointed_to_object_is_alive,
373 ExcMessage(
"The object pointed to is not valid anymore."));
379template <
typename T,
typename P>
384 Assert(pointed_to_object_is_alive,
385 ExcMessage(
"The object pointed to is not valid anymore."));
391template <
typename T,
typename P>
407template <
typename T,
typename P>
411 if (pointed_to_object_is_alive && t !=
nullptr)
412 t->unsubscribe(pointed_to_object_is_alive,
id);
417 t->subscribe(pointed_to_object_is_alive,
id);
422template <
typename T,
typename P>
445template <
typename T,
typename P,
class Q>
461template <
typename T,
typename P>
477template <
typename T,
typename P>
void swap(SmartPointer< T, Q > &tt)
SmartPointer(const SmartPointer< T, P > &tt)
SmartPointer< T, P > & operator=(const SmartPointer< T, P > &tt)
std::atomic< bool > pointed_to_object_is_alive
SmartPointer(const SmartPointer< T, Q > &tt)
std::size_t memory_consumption() const
SmartPointer< T, P > & operator=(const SmartPointer< T, Q > &tt)
SmartPointer(T *t, const std::string &id)
SmartPointer< T, P > & operator=(T *tt)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcMessage(std::string arg1)
void swap(SmartPointer< T, P > &t1, SmartPointer< T, Q > &t2)