Loading...
Searching...
No Matches
non_propagating_cache.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <optional>
#include <seqan3/core/platform.hpp>
namespace seqan3::detail
{
template <typename T>
requires std::is_object_v<T>
class non_propagating_cache : public std::optional<T>
{
public:
using std::optional<T>::optional;
using std::optional<T>::operator=;
constexpr non_propagating_cache(non_propagating_cache const &) noexcept
{}
constexpr non_propagating_cache(non_propagating_cache && other) noexcept
{
other.reset();
}
constexpr non_propagating_cache & operator=(non_propagating_cache const & other) noexcept
{
if (std::addressof(other) != this)
this->reset();
return *this;
}
constexpr non_propagating_cache & operator=(non_propagating_cache && other) noexcept
{
this->reset();
other.reset();
return *this;
}
template <class I>
constexpr T & emplace_deref(I const & i)
requires requires (I const & i) { T(*i); }
{
this->reset();
this->emplace(*i);
return this->value();
}
};
} // namespace seqan3::detail
std::addressof
T addressof(T... args)
std::optional< T >::emplace
T emplace(T... args)
std::is_object_v
T is_object_v
optional
platform.hpp
Provides platform and dependency checks.
std::optional< T >::reset
T reset(T... args)
std::optional< T >::value
T value(T... args)
Hide me