Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #118341
| From | Andrey Tarasevich <andreytarasevich@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: MSVC-bug |
| Date | 2024-03-01 18:44 -0800 |
| Organization | A noiseless patient Spider |
| Message-ID | <uru3ps$1i8fc$1@dont-email.me> (permalink) |
| References | (2 earlier) <uqlai8$3c3iu$1@raubtier-asyl.eternal-september.org> <uqm260$3gd7u$1@dont-email.me> <uqn5m7$3p98f$2@raubtier-asyl.eternal-september.org> <urrmgq$12lh3$1@dont-email.me> <ursmlf$18r2d$1@raubtier-asyl.eternal-september.org> |
On 03/01/24 5:53 AM, Bonita Montero wrote:
>>
>> You have been told very clearly already that in this case
>> `std::function<>` does not perform any memory allocation in Visual
>> Studio. Neither in Debug nor in Release builds. You imagined it.
>
> Not true ! This code prints "alloc" first with MSVC
> and a Debug-build, but not with Release-builds.
>
???
As you have already been told, your "alloc" originates from
`std::string`, and has nothing to do with `std::function<>`.
Do this
...
int main()
{
function<void ()> fn;
string str( "hello word" );
auto lam = [&str]() { cout << str << endl; };
cout << "---" << endl;
fn = ref( lam );
cout << "---" << endl;
fn();
}
Your "alloc" is printed before the first "---".
--
Best regards,
Andrey
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-02-13 12:07 +0100
Re: MSVC-bug Paavo Helde <eesnimi@osa.pri.ee> - 2024-02-15 15:34 +0200
Re: MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-02-15 12:20 +0100
Re: MSVC-bug Paavo Helde <eesnimi@osa.pri.ee> - 2024-02-16 00:11 +0200
Re: MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-02-16 09:17 +0100
Re: MSVC-bug Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-02-29 20:45 -0800
Re: MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-03-01 14:53 +0100
Re: MSVC-bug Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-03-01 18:44 -0800
Re: MSVC-bug Bonita Montero <Bonita.Montero@gmail.com> - 2024-03-02 07:36 +0100
Re: MSVC-bug Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-03-02 12:38 -0800
csiph-web