POV-Ray : Newsgroups : povray.off-topic : This is the sort of brokenness... : Re: This is the sort of brokenness... Server Time
6 Sep 2024 11:18:13 EDT (-0400)
  Re: This is the sort of brokenness...  
From: Darren New
Date: 21 Mar 2009 03:12:55
Message: <49c49377@news.povray.org>
Warp wrote:
>   You can't access the private variable by address. Not according to the
> standard. 

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf
Section 3.9 paragraph 2, page 60 sheet 74.

#define N sizeof(T)
char buf[N];
T obj ; // obj initialized to its original value
std::memcpy(buf, &obj, N); // between these two calls to std::memcpy,
                            // obj might be modified
std::memcpy(&obj, buf, N); // at this point, each subobject of obj of scalar 
type
// holds its original value


Yet I'm sure at this point that there will be some reason this doesn't count 
as violating modularity. Will it be that it's only a draft of the standard? 
Will it be that it's only true of POD types? Will it be because it only says 
it works for reading and writing all the private variables at once?

-- 
   Darren New, San Diego CA, USA (PST)
   My fortune cookie said, "You will soon be
   unable to read this, even at arm's length."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.