• R/O
  • SSH
  • HTTPS

eirrepo: Commit


Commit MetaInfo

Revision163 (tree)
Time2018-12-11 20:38:15
Authorquiret

Log Message

- added some stuff regarding stream pointer comparison
- fixed "operator <" of eir::MultiString

Change Summary

Incremental Difference

--- common/sdk/MemoryUtils.stream.h (revision 162)
+++ common/sdk/MemoryUtils.stream.h (revision 163)
@@ -23,6 +23,10 @@
2323
2424 #include <algorithm>
2525
26+#ifdef _DEBUG
27+#include <assert.h>
28+#endif //_DEBUG
29+
2630 // Algorithms-only for performing read and write access on a size-bounded device.
2731 template <typename seekNumberType>
2832 struct BoundedBufferOperations
@@ -182,22 +186,38 @@
182186
183187 return readable;
184188 }
185-};
186-
187-// Comparison helper for stream ptr with size integer.
188-template <typename seekType>
189-AINLINE bool stream_ptr_less( const seekType& ptr, const size_t& val )
190-{
191- static_assert( std::is_unsigned <seekType>::value == false, "seek number must be signed" );
192-
193- if ( ptr < 0 )
189+};
190+
191+// Only use after you have verified that the seek pointer really is not negative.
192+template <typename seekableType>
193+AINLINE typename std::make_unsigned <seekableType>::type stream_ptr_unsigned( const seekableType& ptr )
194+{
195+ static_assert( std::is_signed <seekableType>::value == true );
196+
197+#ifdef _DEBUG
198+ assert( ptr >= 0 );
199+#endif //_DEBUG
200+
201+ return (typename std::make_unsigned <seekableType>::type)ptr;
202+}
203+
204+// Comparison helper for stream ptr with size integer.
205+template <typename seekableType>
206+AINLINE bool stream_ptr_less( const seekableType& ptr, const size_t& val )
207+{
208+ if constexpr ( std::is_signed <seekableType>::value )
209+ {
210+ if ( ptr < 0 )
211+ {
212+ return true;
213+ }
214+
215+ return ( stream_ptr_unsigned( ptr ) < val );
216+ }
217+ else
194218 {
195- return true;
219+ return ( ptr < val );
196220 }
197-
198- typename std::make_unsigned <seekType>::type ptr_unsigned = (typename std::make_unsigned <seekType>::type)ptr;
199-
200- return ( ptr_unsigned < val );
201221 }
202222
203223 // We need a generic memory-aware bounded buffer device.
@@ -436,4 +456,4 @@
436456 using basicMemoryBufferStream = memoryBufferStream <numberType, basicMemStreamAllocMan <numberType>>;
437457 };
438458
439-#endif //_MEMORY_UTILITIES_STREAM_
459+#endif //_MEMORY_UTILITIES_STREAM_
--- common/sdk/MultiString.h (revision 162)
+++ common/sdk/MultiString.h (revision 163)
@@ -1203,13 +1203,13 @@
12031203
12041204 inline bool operator < ( const MultiString& right ) const
12051205 {
1206- return ( this->compare( right ) < 0 );
1206+ return ( this->compare( right ) == eCompResult::LEFT_LESS );
12071207 }
12081208
12091209 template <typename otherAllocatorType>
12101210 inline bool operator < ( const MultiString <otherAllocatorType>& right ) const
12111211 {
1212- return ( this->compare( right ) < 0 );
1212+ return ( this->compare( right ) == eCompResult::LEFT_LESS );
12131213 }
12141214
12151215 // Inserts a string of specified length into a character offset.
Show on old repository browser