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