// SPDX-License-Identifier: BSD-2-Clause // Copyright CM4all GmbH // author: Max Kellermann #pragma once #include // for std::forward() /** * Helps with declaring a field that is present only under a certain * (compile-time) condition. If `enable` is true, this struct * contains a field named `value` of the specified type. To avoid * memory overhead when disabled, add the attribute * [[no_unique_address]]. */ template struct OptionalField; template struct OptionalField { template constexpr OptionalField(Args&&...) {} }; template struct OptionalField { T value; template constexpr OptionalField(Args&&... args) :value(std::forward(args)...) {} };