mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 21:18:23 +01:00
cpp: type::raw_ref::str(), operator==, operator!=, operator< and operator> are now const
This commit is contained in:
parent
167e2475d8
commit
331bf0af21
@ -33,25 +33,25 @@ struct raw_ref {
|
|||||||
uint32_t size;
|
uint32_t size;
|
||||||
const char* ptr;
|
const char* ptr;
|
||||||
|
|
||||||
std::string str() { return std::string(ptr, size); }
|
std::string str() const { return std::string(ptr, size); }
|
||||||
|
|
||||||
bool operator== (const raw_ref& x)
|
bool operator== (const raw_ref& x) const
|
||||||
{
|
{
|
||||||
return size == x.size && memcmp(ptr, x.ptr, size) == 0;
|
return size == x.size && memcmp(ptr, x.ptr, size) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!= (const raw_ref& x)
|
bool operator!= (const raw_ref& x) const
|
||||||
{
|
{
|
||||||
return !(*this != x);
|
return !(*this != x);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator< (const raw_ref& x)
|
bool operator< (const raw_ref& x) const
|
||||||
{
|
{
|
||||||
if(size == x.size) { return memcmp(ptr, x.ptr, size) < 0; }
|
if(size == x.size) { return memcmp(ptr, x.ptr, size) < 0; }
|
||||||
else { return size < x.size; }
|
else { return size < x.size; }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator> (const raw_ref& x)
|
bool operator> (const raw_ref& x) const
|
||||||
{
|
{
|
||||||
if(size == x.size) { return memcmp(ptr, x.ptr, size) > 0; }
|
if(size == x.size) { return memcmp(ptr, x.ptr, size) > 0; }
|
||||||
else { return size > x.size; }
|
else { return size > x.size; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user