home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 33,141 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to All   
   Re: post-increment without temporary obj   
   24 Jul 13 16:06:00   
   
   From: daniel.kruegler@googlemail.com   
      
   Am 24.07.2013 20:42, schrieb frank67x@googlemail.com:   
   > Trying to avoid a temporary copy of *this in post-increment.   
   > But is this code below valid?   
      
   Valid in which sense? Let's ignore for the moment the fact, that it is   
   (in general) possible that operator++() may throw an exception (I'm   
   mentioning this, because this would be a show stopper when considering   
   to use this idiom in a general iterator facade such as   
   boost::iterator_facade). If I understand your idea, you want to create   
   an UPInt object before you perform the incrementation, but that does not   
   need your Lazy type, because I simply could construct UPInt from *this,   
   after this would invoke pre-increment, and then return the value.   
      
   Whether you construct a named UPInt object (as I described above) or an   
   unnamed one (in your design), in both cases, RVO is optional (but   
   possible), so I don't see that you exclude the possibility of an   
   intermediate copy (nor do I understand the advantage of preventing this)   
   in either case.   
      
   I also think that your model iterator UPInt doesn't properly account for   
   some very special characteristics of a valid input iterator: The input   
   iterator requirements basically allow you to implement an iterator where   
   all copies reference the same underlying data source (e.g. an input   
   stream) without need to copy it. Now if your UInt type would hold such a   
   reference, you would have the problem that the also required operation   
      
   *r++   
      
   cannot be correctly implemented (without an additional proxy return   
   type), because here you would invoke operator* *after* operator++(int),   
   and the returned value is the wrong one (it would be the value that   
   followed the required one).   
      
   But maybe I misunderstand what you are intending here, so could you   
   please make your point a little bit clearer?   
      
   Thanks && Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca