tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
language_standard.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_VERSION_LANGUAGE_STANDARD_HPP
5#define TETL_VERSION_LANGUAGE_STANDARD_HPP
6
7#include <etl/_config/all.hpp>
8
9namespace etl {
10
11/// \brief Enumeration for the currently selected C++ standard version. Unlike
12/// the official macro `__cplusplus`, these values only include the published
13/// year. This is to make the actual values smaller and therfore fit on smaller
14/// word sized chips.
15enum struct language_standard : unsigned char {
16 cpp_17 = 17,
17 cpp_20 = 20,
18 cpp_23 = 23,
19 cpp_26 = 26,
20};
21
22/// \brief Compares language_standards
23[[nodiscard]] constexpr auto operator==(language_standard lhs, language_standard rhs) noexcept -> bool
24{
25 return static_cast<unsigned char>(lhs) == static_cast<unsigned char>(rhs);
26}
27
28[[nodiscard]] constexpr auto operator!=(language_standard lhs, language_standard rhs) noexcept -> bool
29{
30 return !(lhs == rhs);
31}
32
33[[nodiscard]] constexpr auto operator<(language_standard lhs, language_standard rhs) noexcept -> bool
34{
35 return static_cast<unsigned char>(lhs) < static_cast<unsigned char>(rhs);
36}
37
38[[nodiscard]] constexpr auto operator<=(language_standard lhs, language_standard rhs) noexcept -> bool
39{
40 return static_cast<unsigned char>(lhs) <= static_cast<unsigned char>(rhs);
41}
42
43[[nodiscard]] constexpr auto operator>(language_standard lhs, language_standard rhs) noexcept -> bool
44{
45 return static_cast<unsigned char>(lhs) > static_cast<unsigned char>(rhs);
46}
47
48[[nodiscard]] constexpr auto operator>=(language_standard lhs, language_standard rhs) noexcept -> bool
49{
50 return static_cast<unsigned char>(lhs) >= static_cast<unsigned char>(rhs);
51}
52
53#if defined(_MSVC_LANG)
54 #define TETL_CPP_STANDARD_FULL _MSVC_LANG
55#else
56 #define TETL_CPP_STANDARD_FULL __cplusplus
57#endif
58
59#if TETL_CPP_STANDARD_FULL > 202302L
60 #define TETL_CPP_STANDARD 26
61/// The currently configured C++ standard.
62inline constexpr auto current_standard = language_standard::cpp_26;
63#elif TETL_CPP_STANDARD_FULL > 202002L
64 #define TETL_CPP_STANDARD 23
65/// The currently configured C++ standard.
66inline constexpr auto current_standard = language_standard::cpp_23;
67#else
68 #error "Unsupported C++ language standard. TETL requires at least C++23"
69#endif
70
71} // namespace etl
72
73#endif // TETL_VERSION_LANGUAGE_STANDARD_HPP
Definition adjacent_find.hpp:9
constexpr auto operator<=(language_standard lhs, language_standard rhs) noexcept -> bool
Definition language_standard.hpp:38
constexpr auto operator>(language_standard lhs, language_standard rhs) noexcept -> bool
Definition language_standard.hpp:43
language_standard
Enumeration for the currently selected C++ standard version. Unlike the official macro __cplusplus,...
Definition language_standard.hpp:15
constexpr auto operator>=(language_standard lhs, language_standard rhs) noexcept -> bool
Definition language_standard.hpp:48
constexpr auto operator==(language_standard lhs, language_standard rhs) noexcept -> bool
Compares language_standards.
Definition language_standard.hpp:23
constexpr auto operator<(language_standard lhs, language_standard rhs) noexcept -> bool
Definition language_standard.hpp:33
constexpr auto operator!=(language_standard lhs, language_standard rhs) noexcept -> bool
Definition language_standard.hpp:28