mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 09:24:55 +02:00
fixed GH #1425: Workaround bug in SolarisStudio 12.4 on RVO-ed objects.
This commit is contained in:
parent
079c9a6263
commit
47043e0f4f
@ -34,7 +34,7 @@ S trimLeft(const S& str)
|
|||||||
{
|
{
|
||||||
typename S::const_iterator it = str.begin();
|
typename S::const_iterator it = str.begin();
|
||||||
typename S::const_iterator end = str.end();
|
typename S::const_iterator end = str.end();
|
||||||
|
|
||||||
while (it != end && Ascii::isSpace(*it)) ++it;
|
while (it != end && Ascii::isSpace(*it)) ++it;
|
||||||
return S(it, end);
|
return S(it, end);
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ S& trimLeftInPlace(S& str)
|
|||||||
{
|
{
|
||||||
typename S::iterator it = str.begin();
|
typename S::iterator it = str.begin();
|
||||||
typename S::iterator end = str.end();
|
typename S::iterator end = str.end();
|
||||||
|
|
||||||
while (it != end && Ascii::isSpace(*it)) ++it;
|
while (it != end && Ascii::isSpace(*it)) ++it;
|
||||||
str.erase(str.begin(), it);
|
str.erase(str.begin(), it);
|
||||||
return str;
|
return str;
|
||||||
@ -59,7 +59,7 @@ S trimRight(const S& str)
|
|||||||
/// whitespace removed.
|
/// whitespace removed.
|
||||||
{
|
{
|
||||||
int pos = int(str.size()) - 1;
|
int pos = int(str.size()) - 1;
|
||||||
|
|
||||||
while (pos >= 0 && Ascii::isSpace(str[pos])) --pos;
|
while (pos >= 0 && Ascii::isSpace(str[pos])) --pos;
|
||||||
return S(str, 0, pos + 1);
|
return S(str, 0, pos + 1);
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ S& trimRightInPlace(S& str)
|
|||||||
/// Removes all trailing whitespace in str.
|
/// Removes all trailing whitespace in str.
|
||||||
{
|
{
|
||||||
int pos = int(str.size()) - 1;
|
int pos = int(str.size()) - 1;
|
||||||
|
|
||||||
while (pos >= 0 && Ascii::isSpace(str[pos])) --pos;
|
while (pos >= 0 && Ascii::isSpace(str[pos])) --pos;
|
||||||
str.resize(pos + 1);
|
str.resize(pos + 1);
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ S trim(const S& str)
|
|||||||
{
|
{
|
||||||
int first = 0;
|
int first = 0;
|
||||||
int last = int(str.size()) - 1;
|
int last = int(str.size()) - 1;
|
||||||
|
|
||||||
while (first <= last && Ascii::isSpace(str[first])) ++first;
|
while (first <= last && Ascii::isSpace(str[first])) ++first;
|
||||||
while (last >= first && Ascii::isSpace(str[last])) --last;
|
while (last >= first && Ascii::isSpace(str[last])) --last;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ S& trimInPlace(S& str)
|
|||||||
{
|
{
|
||||||
int first = 0;
|
int first = 0;
|
||||||
int last = int(str.size()) - 1;
|
int last = int(str.size()) - 1;
|
||||||
|
|
||||||
while (first <= last && Ascii::isSpace(str[first])) ++first;
|
while (first <= last && Ascii::isSpace(str[first])) ++first;
|
||||||
while (last >= first && Ascii::isSpace(str[last])) --last;
|
while (last >= first && Ascii::isSpace(str[last])) --last;
|
||||||
|
|
||||||
@ -168,16 +168,16 @@ S& toLowerInPlace(S& str)
|
|||||||
template <class S, class It>
|
template <class S, class It>
|
||||||
int icompare(
|
int icompare(
|
||||||
const S& str,
|
const S& str,
|
||||||
typename S::size_type pos,
|
typename S::size_type pos,
|
||||||
typename S::size_type n,
|
typename S::size_type n,
|
||||||
It it2,
|
It it2,
|
||||||
It end2)
|
It end2)
|
||||||
/// Case-insensitive string comparison
|
/// Case-insensitive string comparison
|
||||||
{
|
{
|
||||||
typename S::size_type sz = str.size();
|
typename S::size_type sz = str.size();
|
||||||
if (pos > sz) pos = sz;
|
if (pos > sz) pos = sz;
|
||||||
if (pos + n > sz) n = sz - pos;
|
if (pos + n > sz) n = sz - pos;
|
||||||
It it1 = str.begin() + pos;
|
It it1 = str.begin() + pos;
|
||||||
It end1 = str.begin() + pos + n;
|
It end1 = str.begin() + pos + n;
|
||||||
while (it1 != end1 && it2 != end2)
|
while (it1 != end1 && it2 != end2)
|
||||||
{
|
{
|
||||||
@ -215,7 +215,7 @@ int icompare(const S& str1, const S& str2)
|
|||||||
return 1;
|
return 1;
|
||||||
++it1; ++it2;
|
++it1; ++it2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it1 == end1)
|
if (it1 == end1)
|
||||||
return it2 == end2 ? 0 : -1;
|
return it2 == end2 ? 0 : -1;
|
||||||
else
|
else
|
||||||
@ -248,9 +248,9 @@ int icompare(const S& str1, typename S::size_type pos, typename S::size_type n,
|
|||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
int icompare(
|
int icompare(
|
||||||
const S& str1,
|
const S& str1,
|
||||||
typename S::size_type pos1,
|
typename S::size_type pos1,
|
||||||
typename S::size_type n1,
|
typename S::size_type n1,
|
||||||
const S& str2,
|
const S& str2,
|
||||||
typename S::size_type pos2,
|
typename S::size_type pos2,
|
||||||
typename S::size_type n2)
|
typename S::size_type n2)
|
||||||
@ -264,9 +264,9 @@ int icompare(
|
|||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
int icompare(
|
int icompare(
|
||||||
const S& str1,
|
const S& str1,
|
||||||
typename S::size_type pos1,
|
typename S::size_type pos1,
|
||||||
typename S::size_type n,
|
typename S::size_type n,
|
||||||
const S& str2,
|
const S& str2,
|
||||||
typename S::size_type pos2)
|
typename S::size_type pos2)
|
||||||
{
|
{
|
||||||
@ -288,7 +288,7 @@ int icompare(
|
|||||||
typename S::size_type sz = str.size();
|
typename S::size_type sz = str.size();
|
||||||
if (pos > sz) pos = sz;
|
if (pos > sz) pos = sz;
|
||||||
if (pos + n > sz) n = sz - pos;
|
if (pos + n > sz) n = sz - pos;
|
||||||
typename S::const_iterator it = str.begin() + pos;
|
typename S::const_iterator it = str.begin() + pos;
|
||||||
typename S::const_iterator end = str.begin() + pos + n;
|
typename S::const_iterator end = str.begin() + pos + n;
|
||||||
while (it != end && *ptr)
|
while (it != end && *ptr)
|
||||||
{
|
{
|
||||||
@ -300,7 +300,7 @@ int icompare(
|
|||||||
return 1;
|
return 1;
|
||||||
++it; ++ptr;
|
++it; ++ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it == end)
|
if (it == end)
|
||||||
return *ptr == 0 ? 0 : -1;
|
return *ptr == 0 ? 0 : -1;
|
||||||
else
|
else
|
||||||
@ -351,7 +351,7 @@ S translate(const S& str, const S& from, const S& to)
|
|||||||
/// from replaced by the corresponding (by position)
|
/// from replaced by the corresponding (by position)
|
||||||
/// characters in to. If there is no corresponding
|
/// characters in to. If there is no corresponding
|
||||||
/// character in to, the character is removed from
|
/// character in to, the character is removed from
|
||||||
/// the copy.
|
/// the copy.
|
||||||
{
|
{
|
||||||
S result;
|
S result;
|
||||||
result.reserve(str.size());
|
result.reserve(str.size());
|
||||||
@ -386,7 +386,7 @@ S translate(const S& str, const typename S::value_type* from, const typename S::
|
|||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
S& translateInPlace(S& str, const S& from, const S& to)
|
S& translateInPlace(S& str, const S& from, const S& to)
|
||||||
/// Replaces in str all occurences of characters in from
|
/// Replaces in str all occurrences of characters in from
|
||||||
/// with the corresponding (by position) characters in to.
|
/// with the corresponding (by position) characters in to.
|
||||||
/// If there is no corresponding character, the character
|
/// If there is no corresponding character, the character
|
||||||
/// is removed.
|
/// is removed.
|
||||||
@ -402,7 +402,13 @@ S translateInPlace(S& str, const typename S::value_type* from, const typename S:
|
|||||||
poco_check_ptr (from);
|
poco_check_ptr (from);
|
||||||
poco_check_ptr (to);
|
poco_check_ptr (to);
|
||||||
str = translate(str, S(from), S(to));
|
str = translate(str, S(from), S(to));
|
||||||
|
#if defined(__SUNPRO_CC)
|
||||||
|
// Fix around the RVO bug in SunStudio 12.4
|
||||||
|
S ret(str);
|
||||||
|
return ret;
|
||||||
|
#else
|
||||||
return str;
|
return str;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -413,7 +419,7 @@ template <class S>
|
|||||||
S& replaceInPlace(S& str, const S& from, const S& to, typename S::size_type start = 0)
|
S& replaceInPlace(S& str, const S& from, const S& to, typename S::size_type start = 0)
|
||||||
{
|
{
|
||||||
poco_assert (from.size() > 0);
|
poco_assert (from.size() > 0);
|
||||||
|
|
||||||
S result;
|
S result;
|
||||||
typename S::size_type pos = 0;
|
typename S::size_type pos = 0;
|
||||||
result.append(str, 0, start);
|
result.append(str, 0, start);
|
||||||
@ -489,7 +495,7 @@ S& removeInPlace(S& str, const typename S::value_type ch, typename S::size_type
|
|||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
S replace(const S& str, const S& from, const S& to, typename S::size_type start = 0)
|
S replace(const S& str, const S& from, const S& to, typename S::size_type start = 0)
|
||||||
/// Replace all occurences of from (which must not be the empty string)
|
/// Replace all occurrences of from (which must not be the empty string)
|
||||||
/// in str with to, starting at position start.
|
/// in str with to, starting at position start.
|
||||||
{
|
{
|
||||||
S result(str);
|
S result(str);
|
||||||
@ -538,7 +544,7 @@ Foundation_API std::string& replaceInPlace(std::string& str, const std::string::
|
|||||||
Foundation_API std::string& removeInPlace(std::string& str, const std::string::value_type ch, std::string::size_type start = 0);
|
Foundation_API std::string& removeInPlace(std::string& str, const std::string::value_type ch, std::string::size_type start = 0);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
template <class S>
|
template <class S>
|
||||||
@ -674,7 +680,7 @@ std::size_t isubstr(const T& str, const T& sought)
|
|||||||
/// without regards to case.
|
/// without regards to case.
|
||||||
{
|
{
|
||||||
typename T::const_iterator it = std::search(str.begin(), str.end(),
|
typename T::const_iterator it = std::search(str.begin(), str.end(),
|
||||||
sought.begin(), sought.end(),
|
sought.begin(), sought.end(),
|
||||||
i_char_traits<typename T::value_type>::eq);
|
i_char_traits<typename T::value_type>::eq);
|
||||||
|
|
||||||
if (it != str.end()) return it - str.begin();
|
if (it != str.end()) return it - str.begin();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user