]> https://gitweb.dealii.org/ - dealii.git/commitdiff
base/lazy.h: add memory_consumption method to Lazy<T> 16213/head
authorMatthias Maier <tamiko@43-1.org>
Sun, 29 Oct 2023 22:07:20 +0000 (17:07 -0500)
committerMatthias Maier <tamiko@43-1.org>
Tue, 31 Oct 2023 01:59:11 +0000 (20:59 -0500)
include/deal.II/base/lazy.h

index 307fbc9708cc0029ffda1f143ed745a577a52463..450230cd0a5469047ef578f234eb8dc9352d6e53 100644 (file)
@@ -20,6 +20,7 @@
 #include <deal.II/base/config.h>
 
 #include <deal.II/base/exceptions.h>
+#include <deal.II/base/memory_consumption.h>
 #include <deal.II/base/mutex.h>
 
 #include <atomic>
@@ -194,6 +195,12 @@ public:
   value_or_initialize(const Callable &creator);
 
 
+  /**
+   * Compute the memory consumption of this structure.
+   */
+  std::size_t
+  memory_consumption() const;
+
 private:
   /**
    * The lazily initialized object stored as a std::optional<T>.
@@ -396,5 +403,14 @@ Lazy<T>::value_or_initialize(const Callable &creator)
 }
 
 
+template <typename T>
+std::size_t
+Lazy<T>::memory_consumption() const
+{
+  return MemoryConsumption::memory_consumption(object) + //
+         sizeof(*this) - sizeof(object);
+}
+
+
 DEAL_II_NAMESPACE_CLOSE
 #endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.