More about strings - passing strings to functions: Revision history

From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽

Diff selection: Mark the radio buttons of the revisions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with latest revision, (prev) = difference with preceding revision, m = minor edit.

    22 February 2024

    • curprev 23:2623:26, 22 February 2024Jimg talk contribs 2,765 bytes +2,765 Created page with "== Is it better to pass as a const reference, or by value and then use std::move()? == It depends. Here's a concise explanation from Stack Overflow. There are three cases: →‎(0): Creature(const std::string &name) : m_name{name} { } A passed lvalue binds to name, then is copied into m_name. A passed rvalue binds to name, then is copied into m_name. →‎(1): Creature(std::string name) : m_name{std::move(name)} { } A passed lvalue is copied into name, t..."