#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
+#include <deal.II/base/subscriptor.h>
#include <atomic>
#include <typeinfo>
* to a constant object (disallowing write access when dereferenced), while
* `SmartPointer<T>` is a mutable pointer.
*
+ * @dealiiConceptRequires{std::is_base_of_v<Subscriptor, T>}
+ *
* @ingroup memory
*/
template <typename T, typename P = void>
: pointer(nullptr)
, id(typeid(P).name())
, pointed_to_object_is_alive(false)
-{}
+{
+ static_assert(std::is_base_of_v<Subscriptor, T>,
+ "This class can only be used if the first template argument "
+ "is a class derived from 'Subscriptor'.");
+}
, id(typeid(P).name())
, pointed_to_object_is_alive(false)
{
+ static_assert(std::is_base_of_v<Subscriptor, T>,
+ "This class can only be used if the first template argument "
+ "is a class derived from 'Subscriptor'.");
+
if (t != nullptr)
t->subscribe(&pointed_to_object_is_alive, id);
}
, id(id)
, pointed_to_object_is_alive(false)
{
+ static_assert(std::is_base_of_v<Subscriptor, T>,
+ "This class can only be used if the first template argument "
+ "is a class derived from 'Subscriptor'.");
+
if (pointer != nullptr)
pointer->subscribe(&pointed_to_object_is_alive, id);
}
, id(other.id)
, pointed_to_object_is_alive(false)
{
+ static_assert(std::is_base_of_v<Subscriptor, T>,
+ "This class can only be used if the first template argument "
+ "is a class derived from 'Subscriptor'.");
+
if (other != nullptr)
{
Assert(other.pointed_to_object_is_alive,
, id(other.id)
, pointed_to_object_is_alive(false)
{
+ static_assert(std::is_base_of_v<Subscriptor, T>,
+ "This class can only be used if the first template argument "
+ "is a class derived from 'Subscriptor'.");
+
if (other != nullptr)
{
Assert(other.pointed_to_object_is_alive,
, id(other.id)
, pointed_to_object_is_alive(false)
{
+ static_assert(std::is_base_of_v<Subscriptor, T>,
+ "This class can only be used if the first template argument "
+ "is a class derived from 'Subscriptor'.");
+
if (other != nullptr)
{
Assert(other.pointed_to_object_is_alive,
template <typename T, typename P>
inline SmartPointer<T, P>::~SmartPointer()
{
+ static_assert(std::is_base_of_v<Subscriptor, T>,
+ "This class can only be used if the first template argument "
+ "is a class derived from 'Subscriptor'.");
+
if (pointed_to_object_is_alive && pointer != nullptr)
pointer->unsubscribe(&pointed_to_object_is_alive, id);
}