Determine read or write ?

Discussion in 'C++' started by LaBird, Jun 26, 2003.

  1. LaBird

    LaBird Guest

    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).
     
    LaBird, Jun 26, 2003
    #1
    1. Advertisements

  2. LaBird wrote:
    > 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
     
    Thomas Matthews, Jun 26, 2003
    #2
    1. Advertisements

  3. LaBird

    LaBird Guest

    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).


    "Thomas Matthews" <> wrote in message
    news:...
    > LaBird wrote:
    > > 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
    >
     
    LaBird, Jun 27, 2003
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Isaac
    Replies:
    0
    Views:
    2,615
    Isaac
    Jul 10, 2003
  2. RBB
    Replies:
    5
    Views:
    512
    Andy Jacobs
    Apr 28, 2005
  3. Peña, Botp
    Replies:
    1
    Views:
    465
    Robert Klemme
    Jan 24, 2004
  4. Trans
    Replies:
    3
    Views:
    353
    Trans
    Dec 21, 2005
  5. Sisyphus
    Replies:
    4
    Views:
    217
    Sisyphus
    Mar 17, 2006
  6. sahm
    Replies:
    4
    Views:
    903
  7. JL
    Replies:
    2
    Views:
    248
    Tim Chase
    Dec 14, 2013
  8. Chris Angelico
    Replies:
    4
    Views:
    320
    Tim Chase
    Dec 19, 2013
Loading...