Re:Formatting Text in C++: The Old and the New Ways
by heywhatupboys on Saturday September 16, 2023 @05:11PM
(#37538748)
what a language
[ Parent
| on HN ]
Re:Formatting Text in C++: The Old and the New Ways
by lionkor on Saturday September 16, 2023 @05:37PM
(#37538962)
just consider const reference to be the default for non-primitive types
Re:Formatting Text in C++: The Old and the New Ways
by a_e_k on Saturday September 16, 2023 @06:47PM
(#37539566)
My rule of thumb is to use const references when the sizeof the type is larger than the sizeof a pointer or reference.
Re:Formatting Text in C++: The Old and the New Ways
by repsilat on Saturday September 16, 2023 @10:06PM
(#37540776)
Might be worth using values/copies even a bit bigger, so long as it's "simple" data. This[1] short post argues for passing `std::string_view` (~2 pointers) by value, for
- Omitting pointer indirections (loads),
- Not forcing the pointee to have an address (i.e. gotta be in memory, not just registers), and
- Eliminating aliasing questions, potentially leading to better codegen if the function isn't inlined.
1: https://quuxplusone.github.io/blog/2021/11/09/pass-string-vi...