-
Notifications
You must be signed in to change notification settings - Fork 3
migrate to c++23 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
700d37b
migrate to c++23
leissa 3a7dfbd
Merge branch 'main' into cpp23
leissa 219c741
removed duplicates from fe::Tab
leissa 2458048
msvc fix
leissa b419d96
added operator<<(std::ostream&, const Join&)
leissa ba41eb8
removed err(ln)/out(ln) in favor of std::print(ln)
leissa f12218e
added assertf
leissa 23f1fbd
cleanup
leissa a247e97
added format test
leissa 5060e6b
remove fe::join.
leissa bf62b64
fix dangling ref bug in fe::Formattable
leissa ffc9c32
polish format.h
leissa 0cfe8b3
removing dubious helpers in fe::Tab
leissa f5c96dd
format.h: polish
leissa e29ba0d
fix format.h review thread issues
Copilot 96d0cd6
style: normalize assertf newline formatting
Copilot 4a42c39
polish assertf macro
leissa 1121323
simplify fe/enum.h
leissa 8fc13e4
linux/doxygen: use gcc/g++ 14
leissa 70fa96b
fix install command
leissa 32523d2
put BitEnum operators into global scope
leissa 5c36ffd
put enum stuff into correct order
leissa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,62 +1,42 @@ | ||
| #pragma once | ||
|
|
||
| #include <compare> | ||
|
|
||
| #include <type_traits> | ||
|
|
||
| namespace fe { | ||
|
|
||
| /// @name is_enum | ||
| ///@{ | ||
| template<typename T> | ||
| struct is_bit_enum : std::false_type {}; | ||
| template<class T> | ||
| inline constexpr bool is_bit_enum_v = is_bit_enum<T>::value; | ||
| template<class E> | ||
| concept BitEnum = std::is_enum_v<E> && is_bit_enum_v<E>; | ||
| ///@} | ||
|
|
||
| /// @name Bit operations for enum classs | ||
| /// Provides all kind of bit and comparison operators for an `enum class` @p E. | ||
| /// Note that the bit operators return @p E's underlying type and not the original `enum` @p E. | ||
| /// This is because the result may not be a valid `enum` value. | ||
| /// For the same reason, it doesn't make sense to declare operators such as `&=`. | ||
| /// Use like this: | ||
| /// ``` | ||
| /// using fe::operator&; | ||
| /// using fe::operator|; | ||
| /// using fe::operator^; | ||
| /// using fe::operator<=>; | ||
| /// using fe::operator==; | ||
| /// using fe::operator!=; | ||
| /// | ||
| /// enum class MyEnum : unsigned { | ||
| /// A = 1 << 0, | ||
| /// B = 1 << 1, | ||
| /// C = 1 << 2, | ||
| /// }; | ||
| /// | ||
| /// template<> struct fe::is_bit_enum<MyEnum> : std::true_type { }; | ||
| /// template<> struct fe::is_bit_enum<MyEnum> : std::true_type {}; | ||
| /// ``` | ||
| ///@{ | ||
| // clang-format off | ||
| template <BitEnum E> constexpr auto operator&(E x, E y) { return std::underlying_type_t<E>(x) & std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr auto operator&(std::underlying_type_t<E> x, E y) { return x & std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr auto operator&( E x, std::underlying_type_t<E> y) { return std::underlying_type_t<E>(x) & y ; } | ||
| template <BitEnum E> constexpr auto operator|( E x, E y) { return std::underlying_type_t<E>(x) | std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr auto operator|(std::underlying_type_t<E> x, E y) { return x | std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr auto operator|( E x, std::underlying_type_t<E> y) { return std::underlying_type_t<E>(x) | y ; } | ||
| template <BitEnum E> constexpr auto operator^( E x, E y) { return std::underlying_type_t<E>(x) ^ std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr auto operator^(std::underlying_type_t<E> x, E y) { return x ^ std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr auto operator^( E x, std::underlying_type_t<E> y) { return std::underlying_type_t<E>(x) ^ y ; } | ||
| template <BitEnum E> constexpr std::strong_ordering operator<=>(std::underlying_type_t<E> x, E y) { return x <=> std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr std::strong_ordering operator<=>(E x, std::underlying_type_t<E> y) { return std::underlying_type_t<E>(x) <=> y; } | ||
| template <BitEnum E> constexpr bool operator==(std::underlying_type_t<E> x, E y) { return x == std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr bool operator!=(std::underlying_type_t<E> x, E y) { return x != std::underlying_type_t<E>(y); } | ||
| template <BitEnum E> constexpr bool operator==(E x, std::underlying_type_t<E> y) { return std::underlying_type_t<E>(x) == y; } | ||
| template <BitEnum E> constexpr bool operator!=(E x, std::underlying_type_t<E> y) { return std::underlying_type_t<E>(x) != y; } | ||
| // clang-format on | ||
| template<typename T> | ||
| struct is_bit_enum : std::false_type {}; | ||
|
|
||
| ///@} | ||
| template<typename E> | ||
| concept BitEnum = std::is_enum_v<E> && is_bit_enum<E>::value; | ||
|
|
||
| template<fe::BitEnum E> constexpr auto to_underlying(E e) noexcept { return static_cast<std::underlying_type_t<E>>(e); } | ||
|
|
||
| } // namespace fe | ||
|
|
||
| // clang-format off | ||
| template<fe::BitEnum E> constexpr E operator|(E a, E b) noexcept { return static_cast<E>(fe::to_underlying(a) | fe::to_underlying(b)); } | ||
| template<fe::BitEnum E> constexpr E operator&(E a, E b) noexcept { return static_cast<E>(fe::to_underlying(a) & fe::to_underlying(b)); } | ||
| template<fe::BitEnum E> constexpr E operator^(E a, E b) noexcept { return static_cast<E>(fe::to_underlying(a) ^ fe::to_underlying(b)); } | ||
| template<fe::BitEnum E> constexpr E operator~(E a) noexcept { return static_cast<E>(~fe::to_underlying(a)); } | ||
| template<fe::BitEnum E> constexpr E& operator|=(E& a, E b) noexcept { return a = (a | b); } | ||
| template<fe::BitEnum E> constexpr E& operator&=(E& a, E b) noexcept { return a = (a & b); } | ||
| template<fe::BitEnum E> constexpr E& operator^=(E& a, E b) noexcept { return a = (a ^ b); } | ||
|
|
||
| namespace fe { | ||
| template<fe::BitEnum E> constexpr bool has_flag(E value, E flag) noexcept { return (value & flag) == flag; } | ||
| } // namespace fe | ||
|
|
||
| // clang-format on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.