Skip to content

Commit f86a5dc

Browse files
authored
Merge pull request #10914 from Ivorforce/stl-fixes
Add notes to `Dictionary`, `HashMap` and `Array`.
2 parents e896343 + 9fb7efd commit f86a5dc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

about/faq.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ general-purpose library, but we had special requirements for Godot.
579579
* We use our custom String type, as the one provided by STL is too basic and lacks proper
580580
internationalization support.
581581

582+
Check out :ref:`Godot's container types <doc_cpp_godot_types>` for alternatives.
583+
582584
Why does Godot not use exceptions?
583585
----------------------------------
584586

contributing/development/cpp_usage_guidelines.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ variables and ``nullptr`` is encouraged when possible. Still, try to keep your
4545
use of modern C++ features conservative. Their use needs to serve a real
4646
purpose, such as improving code readability or performance.
4747

48+
.. _doc_cpp_godot_types:
49+
4850
Standard Template Library
4951
~~~~~~~~~~~~~~~~~~~~~~~~~
5052

@@ -75,6 +77,7 @@ scripting API.
7577
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
7678
| ``Array`` 📜 | ``std::vector`` | Values can be of any Variant type. No static typing is imposed. |
7779
| | | Uses shared reference counting, similar to ``std::shared_ptr``. |
80+
| | | Uses Vector<Variant> internally. |
7881
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
7982
| ``TypedArray`` 📜 | ``std::vector`` | Subclass of ``Array`` but with static typing for its elements. |
8083
| | | Not to be confused with ``Packed*Array``, which is internally a ``Vector``. |
@@ -103,7 +106,7 @@ scripting API.
103106
| | | This means it's generally slower but can be copied around almost for free. |
104107
| | | The performance benefits of ``VSet`` aren't established, so prefer using other types. |
105108
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
106-
| ``HashMap`` | ``std::unordered_map`` | **Use this as the "default" map type.** Does not preserve insertion order. |
109+
| ``HashMap`` | ``std::unordered_map`` | **Use this as the "default" map type.** Preserves insertion order. |
107110
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
108111
| ``AHashMap`` | ``std::unordered_map`` | Array-based implementation of a hash map. Does not preserve insertion order. |
109112
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
@@ -118,6 +121,7 @@ scripting API.
118121
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
119122
| ``Dictionary`` 📜 | ``std::unordered_map`` | Keys and values can be of any Variant type. No static typing is imposed. |
120123
| | | Uses shared reference counting, similar to ``std::shared_ptr``. |
124+
| | | Preserves insertion order. Uses ``HashMap<Variant>`` internally. |
121125
+------------------------+--------------------------+---------------------------------------------------------------------------------------+
122126
| ``TypedDictionary`` 📜 | ``std::unordered_map`` | Subclass of ``Dictionary`` but with static typing for its keys and values. |
123127
+------------------------+--------------------------+---------------------------------------------------------------------------------------+

0 commit comments

Comments
 (0)