CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
TypeInfo.std.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2023 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
11
12#include "TypeInfo.core.hpp"
13#include "TypeInfo.hpp"
14
20
21namespace CeresEngine {
22
23 template<typename T> class SmartPointerTypeInfo : public TTypeInfo<T, impl::TDereferenceableTypeTrait> {
24 using super = TypeInfo;
25
26 public:
27 using PointerType = T;
28 using ElementType = std::remove_cvref_t<decltype(*std::declval<PointerType>())>;
29
30 public:
32 [[nodiscard]] StringView getName() const noexcept override { return "SPtr"; }
33 };
34
35 template<typename T> struct GetTypeInfo<SPtr<T>> {
36 static const TypeInfo& get() {
37 static const SmartPointerTypeInfo<SPtr<T>> type;
38 return type;
39 }
40 };
41
42 template<typename T, typename Deleter> struct GetTypeInfo<UPtr<T, Deleter>> {
43 static const TypeInfo& get() {
45 return type;
46 }
47 };
48
49 template<typename T> struct GetTypeInfo<RC<T>> {
50 static const TypeInfo& get() {
51 static const SmartPointerTypeInfo<RC<T>> type;
52 return type;
53 }
54 };
55
56 // ---------------------------------------------------------------------------------------------
57
58 template<typename T>
59 class TContainerTypeInfo : public TTypeInfoBase<T, //
60 impl::TConstructibleTypeTrait, //
61 impl::TDestructibleTypeTrait, //
62 impl::TCopyableTypeTrait, //
63 impl::TMovableTypeTrait, //
64 impl::TIterableTypeTrait, //
65 impl::TPushBackableTypeTrait, //
66 impl::TIndexableTypeTrait, //
67 impl::TInsertableTypeTrait, //
68 impl::TErasableTypeTrait //
69 > {
70 using super = TypeInfo;
71
72 public:
73 using VectorType = T;
74 using ElementType = typename VectorType::value_type;
75
76 public:
78 [[nodiscard]] StringView getName() const noexcept override { return "Vector"; }
79 };
80
81 template<typename T, typename Allocator> struct GetTypeInfo<Vector<T, Allocator>> {
82 static const TypeInfo& get() {
84 return type;
85 }
86 };
87
88 template<typename T, size_t N, typename Allocator> struct GetTypeInfo<SmallVector<T, N, Allocator>> {
89 static const TypeInfo& get() {
91 return type;
92 }
93 };
94
95 template<typename T, size_t N> struct GetTypeInfo<Array<T, N>> {
96 static const TypeInfo& get() {
97 static const TContainerTypeInfo<Array<T, N>> type;
98 return type;
99 }
100 };
101
102 template<typename T, typename Allocator> struct GetTypeInfo<List<T, Allocator>> {
103 static const TypeInfo& get() {
104 static const TContainerTypeInfo<List<T, Allocator>> type;
105 return type;
106 }
107 };
108
109 // ---------------------------------------------------------------------------------------------
110
111 template<typename T, typename> class TIteratorTypeInfo;
112
114 template<typename T>
115 class TIteratorTypeInfo<T, std::input_iterator_tag> : public TTypeInfo<T, impl::TDereferenceableTypeTrait, impl::TIncrementableTypeTrait> {
116 public:
118 [[nodiscard]] StringView getName() const noexcept override { return getTypeName<T>(); }
119 };
120
122 template<typename T> requires std::input_iterator<T>
123 struct GetTypeInfo<T> {
124 static const TypeInfo& get() {
125 static const TIteratorTypeInfo<T, std::input_iterator_tag> type;
126 return type;
127 }
128 };
129
130} // namespace CeresEngine
Definition TypeInfo.std.hpp:23
T PointerType
Definition TypeInfo.std.hpp:27
StringView getName() const noexcept override
Definition TypeInfo.std.hpp:32
std::remove_cvref_t< decltype(*std::declval< PointerType >())> ElementType
Definition TypeInfo.std.hpp:28
Definition TypeInfo.std.hpp:69
T VectorType
Definition TypeInfo.std.hpp:73
StringView getName() const noexcept override
Definition TypeInfo.std.hpp:78
typename VectorType::value_type ElementType
Definition TypeInfo.std.hpp:74
Definition TypeInfo.std.hpp:111
Definition TypeInfo.core.hpp:843
Definition TypeInfo.hpp:36
Definition Application.hpp:19
std::unique_ptr< T, Deleter > UPtr
UPtr is a smart pointer that owns and manages another object through a pointer and disposes of that o...
Definition SmartPtr.hpp:28
std::shared_ptr< T > SPtr
SPtr is a smart pointer that retains shared ownership of an object through a pointer.
Definition SmartPtr.hpp:37
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
std::list< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > List
List is a container that supports constant time insertion and removal of elements from anywhere in th...
Definition List.hpp:21
sfl::small_vector< T, N, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > SmallVector
SmallVector is a sequence container similar to Vector.
Definition SmallVector.hpp:31
std::array< T, N > Array
Array is a container that encapsulates fixed size arrays.
Definition Array.hpp:17
CountedPtr< T > RC
RC is a smart pointer that retains shared ownership of an object through a pointer.
Definition SmartPtr.hpp:363
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668
static const TypeInfo & get()