31
31
#pragma once
32
32
33
33
#include < godot_cpp/core/type_info.hpp>
34
+ #include < godot_cpp/templates/pair.hpp>
34
35
#include < godot_cpp/variant/dictionary.hpp>
35
36
#include < godot_cpp/variant/variant.hpp>
36
37
@@ -57,6 +58,13 @@ class TypedDictionary : public Dictionary {
57
58
_FORCE_INLINE_ TypedDictionary () {
58
59
set_typed (Variant::OBJECT, K::get_class_static (), Variant (), Variant::OBJECT, V::get_class_static (), Variant ());
59
60
}
61
+ _FORCE_INLINE_ TypedDictionary (std::initializer_list<KeyValue<K, V>> p_init) :
62
+ Dictionary() {
63
+ set_typed (Variant::OBJECT, K::get_class_static (), Variant (), Variant::OBJECT, V::get_class_static (), Variant ());
64
+ for (const KeyValue<K, V> &E : p_init) {
65
+ operator [](E.key ) = E.value ;
66
+ }
67
+ }
60
68
};
61
69
62
70
// specialization for the rest of variant types
@@ -83,6 +91,13 @@ class TypedDictionary : public Dictionary {
83
91
_FORCE_INLINE_ TypedDictionary () { \
84
92
set_typed (Variant::OBJECT, T::get_class_static (), Variant (), m_variant_type, StringName (), Variant ()); \
85
93
} \
94
+ _FORCE_INLINE_ TypedDictionary (std::initializer_list<KeyValue<T, m_type>> p_init) : \
95
+ Dictionary() { \
96
+ set_typed (Variant::OBJECT, T::get_class_static (), Variant (), m_variant_type, StringName (), Variant ()); \
97
+ for (const KeyValue<T, m_type> &E : p_init) { \
98
+ operator [](E.key ) = E.value ; \
99
+ } \
100
+ } \
86
101
}; \
87
102
template <typename T> \
88
103
class TypedDictionary <m_type, T> : public Dictionary { \
@@ -105,6 +120,13 @@ class TypedDictionary : public Dictionary {
105
120
_FORCE_INLINE_ TypedDictionary () { \
106
121
set_typed (m_variant_type, StringName (), Variant (), Variant::OBJECT, T::get_class_static (), Variant ()); \
107
122
} \
123
+ _FORCE_INLINE_ TypedDictionary (std::initializer_list<KeyValue<m_type, T>> p_init) : \
124
+ Dictionary() { \
125
+ set_typed (m_variant_type, StringName (), Variant (), Variant::OBJECT, StringName (), Variant ()); \
126
+ for (const KeyValue<m_type, T> &E : p_init) { \
127
+ operator [](E.key ) = E.value ; \
128
+ } \
129
+ } \
108
130
};
109
131
110
132
#define MAKE_TYPED_DICTIONARY_EXPANDED (m_type_key, m_variant_type_key, m_type_value, m_variant_type_value ) \
@@ -129,6 +151,13 @@ class TypedDictionary : public Dictionary {
129
151
_FORCE_INLINE_ TypedDictionary () { \
130
152
set_typed (m_variant_type_key, StringName (), Variant (), m_variant_type_value, StringName (), Variant ()); \
131
153
} \
154
+ _FORCE_INLINE_ TypedDictionary (std::initializer_list<KeyValue<m_type_key, m_type_value>> p_init) : \
155
+ Dictionary() { \
156
+ set_typed (m_variant_type_key, StringName (), Variant (), m_variant_type_value, StringName (), Variant ()); \
157
+ for (const KeyValue<m_type_key, m_type_value> &E : p_init) { \
158
+ operator [](E.key ) = E.value ; \
159
+ } \
160
+ } \
132
161
};
133
162
134
163
#define MAKE_TYPED_DICTIONARY_NIL (m_type, m_variant_type ) \
0 commit comments