add == and != operators to the TextStreamBase<> class
This commit is contained in:
parent
172c2fcee7
commit
2c4bfe085b
|
@ -198,6 +198,12 @@ public:
|
|||
TextStreamBase & operator<<(const TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & arg);
|
||||
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
bool operator==(const TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & stream) const;
|
||||
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
bool operator!=(const TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & stream) const;
|
||||
|
||||
|
||||
// min width for integer output
|
||||
// if the output value has less digits then first zeroes are added
|
||||
|
@ -1206,6 +1212,46 @@ return *this;
|
|||
}
|
||||
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
bool TextStreamBase<char_type, stack_size, heap_block_size>::operator==(const TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & stream) const
|
||||
{
|
||||
bool are_the_same = false;
|
||||
|
||||
/*
|
||||
* at the moment we do not make any conversions for == and != operators
|
||||
* this may change in the future
|
||||
*/
|
||||
if( sizeof(char_type) == sizeof(arg_char_type) && size() == stream.size() )
|
||||
{
|
||||
are_the_same = true;
|
||||
const_iterator i1 = begin();
|
||||
const_iterator i2 = stream.begin();
|
||||
const_iterator i1_end = end();
|
||||
|
||||
while( i1 != i1_end )
|
||||
{
|
||||
if( *i1 != *i2 )
|
||||
{
|
||||
are_the_same = false;
|
||||
break;
|
||||
}
|
||||
|
||||
++i1;
|
||||
++i2;
|
||||
}
|
||||
}
|
||||
|
||||
return are_the_same;
|
||||
}
|
||||
|
||||
|
||||
template<typename char_type, size_t stack_size, size_t heap_block_size>
|
||||
template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
||||
bool TextStreamBase<char_type, stack_size, heap_block_size>::operator!=(const TextStreamBase<arg_char_type, arg_stack_size, arg_heap_block_size> & stream) const
|
||||
{
|
||||
return !operator==(stream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue