-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Making a list of various changes to make this code more up-to-date. Most of these are easy on their own. It will just take time to do them all. I've already finished most of these kinds of changes to Umbra.
-
TCODList
should be replaced withstd::vector
in all cases. - Remove
new
/delete
from libtcod types. These can be treated as values without major issues. Any exceptions can use smart pointers instead ofnew
. - Pointer types should express ownership, ideally with
std::unique_ptr
, but alsostd::shared_ptr
if necessary. Non-owning pointers would still be raw of course. - Class attributes should be initialized. Just put
{};
at the end of simple types rather than= nullptr;
or= 0;
. Any defaults should be moved from the class constructor code to the class itself. - Pointers to strings should be replaced with
std::string
in many cases. Mostly in non-contexpr cases such as class attributes or local variables. In some cases null strings should be replaced with empty strings. Always replacestrdup
. -
#define X Y
constants should generally be replaced withstatic constexpr auto X{Y};
/static constexpr auto X = Y;
constants. -
#define
macros should all be replaced withconstexpr
functions. - Low level calls such as
memcpy
andstrcmp
should generally be replaced with high level operations. - C-style arrays like
int foo[2]
should be replaced withstd::array<int, 2> foo{}
, etc. - File operations should use C++17
<filesystem>
. - For-loops over containers should prefer ranged-based loops.
for (auto& x : y)
; - Many class methods are missing
const
,noexecpt
, and[[nodiscard]]
qualifiers. - Empty constructors and destructors should use
= default;
, they should not have an empty function in the source. - Small functions with few or no dependencies should be moved inline.
- Functions which take pointers, but don't handle nullptr, should be changed to take references.
- Macros such as
MIN
orCLAMP
should be replaced by their C++ functions. - Virtual class overrides are missing the
override
qualifier. - String formatting functions should use
fmt
. - Temporary local variables which don't change should be qualified with
const
. - Unions should be replaced with
std::variant
.
In general follow the C++ Core Guidelines.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request