Mountain  1.0.0
Simple C++ 2D Game Framework
concepts.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <format>
4 
5 #include "Mountain/core.hpp"
6 
9 
10 namespace Mountain
11 {
12  class Resource;
13  class Entry;
14  class Component;
15  class Entity;
16  class Font;
17  class Effect;
18  struct Color;
19  struct ColorHsva;
20 
23  namespace Concepts
24  {
26  template <class T>
27  concept ResourceT = std::is_base_of_v<Resource, T>;
28 
30  template <class T>
31  concept LoadableResourceT = std::is_base_of_v<Resource, T> && !std::is_same_v<T, Font>;
32 
34  template <class T>
35  concept EntryT = std::is_base_of_v<Entry, T>;
36 
38  template <class T, class U>
39  concept IsTSameAsU = std::is_same_v<T, U>;
40 
42  template <class T>
43  concept ComponentT = std::is_base_of_v<Component, T>;
44 
46  template <class T>
47  concept EntityT = std::is_base_of_v<Entity, T>;
48 
54  template<typename T>
55  concept FormattableT = requires(T& v, std::format_context ctx)
56  {
57  std::formatter<std::remove_cvref_t<T>>().format(v, ctx);
58  };
59 
61  template<typename T>
62  concept ExceptionT = std::is_base_of_v<std::exception, T>;
63 
65  template <class T>
66  concept FunctionT = std::is_function_v<T>;
67 
68  template <typename From, typename To>
69  concept ConvertibleToT = std::convertible_to<From, To>;
70 
72  template <class T>
73  concept ColorT = std::is_same_v<Color, T> || std::is_same_v<ColorHsva, T>;
74 
76  template <typename T>
77  concept PointerT = std::is_pointer_v<T>;
78 
80  template <typename T>
81  concept IntegralT = std::is_integral_v<T>;
82 
83  template <typename T>
84  concept EnumT = std::is_enum_v<T>;
85 
86  template <class T>
87  concept EffectT = std::is_base_of_v<Effect, T>;
88  }
89 }
concept ComponentT
Concept that forces a type to be a child of Component.
Definition: concepts.hpp:43
concept EntityT
Concept that forces a type to be a child of Entity.
Definition: concepts.hpp:47
concept EntryT
A class satisfies the EntryT concept if it is derived of Entry.
Definition: concepts.hpp:35
concept PointerT
Concept that forces a type to be a raw pointer.
Definition: concepts.hpp:77
concept IsTSameAsU
Concept that forces a class to be same as the others.
Definition: concepts.hpp:39
concept FunctionT
Concept that forces a type to be a function.
Definition: concepts.hpp:66
concept IntegralT
Concept that forces a type to be of an integral type.
Definition: concepts.hpp:81
concept FormattableT
The Formattable concept requires a type to be formattable.
Definition: concepts.hpp:55
concept ExceptionT
A class satisfies the ExceptionT concept if it is derived of Exception.
Definition: concepts.hpp:62
concept ColorT
Concept that forces a type to be a color, e.g. either Color or ColorHsva.
Definition: concepts.hpp:73
concept LoadableResourceT
A class satisfies the LoadableResourceT concept if it is derived of Resource and is not the Font clas...
Definition: concepts.hpp:31
Contains useful general-use concepts.
Definition: concepts.hpp:19
concept ResourceT
A class satisfies the ResourceT concept if it is derived of Resource.
Definition: concepts.hpp:27
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22