Thread: Iterator quandary

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    1,644
    I see that with the precedence thing we were talking past each other for the most part. You are absolutely correct that the pointer version behaves as if the dereference happens first since it happens to the pre-incremented object. So if you were to expand x = *p++ you would rewrite it as x = *p; ++p, dereferencing the pointer first.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  2. #2
    Registered User Sir Galahad's Avatar
    Join Date
    Nov 2016
    Location
    The Round Table
    Posts
    277
    Quote Originally Posted by john.c View Post
    I see that with the precedence thing we were talking past each other for the most part. You are absolutely correct that the pointer version behaves as if the dereference happens first since it happens to the pre-incremented object. So if you were to expand x = *p++ you would rewrite it as x = *p; ++p, dereferencing the pointer first.
    Well it is bound to happen sometimes. Thanks for the input, by the way. It really did help push me towards a more satisfactory solution. The "iterant functor" paradigm is very simple, which is great from the standpoint of someone working on an third-party library, as it should be much easier for users to conform to such an interface. No confusing C++ incantations, just define a few simple member functions and done!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. std::iterator::pointer and std::iterator::reference
    By etrusks in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2016, 11:27 AM
  2. Replies: 19
    Last Post: 01-06-2012, 03:01 PM
  3. Connecting input iterator to output iterator
    By QuestionC in forum C++ Programming
    Replies: 2
    Last Post: 04-10-2007, 02:18 AM
  4. std::map::iterator
    By Magos in forum C++ Programming
    Replies: 2
    Last Post: 02-03-2006, 07:47 PM
  5. Hmm. A Quandary. Rounding/adding problem
    By Sennet in forum C++ Programming
    Replies: 11
    Last Post: 10-08-2005, 12:29 AM

Tags for this Thread