logoalt Hacker News

aw1621107 • today at 7:40 AM • 1 reply • view on HN

If you just want to avoid a copy without adding a null state then it's the reference bit that makes all the difference. Whether that reference is a const reference or not does not matter for optimization, I think.


Replies

cowlevel • today at 7:52 AM

If you make it a non-const reference the compiler won't let you pass a result of another function call such as sum(get_daily_prices())

➕ show 1 reply