279 memory_consumption() const;
285 mutable
std::optional<T>
object;
292 mutable
std::atomic<
bool> object_is_initialized;
311 std::is_move_assignable_v<T>))
313 : object_is_initialized(false)
319 std::is_move_assignable_v<T>))
321 :
object(other.
object)
323 object_is_initialized.store(other.object_is_initialized.load());
329 std::is_move_assignable_v<T>))
331 :
object(
std::move(other.
object))
333 object_is_initialized.store(other.object_is_initialized.load());
341 other.object.reset();
347 std::is_move_assignable_v<T>))
351 object_is_initialized.store(other.object_is_initialized.load());
358 std::is_move_assignable_v<T>))
361 object = std::move(other.object);
362 object_is_initialized.store(other.object_is_initialized.load());
369 other.object_is_initialized.store(
false);
370 other.object.reset();
378 std::is_move_assignable_v<T>))
379inline
void Lazy<T>::reset() noexcept
381 object_is_initialized.store(
false);
388 std::is_move_assignable_v<T>))
389template <
typename Callable>
412 if (!object_is_initialized.load(std::memory_order_acquire))
413#ifdef DEAL_II_HAVE_CXX20
417 std::lock_guard<std::mutex> lock(initialization_mutex);
427 if (!object_is_initialized.load(std::memory_order_relaxed))
430 object.emplace(std::move(creator()));
439 object_is_initialized.store(
true, std::memory_order_release);
446 "The internal std::optional<T> object does not contain a valid object "
447 "even though we have just initialized it."));
453 std::is_move_assignable_v<T>))
462 return (object_is_initialized &&
object.has_value());
468 std::is_move_assignable_v<T>))
472 object_is_initialized &&
object.has_value(),
474 "value() has been called but the contained object has not been "
475 "initialized. Did you forget to call 'ensure_initialized()' first?"));
477 return object.value();
483 std::is_move_assignable_v<T>))
487 object_is_initialized &&
object.has_value(),
489 "value() has been called but the contained object has not been "
490 "initialized. Did you forget to call 'ensure_initialized()' first?"));
492 return object.value();
498 std::is_move_assignable_v<T>))
499template <
typename Callable>
501 const Callable &creator)
const
504 ensure_initialized(creator);
505 return object.value();
511 std::is_move_assignable_v<T>))
512template <
typename Callable>
514 const Callable &creator)
517 ensure_initialized(creator);
518 return object.value();
524 std::is_move_assignable_v<T>))
525std::
size_t Lazy<T>::memory_consumption()
const
528 sizeof(*this) -
sizeof(object);