Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
5c4b6678
Commit
5c4b6678
authored
Oct 30, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Compute StringRef size in ctor
parent
10d83aaa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
8 deletions
+10
-8
format.h
format.h
+10
-8
No files found.
format.h
View file @
5c4b6678
...
...
@@ -164,15 +164,20 @@ template <typename Char>
class
BasicStringRef
{
private:
const
Char
*
data_
;
mutable
std
::
size_t
size_
;
std
::
size_t
size_
;
public:
/**
Constructs a string reference object from a C string and a size.
If *size* is zero, which is the default, the size is computed
automatically.
*/
BasicStringRef
(
const
Char
*
s
,
std
::
size_t
size
=
0
)
:
data_
(
s
),
size_
(
size
)
{}
BasicStringRef
(
const
Char
*
s
,
std
::
size_t
n
)
:
data_
(
s
),
size_
(
n
)
{}
/**
Constructs a string reference object from a C string computing
the size with ``std::char_traits<Char>::length``.
*/
BasicStringRef
(
const
Char
*
s
)
:
data_
(
s
),
size_
(
std
::
char_traits
<
Char
>::
length
(
s
))
{}
/**
Constructs a string reference from an `std::string` object.
...
...
@@ -195,10 +200,7 @@ class BasicStringRef {
/**
Returns the string size.
*/
std
::
size_t
size
()
const
{
if
(
size_
==
0
&&
data_
)
size_
=
std
::
char_traits
<
Char
>::
length
(
data_
);
return
size_
;
}
std
::
size_t
size
()
const
{
return
size_
;
}
friend
bool
operator
==
(
BasicStringRef
lhs
,
BasicStringRef
rhs
)
{
return
lhs
.
data_
==
rhs
.
data_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment