Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
e4a6b6bc
Commit
e4a6b6bc
authored
13 years ago
by
Marco Biasini
Browse files
Options
Downloads
Patches
Plain Diff
remove recently added exception from StringRef.substr and add a comment explantion the change
parent
45fa8787
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/base/src/string_ref.hh
+11
-8
11 additions, 8 deletions
modules/base/src/string_ref.hh
with
11 additions
and
8 deletions
modules/base/src/string_ref.hh
+
11
−
8
View file @
e4a6b6bc
...
@@ -72,19 +72,22 @@ public:
...
@@ -72,19 +72,22 @@ public:
}
}
return
s
;
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
StringRef
substr
(
size_t
pos
,
size_t
n
=
std
::
string
::
npos
)
const
{
{
if
(
n
==
std
::
string
::
npos
)
{
if
(
n
==
std
::
string
::
npos
)
{
assert
(
pos
>=
0
&&
begin_
+
pos
<=
end_
);
assert
(
begin_
+
pos
<=
end_
);
if
(
!
(
pos
>=
0
&&
begin_
+
pos
<=
end_
)){
throw
Error
(
"out of bounds"
);
}
return
StringRef
(
begin_
+
pos
,
this
->
length
()
-
pos
);
return
StringRef
(
begin_
+
pos
,
this
->
length
()
-
pos
);
}
else
{
}
else
{
assert
(
pos
>=
0
&&
begin_
+
pos
+
n
<=
end_
);
assert
(
begin_
+
pos
+
n
<=
end_
);
if
(
!
(
pos
>=
0
&&
begin_
+
pos
+
n
<=
end_
)){
throw
Error
(
"out of bounds"
);
}
return
StringRef
(
begin_
+
pos
,
n
);
return
StringRef
(
begin_
+
pos
,
n
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment