Author Topic: peek()  (Read 2707 times)


  • Not-a-newbie
  • *
  • Posts: 9
  • Karma: 0
    • View Profile
« on: September 17, 2007, 12:25:38 PM »
I suggest a peek() function to read in a particular variable type from a BitStream, without actually moving the stream pointer along like Read() does.
Code: [Select]
bool peek<templateType>(templateType &var)

Works exactly like Read() does in other words.


  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: peek()
« Reply #1 on: September 20, 2007, 10:35:05 AM »
You can use GetReadOffset and SetReadOffset


  • Anti-Spam Moderator
  • Hero Member
  • ****
  • Posts: 855
  • Karma: 40
  • Programmer
    • View Profile
    • OvermindDL1's Site
Re: peek()
« Reply #2 on: September 20, 2007, 01:06:29 PM »
I have to admit, a peek in the variety of read, just not moving the pointer, would be nice.  Using the offset functions with read would still incur moving the pointer then moving it back, needless calculation.  Although I understand the reasons for not wanting to do it, quite a few template specializations to copy and 'fix'.  Perhaps peek could be specified as inlined and just have read call it while moving the pointer, that way code updates would only need to be done in one place.  If I get free time any time soon (unlikely) then I could do a patch...