Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
ddd90bee
Commit
ddd90bee
authored
Mar 18, 2019
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix const-correctness of Vector::operator[].
Not sure how this slipped by for so long!
parent
62a493ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
array.h
c++/src/kj/array.h
+10
-2
vector.h
c++/src/kj/vector.h
+2
-1
No files found.
c++/src/kj/array.h
View file @
ddd90bee
...
...
@@ -162,7 +162,11 @@ public:
}
inline
size_t
size
()
const
{
return
size_
;
}
inline
T
&
operator
[](
size_t
index
)
const
{
inline
T
&
operator
[](
size_t
index
)
{
KJ_IREQUIRE
(
index
<
size_
,
"Out-of-bounds Array access."
);
return
ptr
[
index
];
}
inline
const
T
&
operator
[](
size_t
index
)
const
{
KJ_IREQUIRE
(
index
<
size_
,
"Out-of-bounds Array access."
);
return
ptr
[
index
];
}
...
...
@@ -356,7 +360,11 @@ public:
inline
size_t
size
()
const
{
return
pos
-
ptr
;
}
inline
size_t
capacity
()
const
{
return
endPtr
-
ptr
;
}
inline
T
&
operator
[](
size_t
index
)
const
{
inline
T
&
operator
[](
size_t
index
)
{
KJ_IREQUIRE
(
index
<
implicitCast
<
size_t
>
(
pos
-
ptr
),
"Out-of-bounds Array access."
);
return
ptr
[
index
];
}
inline
const
T
&
operator
[](
size_t
index
)
const
{
KJ_IREQUIRE
(
index
<
implicitCast
<
size_t
>
(
pos
-
ptr
),
"Out-of-bounds Array access."
);
return
ptr
[
index
];
}
...
...
c++/src/kj/vector.h
View file @
ddd90bee
...
...
@@ -52,7 +52,8 @@ public:
inline
size_t
size
()
const
{
return
builder
.
size
();
}
inline
bool
empty
()
const
{
return
size
()
==
0
;
}
inline
size_t
capacity
()
const
{
return
builder
.
capacity
();
}
inline
T
&
operator
[](
size_t
index
)
const
{
return
builder
[
index
];
}
inline
T
&
operator
[](
size_t
index
)
{
return
builder
[
index
];
}
inline
const
T
&
operator
[](
size_t
index
)
const
{
return
builder
[
index
];
}
inline
const
T
*
begin
()
const
{
return
builder
.
begin
();
}
inline
const
T
*
end
()
const
{
return
builder
.
end
();
}
...
...
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