BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
core.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
9#pragma once
10
11#include <cinttypes>
12#include <ciso646> // makes _LIBCPP_VERSION available
13#include <cstddef> // makes __GLIBCXX__ available
14
20// ============================================================================
21// C++ standard and features
22// ============================================================================
23
24// C++ standard [required]
25#ifdef __cplusplus
26static_assert(__cplusplus >= 201709, "BioCpp-Core requires C++20, make sure that you have set -std=c++20.");
27#else
28# error "This is not a C++ compiler."
29#endif
30
31#if __has_include(<version>)
32# include <version>
33#endif
34
35// ============================================================================
36// Dependencies
37// ============================================================================
38
39// Self [required]
40#if !__has_include(<bio/core.hpp>)
41# error BioC++ include directory not set correctly. Forgot to add -I ${INSTALLDIR}/include to your CXXFLAGS?
42#endif
43
44// ============================================================================
45// Documentation
46// ============================================================================
47
48// Doxygen related
49// this macro is a NO-OP unless doxygen parses it, in which case it resolves to the argument
50#ifndef BIOCPP_DOXYGEN_ONLY
51# define BIOCPP_DOXYGEN_ONLY(x)
52#endif
53
54// ============================================================================
55// Compiler Workarounds
56// ============================================================================
57
64#if defined(__GNUC__) && (__GNUC__ == 10 && __GNUC_MINOR__ <= 1)
65# pragma GCC warning \
66 "Be aware that gcc 10.0 and 10.1 are known to have several bugs that might make BioC++ fail to compile. Please use gcc >= 10.2."
67#endif // defined(__GNUC__) && (__GNUC__ == 10 && __GNUC_MINOR__ <= 1)
68
70#ifndef BIOCPP_WORKAROUND_GCC_96070 // fixed since gcc10.4
71# if (defined(__GNUC__) && (__GNUC__ == 10 && __GNUC_MINOR__ < 4)) || defined(__clang__)
72# define BIOCPP_WORKAROUND_GCC_96070 1
73# else
74# define BIOCPP_WORKAROUND_GCC_96070 0
75# endif
76#endif
77
78#if BIOCPP_DOXYGEN_ONLY(1) 0
80# define BIOCPP_DISABLE_LEGACY_STD_DIAGNOSTIC
81#endif // BIOCPP_DOXYGEN_ONLY(1)0
82
83#if defined(_GLIBCXX_USE_CXX11_ABI) && _GLIBCXX_USE_CXX11_ABI == 0
84# ifndef BIOCPP_DISABLE_LEGACY_STD_DIAGNOSTIC
85# pragma GCC warning \
86 "Your compiler has set -D_GLIBCXX_USE_CXX11_ABI=0. Please switch to a compiler that does not. You can disable this warning by setting -DBIOCPP_DISABLE_LEGACY_STD_DIAGNOSTIC."
87# endif // BIOCPP_DISABLE_LEGACY_STD_DIAGNOSTIC
88#endif // _GLIBCXX_USE_CXX11_ABI == 0
89
91#ifndef BIOCPP_WORKAROUND_CLANG_58078
92# if defined(__clang__)
93# define BIOCPP_WORKAROUND_CLANG_58078 1
94# else
95# define BIOCPP_WORKAROUND_CLANG_58078 0
96# endif
97#endif
98
100#ifndef BIOCPP_WORKAROUND_CLANG_59501
101# if defined(__clang__)
102# define BIOCPP_WORKAROUND_CLANG_59501 1
103# else
104# define BIOCPP_WORKAROUND_CLANG_59501 0
105# endif
106#endif
107
108// ============================================================================
109// Define our version
110// ============================================================================
111
113#define BIOCPP_CORE_VERSION_MAJOR 0
115#define BIOCPP_CORE_VERSION_MINOR 7
117#define BIOCPP_CORE_VERSION_PATCH 0
118
120#define BIOCPP_CORE_VERSION \
121 (BIOCPP_CORE_VERSION_MAJOR * 10000 + BIOCPP_CORE_VERSION_MINOR * 100 + BIOCPP_CORE_VERSION_PATCH)
122
126#define BIOCPP_CORE_VERSION_CSTRING_HELPER_STR(str) #str
127
129#define BIOCPP_CORE_VERSION_CSTRING_HELPER_FUNC(MAJOR, MINOR, PATCH) \
130 BIOCPP_CORE_VERSION_CSTRING_HELPER_STR(MAJOR) \
131 "." BIOCPP_CORE_VERSION_CSTRING_HELPER_STR(MINOR) "." BIOCPP_CORE_VERSION_CSTRING_HELPER_STR(PATCH)
132
134#define BIOCPP_CORE_VERSION_CSTRING \
135 BIOCPP_CORE_VERSION_CSTRING_HELPER_FUNC(BIOCPP_CORE_VERSION_MAJOR, \
136 BIOCPP_CORE_VERSION_MINOR, \
137 BIOCPP_CORE_VERSION_PATCH)
138
139#include <string_view>
140
144namespace bio
145{
146
153
156
157} // namespace bio
158
159#undef BIOCPP_CORE_VERSION_CSTRING_HELPER_STR
160#undef BIOCPP_CORE_VERSION_CSTRING_HELPER_FUNC
161
162// ============================================================================
163// Macros for general use within libraries
164// ============================================================================
165
170#if defined(__clang__)
171# define BIOCPP_IS_SAME(...) __is_same(__VA_ARGS__)
172#elif defined(__GNUC__)
173# define BIOCPP_IS_SAME(...) __is_same_as(__VA_ARGS__)
174#else
175# define BIOCPP_IS_SAME(...) std::is_same_v<__VA_ARGS__>
176#endif
177
182#define BIOCPP_IS_CONSTEXPR(...) std::integral_constant<bool, __builtin_constant_p((__VA_ARGS__, 0))>::value
183
186#define BIOCPP_UNREACHABLE __builtin_unreachable(); /* GCOVR_EXCL_LINE */
187
188// ============================================================================
189// Alphabet namespaces
190// ============================================================================
191
198namespace bio::alphabet
199{}
200
207namespace bio::alphabet::custom
208{}
209
215namespace bio::alphabet
216{
217inline namespace literals
218{}
219} // namespace bio::alphabet
220
232namespace bio::alphabet::detail
233{}
234
235// ============================================================================
236// Meta namespaces
237// ============================================================================
238
251namespace bio::meta
252{}
253
259namespace bio::meta
260{
261inline namespace literals
262{}
263} // namespace bio::meta
264
275namespace bio::meta::detail
276{}
277
278// ============================================================================
279// Ranges namespaces
280// ============================================================================
281
286namespace bio::ranges
287{}
288
303namespace bio::ranges::views
304{}
305
306#ifndef BIOCPP_NO_NAMESPACE_ALIASES
307namespace bio
308{
309namespace views = ranges::views;
310} // namespace bio
311#endif
312
323namespace bio::ranges::detail
324{}
#define BIOCPP_CORE_VERSION_MAJOR
The major version as MACRO.
Definition: core.hpp:113
#define BIOCPP_CORE_VERSION_CSTRING
The full version as null terminated string.
Definition: core.hpp:134
#define BIOCPP_CORE_VERSION_PATCH
The patch version as MACRO.
Definition: core.hpp:117
#define BIOCPP_CORE_VERSION_MINOR
The minor version as MACRO.
Definition: core.hpp:115
A namespace for third party and standard library specialisations of BioC++ customisation points.
Definition: concept.hpp:43
The alphabet module's namespace.
Definition: aa10li.hpp:23
The Meta module's namespace.
The BioC++ namespace for views.
The ranges module's namespace.
The main BioC++ namespace.
Definition: aa10li.hpp:23
constexpr std::string_view biocpp_core_version
The full version as std::string_view.
Definition: core.hpp:155
constexpr size_t biocpp_core_version_minor
The minor version.
Definition: core.hpp:150
constexpr size_t biocpp_core_version_patch
The patch version.
Definition: core.hpp:152
constexpr size_t biocpp_core_version_major
The major version.
Definition: core.hpp:148