Date: Sun, 9 Aug 2020 00:50:17 +0200
Il 08/08/20 20:31, Walt Karas via Std-Proposals ha scritto:
>
> void f(T &v)
> {
> char cpy[sizeof(T)];
> std::memcpy(cpy, &v, sizeof(T));
> std::memset(&v, 0, sizeof(T));
> std::memcpy(&v, cpy, sizeof(T));
> g(v);
> }
>
> But I can't think of an example of a type T where it wouldn't work. Can you?
An object of some atomic type?
Thanks,
>
> void f(T &v)
> {
> char cpy[sizeof(T)];
> std::memcpy(cpy, &v, sizeof(T));
> std::memset(&v, 0, sizeof(T));
> std::memcpy(&v, cpy, sizeof(T));
> g(v);
> }
>
> But I can't think of an example of a type T where it wouldn't work. Can you?
An object of some atomic type?
Thanks,
-- Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
Received on 2020-08-08 17:53:45