Talk:New coding guidelines: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
Line 13: Line 13:
-- [[User:Tracer|Tracer]] ([[User talk:Tracer|talk]]) 18:57, 25 June 2024 (UTC)
-- [[User:Tracer|Tracer]] ([[User talk:Tracer|talk]]) 18:57, 25 June 2024 (UTC)


::It doesn't really matter, but I personally find using auto* more readable. This one star doesn't change anything, it doesn't cost much, and it always makes the code more readable at first glance, without having to look at the entire line to know that it will be a pointer. -- [[User:FileEX|FileEX]] ([[User talk:FileEX|talk]]) 01:44, 26 June 2024 (UTC)
::It doesn't really matter, but I personally find using auto* more readable. This one small asterisk doesn't change anything, it doesn't cost much, and it always makes the code more readable at first glance, without having to look at the entire line to know that it will be a pointer. -- [[User:FileEX|FileEX]] ([[User talk:FileEX|talk]]) 01:44, 26 June 2024 (UTC)

Latest revision as of 23:47, 25 June 2024

auto vs auto*

When you use static_cast, wouldn't it be better to use auto instead of auto*?

auto* obj = static_cast<Class*>(object);
// vs
auto obj = static_cast<Class*>(object);

It would have the same result. Yes, * marks the variable as a pointer but from the cast we can see that it is a pointer nonetheless.

-- Tracer (talk) 18:57, 25 June 2024 (UTC)

It doesn't really matter, but I personally find using auto* more readable. This one small asterisk doesn't change anything, it doesn't cost much, and it always makes the code more readable at first glance, without having to look at the entire line to know that it will be a pointer. -- FileEX (talk) 01:44, 26 June 2024 (UTC)