BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
core_language.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
14#pragma once
15
16#include <concepts>
17#include <type_traits>
18
19#include <bio/core.hpp>
20
21namespace bio::meta
22{
23
32template <class T, class U>
34 requires(std::remove_reference_t<T> const & t, std::remove_reference_t<U> const & u) {
35 requires std::convertible_to<decltype(t == u), bool>;
36 requires std::convertible_to<decltype(t != u), bool>;
37 requires std::convertible_to<decltype(u == t), bool>;
38 requires std::convertible_to<decltype(u != t), bool>;
39 };
40
45template <typename t1, typename t2>
47 requires std::convertible_to<decltype(v1 < v2), bool>;
48 requires std::convertible_to<decltype(v1 <= v2), bool>;
49 requires std::convertible_to<decltype(v1 > v2), bool>;
50 requires std::convertible_to<decltype(v1 >= v2), bool>;
51
52 requires std::convertible_to<decltype(v2 < v1), bool>;
53 requires std::convertible_to<decltype(v2 <= v1), bool>;
54 requires std::convertible_to<decltype(v2 > v1), bool>;
55 requires std::convertible_to<decltype(v2 >= v1), bool>;
56};
57
61template <typename t>
62concept arithmetic = std::is_arithmetic_v<t>;
63
68template <typename t>
69concept floating_point = arithmetic<t> && std::is_floating_point_v<t>;
70
73template <typename query_t, typename... other_types>
74concept one_of = (BIOCPP_IS_SAME(query_t, other_types) || ...);
75
80template <typename t>
83
88template <typename type>
90
95template <typename t>
96concept trivially_destructible = std::destructible<t> && std::is_trivially_destructible_v<t>;
97
102template <typename t>
103concept trivially_copyable = std::copyable<t> && std::is_trivially_copyable_v<t>;
104
110template <typename t>
111concept trivial = trivially_copyable<t> && trivially_destructible<t> && std::is_trivial_v<t>;
112
116template <typename t>
117concept standard_layout = std::is_standard_layout_v<t>;
118
127template <typename t, typename u>
128concept weakly_assignable_from = std::is_assignable_v<t, u>;
129
132template <typename from_t, typename to_t>
133concept decays_to = std::same_as<std::decay_t<from_t>, std::decay_t<to_t>>;
134
137template <typename from_t, typename to_t>
139
142template <typename t>
143concept constexpr_default_initializable = std::default_initializable<t> && BIOCPP_IS_CONSTEXPR(t{});
144
146
147} // namespace bio::meta
A type that satisfies std::is_arithmetic_v<t>.
Definition: core_language.hpp:62
This concept encompasses exactly the types char, signed char, unsigned char, wchar_t,...
Definition: core_language.hpp:81
A type that is std::default_initializable<t> at compile-time.
Definition: core_language.hpp:143
Resolves to std::same_as<std::decay_t<t>, std::decay_t<u>>.
Definition: core_language.hpp:133
The negation of bio::meta::decays_to.
Definition: core_language.hpp:138
An arithmetic type that also satisfies std::is_floating_point_v<t>.
Definition: core_language.hpp:69
This concept encompasses exactly the types char, wchar_t, char16_t and char32_t.
Definition: core_language.hpp:89
Resolves to (std::same_as<query_t, other_types> || ...).
Definition: core_language.hpp:74
Resolves to std::is_standard_layout_v<t>.
Definition: core_language.hpp:117
A type that satisfies bio::meta::trivially_copyable and bio::meta::trivially_destructible.
Definition: core_language.hpp:111
A type that satisfies std::is_trivially_copyable_v<t>.
Definition: core_language.hpp:103
A type that satisfies std::is_trivially_destructible_v<t>.
Definition: core_language.hpp:96
Resolves to std::is_assignable_v<t>.
Definition: core_language.hpp:128
Requires the two operands to be comparable with == and != in both directions.
Definition: core_language.hpp:33
Requires the two operands to be comparable with <, <=, > and >= in both directions.
Definition: core_language.hpp:46
Provides platform and dependency checks.
#define BIOCPP_IS_CONSTEXPR(...)
Returns true if the expression passed to this macro can be evaluated at compile time,...
Definition: core.hpp:182
#define BIOCPP_IS_SAME(...)
A macro that behaves like std::is_same_v, except that it doesn't need to instantiate the template on ...
Definition: core.hpp:175
The Meta module's namespace.