mirror of
https://github.com/OlafvdSpek/ctemplate.git
synced 2025-09-28 19:05:49 +08:00
Don't dereference begin() when range is empty
This commit is contained in:
parent
356d7dfac9
commit
9060230767
|
@ -51,7 +51,10 @@ public:
|
|||
template <class U>
|
||||
str_ref_basic(const U& c)
|
||||
{
|
||||
assign(&*c.begin(), c.end() - c.begin() + &*c.begin());
|
||||
if (c.end() != c.begin())
|
||||
assign(&*c.begin(), c.end() - c.begin() + &*c.begin());
|
||||
else
|
||||
clear();
|
||||
}
|
||||
|
||||
str_ref_basic(const void* b, const void* e)
|
||||
|
@ -66,7 +69,10 @@ public:
|
|||
|
||||
str_ref_basic(const char* b)
|
||||
{
|
||||
assign(b, strlen(b));
|
||||
if (b)
|
||||
assign(b, strlen(b));
|
||||
else
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear()
|
||||
|
|
|
@ -56,7 +56,10 @@ public:
|
|||
template <class U>
|
||||
str_ref_basic(const U& c)
|
||||
{
|
||||
assign(&*c.begin(), c.end() - c.begin() + &*c.begin());
|
||||
if (c.end() != c.begin())
|
||||
assign(&*c.begin(), c.end() - c.begin() + &*c.begin());
|
||||
else
|
||||
clear();
|
||||
}
|
||||
|
||||
str_ref_basic(const void* b, const void* e)
|
||||
|
@ -71,7 +74,10 @@ public:
|
|||
|
||||
str_ref_basic(const char* b)
|
||||
{
|
||||
assign(b, strlen(b));
|
||||
if (b)
|
||||
assign(b, strlen(b));
|
||||
else
|
||||
clear();
|
||||
}
|
||||
|
||||
void clear()
|
||||
|
|
Loading…
Reference in New Issue
Block a user