From e898fb5d55d8fe6d423b3290795acbb1e217f84e Mon Sep 17 00:00:00 2001 From: juergen <juergen.haas@unibas.ch> Date: Fri, 2 Dec 2011 15:04:04 +0100 Subject: [PATCH] restoring docu and removing check >=0 of unsigned var --- modules/base/src/string_ref.hh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/base/src/string_ref.hh b/modules/base/src/string_ref.hh index 21bf024b8..802dd5940 100644 --- a/modules/base/src/string_ref.hh +++ b/modules/base/src/string_ref.hh @@ -59,7 +59,9 @@ public: assert(!this->empty()); return *begin_; } - + + /// \brief find character in StringRef + /// \return iterator position when found, else iterator pointing to the end const_iterator find(char p) const { const char* s=begin_; while (s!=end_) { @@ -70,13 +72,22 @@ public: } return s; } + + /// \brief returns a substring of the string + /// + /// \param pos the starting position of the substring + /// \param length is the length of the string. if std::string::npos, the + /// substring goes from \p pos to the end of the string + /// The function does on purpose not perform any boundary check in release + /// mode. It's the duty of the caller to make sure the string has the required + /// length. StringRef substr(size_t pos, size_t n=std::string::npos) const { if (n==std::string::npos) { - assert(pos>=0 && begin_+pos<=end_); + assert(begin_+pos<=end_); return StringRef(begin_+pos, this->length()-pos); } else { - assert(pos>=0 && begin_+pos+n<=end_); + assert(begin_+pos+n<=end_); return StringRef(begin_+pos, n); } } -- GitLab