13#ifndef dealii_observer_pointer_h
14#define dealii_observer_pointer_h
103template <
typename T,
typename P =
void>
202 operator T *()
const;
266 const std::string
id;
282template <
typename T,
typename P =
void>
290template <
typename T,
typename P>
293 ,
id(typeid(P).name())
296 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
297 "This class can only be used if the first template argument "
298 "is a class derived from 'EnableObserverPointer'.");
303template <
typename T,
typename P>
306 ,
id(typeid(P).name())
309 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
310 "This class can only be used if the first template argument "
311 "is a class derived from 'EnableObserverPointer'.");
319template <
typename T,
typename P>
325 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
326 "This class can only be used if the first template argument "
327 "is a class derived from 'EnableObserverPointer'.");
335template <
typename T,
typename P>
343 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
344 "This class can only be used if the first template argument "
345 "is a class derived from 'EnableObserverPointer'.");
347 if (other !=
nullptr)
350 ExcMessage(
"You can't copy a smart pointer object that "
351 "is pointing to an object that is no longer alive."));
358template <
typename T,
typename P>
365 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
366 "This class can only be used if the first template argument "
367 "is a class derived from 'EnableObserverPointer'.");
369 if (other !=
nullptr)
372 ExcMessage(
"You can't copy a smart pointer object that "
373 "is pointing to an object that is no longer alive."));
380template <
typename T,
typename P>
387 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
388 "This class can only be used if the first template argument "
389 "is a class derived from 'EnableObserverPointer'.");
391 if (other !=
nullptr)
393 Assert(other.pointed_to_object_is_alive,
394 ExcMessage(
"You can't move a smart pointer object that "
395 "is pointing to an object that is no longer alive."));
405 "Calling subscribe() failed with an exception, but we "
406 "are in a function that cannot throw exceptions. "
407 "Aborting the program here."));
418template <
typename T,
typename P>
421 static_assert(std::is_base_of_v<EnableObserverPointer, T>,
422 "This class can only be used if the first template argument "
423 "is a class derived from 'EnableObserverPointer'.");
431template <
typename T,
typename P>
446template <
typename T,
typename P>
468template <
typename T,
typename P>
484 pointer = (other !=
nullptr ? other.
get() :
nullptr);
485 if (other !=
nullptr)
488 ExcMessage(
"You can't copy a smart pointer object that "
489 "is pointing to an object that is no longer alive."));
497template <
typename T,
typename P>
512 pointer = (other !=
nullptr ? other.
get() :
nullptr);
513 if (other !=
nullptr)
516 ExcMessage(
"You can't copy a smart pointer object that "
517 "is pointing to an object that is no longer alive."));
525template <
typename T,
typename P>
529 if (other ==
nullptr)
535 else if (&other !=
this)
542 Assert(other.pointed_to_object_is_alive,
543 ExcMessage(
"You can't move a smart pointer object that "
544 "is pointing to an object that is no longer alive."));
554 "Calling subscribe() failed with an exception, but we "
555 "are in a function that cannot throw exceptions. "
556 "Aborting the program here."));
567template <
typename T,
typename P>
575template <
typename T,
typename P>
581 ExcMessage(
"The object pointed to is not valid anymore."));
587template <
typename T,
typename P>
593 ExcMessage(
"The object pointed to is not valid anymore."));
599template <
typename T,
typename P>
608template <
typename T,
typename P>
627template <
typename T,
typename P>
642template <
typename T,
typename P>
665template <
typename T,
typename P,
class Q>
681template <
typename T,
typename P>
697template <
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
#define DEAL_II_DEPRECATED_WITH_COMMENT(comment)
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)