1/ "POD" has a specific meaning (until C++20). "POD" is not a synonym for "primitive data types" (I have just learned that the dedicated name seems to be "Fundamental types" ^^)
I used "POD" for Plain Old Data, but indeed I should have used Fundamental types. We both learned something :)
Your second point is wow, interesting... Even without clang-tidy, I'd warn anyone to not match the declaration with the definition. I'd find it really disturbing :(
I agree, that for small functions, using const value parameters don't add much readability, but in case of longer ones, it gives some extra safety and then I prefer to be consistent.
You can learned new stuffs everyday, and I like that :)
Interesting indeed... "Scary" sounds more accurate to me 😅
In fact, there are other scary stuffs regarding declarations, definitions and redeclaration (yes, you can re-declare a function without exactly matching the previous declarations). Since you live in France, I suppose you speak French so take a look at the section "Le grand bazar des redéclarations" in this article I wrote about default parameters: "Arguments par défaut d'une fonction en C++". You will get psyched 😂
You're welcome! Glad you found them interesting :)
Thanks, I'm going to read it during the weekend. I just had a glance at it, and yeah, the default parameters for virtual can be problematic. I also wrote a draft about it after we had discussed that in our team a few weeks ago when we activated a new Sonar profile...
By the way, luckily the const mismatch doesn't work with references or pointers to const data.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello,
I have 2 remarks:
1/ "POD" has a specific meaning (until C++20). "POD" is not a synonym for "primitive data types" (I have just learned that the dedicated name seems to be "Fundamental types" ^^)
See:
2/ It's worth noting that
const
for parameters is only relevant for functions definitions, not function declarations.For example, the following code is valid:
clang-tidy warns about it:
Personally, I don't use
const
for base types. But for other typesconst&
is of course the default way :)Thanks, for your remarks!
I used "POD" for Plain Old Data, but indeed I should have used Fundamental types. We both learned something :)
Your second point is wow, interesting... Even without clang-tidy, I'd warn anyone to not match the declaration with the definition. I'd find it really disturbing :(
I agree, that for small functions, using const value parameters don't add much readability, but in case of longer ones, it gives some extra safety and then I prefer to be consistent.
Thanks again for your captivating remarks!
You can learned new stuffs everyday, and I like that :)
Interesting indeed... "Scary" sounds more accurate to me 😅
In fact, there are other scary stuffs regarding declarations, definitions and redeclaration (yes, you can re-declare a function without exactly matching the previous declarations). Since you live in France, I suppose you speak French so take a look at the section "Le grand bazar des redéclarations" in this article I wrote about default parameters: "Arguments par défaut d'une fonction en C++". You will get psyched 😂
You're welcome! Glad you found them interesting :)
Thanks, I'm going to read it during the weekend. I just had a glance at it, and yeah, the default parameters for virtual can be problematic. I also wrote a draft about it after we had discussed that in our team a few weeks ago when we activated a new Sonar profile...
By the way, luckily the const mismatch doesn't work with references or pointers to const data.