Loading...
Searching...
No Matches
lazy_conditional.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 <type_traits>
#include <seqan3/core/platform.hpp>
namespace seqan3::detail
{
// ----------------------------------------------------------------------------
// lazy
// ----------------------------------------------------------------------------
template <template <typename...> typename template_t, typename... spec_t>
struct lazy
{};
// ----------------------------------------------------------------------------
// instantiate
// ----------------------------------------------------------------------------
template <typename t>
struct instantiate : std::type_identity<t>
{};
template <template <typename...> typename template_t, typename... spec_t>
struct instantiate<lazy<template_t, spec_t...>>
{
using type = template_t<spec_t...>;
};
template <typename t>
requires requires { typename instantiate<t>::type; }
using instantiate_t = typename instantiate<t>::type;
// ----------------------------------------------------------------------------
// instantiate_if
// ----------------------------------------------------------------------------
template <typename t, bool condition>
struct instantiate_if : std::false_type
{};
template <typename t>
struct instantiate_if<t, true> : std::type_identity<t>
{};
template <template <typename...> typename template_t, typename... spec_t>
struct instantiate_if<lazy<template_t, spec_t...>, true>
{
using type = template_t<spec_t...>;
};
template <typename t, bool condition>
requires requires { typename instantiate_if<t, condition>::type; }
using instantiate_if_t = typename instantiate_if<t, condition>::type;
template <typename t, bool condition>
requires requires { instantiate_if_t<t, condition>::value; }
inline constexpr auto instantiate_if_v = instantiate_if_t<t, condition>::value;
// ----------------------------------------------------------------------------
// lazy_conditional
// ----------------------------------------------------------------------------
template <bool decision, typename on_true_t, typename on_false_t>
struct lazy_conditional : instantiate<std::conditional_t<decision, on_true_t, on_false_t>>
{};
template <bool decision, typename on_true_t, typename on_false_t>
requires requires { typename instantiate_t<std::conditional_t<decision, on_true_t, on_false_t>>; }
using lazy_conditional_t = instantiate_t<std::conditional_t<decision, on_true_t, on_false_t>>;
} // namespace seqan3::detail
platform.hpp
Provides platform and dependency checks.
type_traits
Hide me