15#ifndef dealii_observer_pointer_h
16#define dealii_observer_pointer_h
105template <
typename T,
typename P =
void>
204 operator T *()
const;
268 const std::string
id;
284template <
typename T,
typename P =
void>
292template <
typename T,
typename P>
295 ,
id(typeid(P).name())
298 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
299 "This class can only be used if the first template argument "
300 "is a class derived from 'EnableObserverPointer'.");
305template <
typename T,
typename P>
308 ,
id(typeid(P).name())
311 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
312 "This class can only be used if the first template argument "
313 "is a class derived from 'EnableObserverPointer'.");
321template <
typename T,
typename P>
327 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
328 "This class can only be used if the first template argument "
329 "is a class derived from 'EnableObserverPointer'.");
337template <
typename T,
typename P>
345 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
346 "This class can only be used if the first template argument "
347 "is a class derived from 'EnableObserverPointer'.");
349 if (other !=
nullptr)
352 ExcMessage(
"You can't copy a smart pointer object that "
353 "is pointing to an object that is no longer alive."));
360template <
typename T,
typename P>
367 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
368 "This class can only be used if the first template argument "
369 "is a class derived from 'EnableObserverPointer'.");
371 if (other !=
nullptr)
374 ExcMessage(
"You can't copy a smart pointer object that "
375 "is pointing to an object that is no longer alive."));
382template <
typename T,
typename P>
389 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
390 "This class can only be used if the first template argument "
391 "is a class derived from 'EnableObserverPointer'.");
393 if (other !=
nullptr)
395 Assert(other.pointed_to_object_is_alive,
396 ExcMessage(
"You can't move a smart pointer object that "
397 "is pointing to an object that is no longer alive."));
407 "Calling subscribe() failed with an exception, but we "
408 "are in a function that cannot throw exceptions. "
409 "Aborting the program here."));
420template <
typename T,
typename P>
423 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
424 "This class can only be used if the first template argument "
425 "is a class derived from 'EnableObserverPointer'.");
433template <
typename T,
typename P>
448template <
typename T,
typename P>
470template <
typename T,
typename P>
486 pointer = (other !=
nullptr ? other.
get() :
nullptr);
487 if (other !=
nullptr)
490 ExcMessage(
"You can't copy a smart pointer object that "
491 "is pointing to an object that is no longer alive."));
499template <
typename T,
typename P>
514 pointer = (other !=
nullptr ? other.
get() :
nullptr);
515 if (other !=
nullptr)
518 ExcMessage(
"You can't copy a smart pointer object that "
519 "is pointing to an object that is no longer alive."));
527template <
typename T,
typename P>
531 if (other ==
nullptr)
537 else if (&other !=
this)
544 Assert(other.pointed_to_object_is_alive,
545 ExcMessage(
"You can't move a smart pointer object that "
546 "is pointing to an object that is no longer alive."));
556 "Calling subscribe() failed with an exception, but we "
557 "are in a function that cannot throw exceptions. "
558 "Aborting the program here."));
569template <
typename T,
typename P>
577template <
typename T,
typename P>
583 ExcMessage(
"The object pointed to is not valid anymore."));
589template <
typename T,
typename P>
595 ExcMessage(
"The object pointed to is not valid anymore."));
601template <
typename T,
typename P>
610template <
typename T,
typename P>
629template <
typename T,
typename P>
644template <
typename T,
typename P>
667template <
typename T,
typename P,
class Q>
683template <
typename T,
typename P>
699template <
typename T,
typename P>
std::size_t memory_consumption() const
void swap(ObserverPointer< T, Q > &tt)
std::atomic< bool > pointed_to_object_is_alive
ObserverPointer< T, P > & operator=(const ObserverPointer< T, P > &other)
ObserverPointer< T, P > & operator=(const ObserverPointer< T, Q > &other)
ObserverPointer(const ObserverPointer< T, P > &other)
ObserverPointer< T, P > & operator=(T *tt)
ObserverPointer< T, P > & operator=(ObserverPointer< T, P > &&other) noexcept
ObserverPointer(const ObserverPointer< T, Q > &other)
ObserverPointer(ObserverPointer< T, P > &&other) noexcept
ObserverPointer(T *t, const std::string &id)
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
constexpr bool running_in_debug_mode()
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcMessage(std::string arg1)
ObserverPointer< T, P > SmartPointer
void swap(ObserverPointer< T, P > &t1, ObserverPointer< T, Q > &t2)