Seregon/ShadPKG

A tool for deriving PKG packet encryption keys for ps4 written in c++

C++/47.3 KB/No license
common/concepts.h
ShadPKG / common / concepts.h
1// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3 
4#pragma once
5 
6#include <concepts>
7#include <iterator>
8#include <type_traits>
9 
10namespace Common {
11 
12// Check if type satisfies the ContiguousContainer named requirement.
13template <typename T>
14concept IsContiguousContainer = std::contiguous_iterator<typename T::iterator>;
15 
16template <typename Derived, typename Base>
17concept DerivedFrom = std::derived_from<Derived, Base>;
18 
19// TODO: Replace with std::convertible_to when libc++ implements it.
20template <typename From, typename To>
21concept ConvertibleTo = std::is_convertible_v<From, To>;
22 
23// No equivalents in the stdlib
24 
25template <typename T>
26concept IsArithmetic = std::is_arithmetic_v<T>;
27 
28template <typename T>
29concept IsIntegral = std::is_integral_v<T>;
30 
31} // namespace Common
32