SeqAn3 3.3.0-rc.1
The Modern C++ library for sequence analysis.
 
Loading...
Searching...
No Matches
lazy_conditional.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <type_traits>
16
18
19namespace seqan3::detail
20{
21
22// ----------------------------------------------------------------------------
23// lazy
24// ----------------------------------------------------------------------------
25
31template <template <typename...> typename template_t, typename... spec_t>
32struct lazy
33{};
34
35// ----------------------------------------------------------------------------
36// instantiate
37// ----------------------------------------------------------------------------
38
44template <typename t>
46{};
47
54template <template <typename...> typename template_t, typename... spec_t>
55struct instantiate<lazy<template_t, spec_t...>>
56{
58 using type = template_t<spec_t...>;
59};
60
65template <typename t>
66 requires requires { typename instantiate<t>::type; }
68
69// ----------------------------------------------------------------------------
70// instantiate_if
71// ----------------------------------------------------------------------------
72
79template <typename t, bool condition>
81{};
82
89template <typename t>
91{};
92
100template <template <typename...> typename template_t, typename... spec_t>
101struct instantiate_if<lazy<template_t, spec_t...>, true>
102{
104 using type = template_t<spec_t...>;
105};
106
111template <typename t, bool condition>
112 requires requires { typename instantiate_if<t, condition>::type; }
114
119template <typename t, bool condition>
120 requires requires { instantiate_if_t<t, condition>::value; }
121inline constexpr auto instantiate_if_v = instantiate_if_t<t, condition>::value;
122
123// ----------------------------------------------------------------------------
124// lazy_conditional
125// ----------------------------------------------------------------------------
126
140template <bool decision, typename on_true_t, typename on_false_t>
141struct lazy_conditional : instantiate<std::conditional_t<decision, on_true_t, on_false_t>>
142{};
143
150template <bool decision, typename on_true_t, typename on_false_t>
151 requires requires { typename instantiate_t<std::conditional_t<decision, on_true_t, on_false_t>>; }
153
154} // namespace seqan3::detail
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides platform and dependency checks.
template_t< spec_t... > type
Return type of the trait [instantiates the template arguments].
Definition: lazy_conditional.hpp:58
template_t< spec_t... > type
Return type of the trait [instantiates the template arguments].
Definition: lazy_conditional.hpp:104
A transformation trait that instantiates seqan3::lazy types given a boolean condition....
Definition: lazy_conditional.hpp:81
typename instantiate_if< t, condition >::type instantiate_if_t
A transformation trait that instantiates seqan3::lazy types, conditionally. Transformation trait shor...
Definition: lazy_conditional.hpp:113
A transformation trait that instantiates seqan3::lazy types. Base template is the identity transforma...
Definition: lazy_conditional.hpp:46
typename instantiate< t >::type instantiate_t
A transformation trait that instantiates seqan3::lazy types. Transformation trait shortcut.
Definition: lazy_conditional.hpp:67
Behaves like std::conditional, but instantiates types wrapped in seqan3::lazy.
Definition: lazy_conditional.hpp:142
instantiate_t< std::conditional_t< decision, on_true_t, on_false_t > > lazy_conditional_t
Behaves like std::conditional_t, but instantiates types wrapped in seqan3::lazy. Transformation trait...
Definition: lazy_conditional.hpp:152
An empty type whose only purpose is to hold an uninstantiated template plus its arguments.
Definition: lazy_conditional.hpp:33