From 75347236f212f327a5bba10d8a900cc58ebe5de0 Mon Sep 17 00:00:00 2001 From: Pasta Date: Fri, 17 Dec 2021 23:40:06 -0500 Subject: [PATCH] docs: document c-style cast prohibition --- doc/developer-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 18888978568..76aebc55b7d 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -104,6 +104,10 @@ code. - `++i` is preferred over `i++`. - `nullptr` is preferred over `NULL` or `(void*)0`. - `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking. + - Use a named cast or functional cast, not a C-Style cast. When casting + between integer types, use functional casts such as `int(x)` or `int{x}` + instead of `(int) x`. When casting between more complex types, use static_cast. + Use reinterpret_cast and const_cast as appropriate. Block style example: ```c++