Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Introducing: Common Concepts
As Dolphin Emulator upgrades to C++20, concepts ought to be applied around the codebase to clean up static assertions and primitive SFINAE. Also, a clang-format rule for concepts has been added. Unfortunately, the Build-bot infrastructure currently has outdated C++ Standard Libraries despite supporting C++20 features. We can work around this issue for the time being by wielding the other new header file introduced by this commit: 'Common/Future/CppLibConcepts.h'. Finally, TypeUtils.h has been re-licensed under the CC0-1.0 public-domain-equivalent license with permission from Pokechu22, its original author and only contributor to it thus far.
- Loading branch information
1 parent
ae18aa0
commit bfcf099
Showing
44 changed files
with
363 additions
and
318 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // 2022 Dolphin Emulator Project | ||
| // SPDX-License-Identifier: CC0-1.0 | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cstddef> | ||
| #include <type_traits> | ||
|
|
||
| #include "Common/TypeUtils.h" | ||
|
|
||
| #include "Common/Future/CppLibConcepts.h" | ||
|
|
||
| namespace Common | ||
| { | ||
| template <class T> | ||
| concept TriviallyCopyable = std::is_trivially_copyable<T>::value; | ||
|
|
||
| template <class T> | ||
| concept NotTriviallyCopyable = !TriviallyCopyable<T>; | ||
|
|
||
| template <class T> | ||
| concept Const = std::is_const<T>::value; | ||
|
|
||
| template <class T> | ||
| concept NotConst = !Const<T>; | ||
|
|
||
| template <class T> | ||
| concept Enumerated = std::is_enum<T>::value; | ||
|
|
||
| template <class T> | ||
| concept NotEnumerated = !Enumerated<T>; | ||
|
|
||
| template <class T> | ||
| concept Class = std::is_class<T>::value; | ||
|
|
||
| template <class T> | ||
| concept Union = std::is_union<T>::value; | ||
|
|
||
| template <class T> | ||
| concept Arithmetic = std::is_arithmetic<T>::value; | ||
|
|
||
| template <class T> | ||
| concept Pointer = std::is_pointer<T>::value; | ||
|
|
||
| template <class T> | ||
| concept Function = std::is_function<T>::value; | ||
|
|
||
| template <class T> | ||
| concept FunctionPointer = Function<std::remove_pointer_t<T>>; | ||
|
|
||
| template <class T> | ||
| concept IntegralOrEnum = std::integral<T> || Enumerated<T>; | ||
|
|
||
| template <class T, class U> | ||
| concept UnderlyingSameAs = std::same_as<std::underlying_type_t<T>, U>; | ||
|
|
||
| template <class T, class U> | ||
| concept SameAsOrUnderlyingSameAs = std::same_as<T, U> || UnderlyingSameAs<T, U>; | ||
|
|
||
| template <size_t N, class... Ts> | ||
| concept CountOfTypes = IsCountOfTypes<N, Ts...>::value; | ||
|
|
||
| template <class T, class... Ts> | ||
| concept ConvertibleFromAllOf = IsConvertibleFromAllOf<T, Ts...>::value; | ||
|
|
||
| template <class T, class... Ts> | ||
| concept SameAsAnyOf = IsSameAsAnyOf<T, Ts...>::value; | ||
| }; // namespace Common |
This file contains 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 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.