Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  26 Nov 2025, Lars Martin, Suggestion, mvodb WS and family type matching 
    Reply  27 Nov 2025, Konstantin Olchanski, Suggestion, mvodb WS and family type matching 
       Reply  27 Nov 2025, Stefan Ritt, Suggestion, mvodb WS and family type matching 
Message ID: 3158     Entry time: 27 Nov 2025     In reply to: 3151
Author: Stefan Ritt 
Topic: Suggestion 
Subject: mvodb WS and family type matching 
> 2) "advanced" c++ code:
> 
> void foo(const std::string& xxx) { ... };
> int main() { foo("bar"); }
> 
> copy-created 2nd string is avoided, but string object to hold "bar" is still must be 
> made, 1 malloc(), 1 memcpy().

Are you sure about this? I always thought that foo only receives a pointer to xxx which it puts on the stack, so
no additional malloc/free is involved.

Have a look here: https://en.cppreference.com/w/cpp/language/reference.html

It says "References are not objects; they do not necessarily occupy storage".

Stefan
ELOG V3.1.4-2e1708b5