summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authoremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>2014-01-24 20:15:00 +0000
committeremsr <emsr@138bc75d-0d04-0410-961f-82ee72b054a4>2014-01-24 20:15:00 +0000
commit887e376f90d3b7123dec5b3990bb7287b7e1c28d (patch)
tree2ead9d19b22d7de9c759bd3b41bbead84fff79f0 /libstdc++-v3/include
parent8f1514645d3a84ba87072b81adebecf542d08fe1 (diff)
downloadppe42-gcc-887e376f90d3b7123dec5b3990bb7287b7e1c28d.tar.gz
ppe42-gcc-887e376f90d3b7123dec5b3990bb7287b7e1c28d.zip
2014-01-24 Ed Smith-Rowland <3dw4rd@verizon.net>
PR libstdc++/59531 * testsuite/experimental/string_view/operations/copy/char/1.cc: New. * testsuite/experimental/string_view/operations/copy/wchar_t/1.cc: New. 2014-01-24 Ed Smith-Rowland <3dw4rd@verizon.net> Peter A. Bigot <pab@pabigot.com> PR libstdc++/59531 * include/experimental/string_view (copy(_CharT*, size_type, size_type) const): Correct throw string. Correct copy start location. 2014-01-24 Ed Smith-Rowland <3dw4rd@verizon.net> Peter A. Bigot <pab@pabigot.com> PR libstdc++/59530 * include/experimental/string_view (operator[](size_type) const): Fix one-off index error in debug check. * testsuite/experimental/string_view/element_access/char/1.cc: Don't test basic_string_view at size(). * testsuite/experimental/string_view/element_access/wchar_t/1.cc: Ditto. 2014-01-24 Ed Smith-Rowland <3dw4rd@verizon.net> Peter A. Bigot <pab@pabigot.com> PR libstdc++/59529 * include/experimental/string_view (basic_string_view(const _CharT*, size_type)): Don't care if len == 0. * testsuite/experimental/string_view/operations/substr/char/1.cc: Comment out catch of out_of_range; No terminating null in basic_string_view. Check begin == end. * testsuite/experimental/string_view/operations/substr/wchar_t/1.cc: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@207060 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/experimental/string_view18
1 files changed, 9 insertions, 9 deletions
diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view
index ab6943d806b..bebeb6b62ea 100644
--- a/libstdc++-v3/include/experimental/string_view
+++ b/libstdc++-v3/include/experimental/string_view
@@ -117,7 +117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr basic_string_view(const _CharT* __str, size_type __len)
: _M_len{__str == nullptr ? 0 :__len},
- _M_str{__str == nullptr || __len == 0 ? _S_empty_str : __str}
+ _M_str{__str == nullptr ? _S_empty_str : __str}
{ }
basic_string_view&
@@ -182,7 +182,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator[](size_type __pos) const
{
// TODO: Assert to restore in a way compatible with the constexpr.
- // _GLIBCXX_DEBUG_ASSERT(__pos <= this->_M_len);
+ // _GLIBCXX_DEBUG_ASSERT(__pos < this->_M_len);
return *(this->_M_str + __pos);
}
@@ -259,14 +259,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
copy(_CharT* __str, size_type __n, size_type __pos = 0) const
{
__glibcxx_requires_string_len(__str, __n);
- if (__pos >= this->_M_len)
- __throw_out_of_range_fmt(__N("basic_string_view::at: __pos "
- "(which is %zu) >= this->size() "
+ if (__pos > this->_M_len)
+ __throw_out_of_range_fmt(__N("basic_string_view::copy: __pos "
+ "(which is %zu) > this->size() "
"(which is %zu)"),
__pos, this->size());
size_type __rlen{std::min(__n, size_type{this->_M_len - __pos})};
for (auto __begin = this->_M_str + __pos,
- __end = this->_M_str + __rlen; __begin != __end;)
+ __end = __begin + __rlen; __begin != __end;)
*__str++ = *__begin++;
return __rlen;
}
@@ -277,11 +277,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
constexpr basic_string_view
substr(size_type __pos, size_type __n=npos) const
{
- return __pos < this->_M_len
+ return __pos <= this->_M_len
? basic_string_view{this->_M_str + __pos,
std::min(__n, size_type{this->_M_len - __pos})}
- : (__throw_out_of_range_fmt(__N("basic_string_view::at: __pos "
- "(which is %zu) >= this->size() "
+ : (__throw_out_of_range_fmt(__N("basic_string_view::substr: __pos "
+ "(which is %zu) > this->size() "
"(which is %zu)"),
__pos, this->size()), basic_string_view{});
}
OpenPOWER on IntegriCloud