Sujet : Re: Top 10 most common hard skills listed on resumes...
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.cDate : 28. Aug 2024, 15:55:44
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vandpe$3gtv6$1@raubtier-asyl.eternal-september.org>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
User-Agent : Mozilla Thunderbird
Am 28.08.2024 um 15:52 schrieb Thiago Adams:
You have to deallocate only if the ownership still with the
same object. This is not the case when the object is moved.
Take this code
string str;
int main ()
{
string str( "hello" );
::str = move( str );
}
With clang-cl (the MSVC-flavour of clang) the whole string-creation
and destruction is opmized away and the compiler directly checks if
::str contains any externally allocated and if not it makes a short
-string-optimized "copy" to ::str. That's nine instructions for the
whole string copy with clang-cl 17.0.3; no external call.