@@ -55,16 +55,39 @@ See :ref:`doc_faq_why_not_stl` for more information.
55
55
This means that pull requests should **not ** use ``std::string ``,
56
56
``std::vector `` and the like. Instead, use Godot's datatypes as described below:
57
57
58
- - Use ``String `` instead of ``std::string ``.
59
- - Use ``Vector `` instead of ``std::vector ``. In some cases, ``LocalVector ``
60
- can be used as an alternative (ask core developers first).
61
- - Use ``Array `` instead of ``std::array ``.
58
+ +------------------------+----------------------------+-------------------------------------------+
59
+ | C++ STL datatype | Recommended Godot datatype | Alternative Godot datatype* |
60
+ +========================+============================+===========================================+
61
+ | ``std::string `` | ``String `` | ``StringName `` |
62
+ +------------------------+----------------------------+-------------------------------------------+
63
+ | ``std::vector `` | ``Vector `` | ``LocalVector `` |
64
+ +------------------------+----------------------------+-------------------------------------------+
65
+ | ``std::array `` | ``Array `` | ``TypedArray `` |
66
+ +------------------------+----------------------------+-------------------------------------------+
67
+ | ``std::span `` | ``Span `` | |
68
+ +------------------------+----------------------------+-------------------------------------------+
69
+ | ``std::set `` | ``HashSet `` | ``RBSet `` |
70
+ +------------------------+----------------------------+-------------------------------------------+
71
+ | ``std::map `` | ``OAHashMap `` | ``AHashMap ``, ``HashMap ``, ``Dictionary `` |
72
+ +------------------------+----------------------------+-------------------------------------------+
73
+ | ``std::unordered_map `` | ``OAHashMap `` | ``AHashMap ``, ``HashMap ``, ``Dictionary `` |
74
+ +------------------------+----------------------------+-------------------------------------------+
75
+ | ``std::pair `` | ``Pair `` | |
76
+ +------------------------+----------------------------+-------------------------------------------+
77
+ | ``std::variant `` | ``Variant `` | |
78
+ +------------------------+----------------------------+-------------------------------------------+
79
+
80
+ \* : For certain use cases, this alternative datatype is more performant or has
81
+ characteristics that are more suitable for the task at hand. However, it is not
82
+ always a direct replacement for the recommended datatype. Ask for advice if you
83
+ are unsure.
62
84
63
85
.. note ::
64
86
65
- Godot also has a List datatype (which is a linked list). While List is already used
66
- in the codebase, it typically performs worse than other datatypes like Vector
67
- and Array. Therefore, List should be avoided in new code unless necessary.
87
+ Godot also has a ``List `` datatype (which is a linked list). While ``List ``
88
+ is already used in the codebase, it typically performs worse than other
89
+ datatypes like ``Vector `` and ``Array ``. Therefore, ``List `` should be
90
+ avoided in new code unless necessary.
68
91
69
92
``auto `` keyword
70
93
~~~~~~~~~~~~~~~~
0 commit comments