Determine read or write ?

L

LaBird

Dear all,

I'd like to know if there is any function or program call
in C++ (without memory protection support by OS),
that can determine whether an object is being read or
written? e.g.,

a = b + c; // a is being written while b and c are being read
a++; // a is being read and written

Also, is there any code that can determine the object
is a lvalue or rvalue?

I think it is possible if a, b and c are user-defined types
(as we can overload operator =, + and ++, and so on),
but how about primitive types?

Thanks in advance.

Regards,
LaBird (Benny).
 
T

Thomas Matthews

LaBird said:
Dear all,

I'd like to know if there is any function or program call
in C++ (without memory protection support by OS),
that can determine whether an object is being read or
written? e.g.,

a = b + c; // a is being written while b and c are being read
a++; // a is being read and written

Also, is there any code that can determine the object
is a lvalue or rvalue?

I think it is possible if a, b and c are user-defined types
(as we can overload operator =, + and ++, and so on),
but how about primitive types?

Thanks in advance.

Regards,
LaBird (Benny).

No, there is no function or vector call when reading from
and writing to memory. For user defined types, one can
put function calls into the assignment, constructors
and destructors.

What do you need this for?

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
 
L

LaBird

Thanks a lot.

My intention is to compute the difference (in contents) of an
object in a period of time, and store the difference as a string.
My plan is, if I write the object A, I can invoke some function to
make a duplicate of the object A', and then when i need to
compute the difference, i can compare the memory contents
between A and A' to get the difference string.

If I can differentiate reads and writes, then I may save some
effort for those objects which have been read only, but not
written during the period, since I can only make A' when I
know a is being written. Thus I can simply check that if A'
does not exist, then any part of object A is not being written.

Regards,
LaBird (Benny).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top