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
31ef7c2d
Commit
31ef7c2d
authored
Jun 06, 2013
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GCC.
parent
ec49e07a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
13 deletions
+25
-13
Makefile.am
c++/Makefile.am
+3
-2
array-test.c++
c++/src/kj/array-test.c++
+9
-7
array.h
c++/src/kj/array.h
+1
-2
common-test.c++
c++/src/kj/common-test.c++
+7
-0
common.h
c++/src/kj/common.h
+4
-0
memory.h
c++/src/kj/memory.h
+1
-2
No files found.
c++/Makefile.am
View file @
31ef7c2d
...
@@ -149,10 +149,11 @@ BUILT_SOURCES = $(test_capnpc_outputs) $(capnpc_outputs)
...
@@ -149,10 +149,11 @@ BUILT_SOURCES = $(test_capnpc_outputs) $(capnpc_outputs)
check_PROGRAMS
=
capnproto-test
check_PROGRAMS
=
capnproto-test
capnproto_test_LDADD
=
-lgtest
-lgtest_main
libcapnproto.a
capnproto_test_LDADD
=
-lgtest
-lgtest_main
libcapnproto.a
capnproto_test_SOURCES
=
\
capnproto_test_SOURCES
=
\
src/kj/array-test.c++
\
src/kj/common-test.c++
\
src/kj/common-test.c++
\
src/kj/debug-test.c++
\
src/kj/memory-test.c++
\
src/kj/array-test.c++
\
src/kj/string-test.c++
\
src/kj/string-test.c++
\
src/kj/debug-test.c++
\
src/kj/units-test.c++
\
src/kj/units-test.c++
\
src/capnproto/blob-test.c++
\
src/capnproto/blob-test.c++
\
src/capnproto/layout-test.c++
\
src/capnproto/layout-test.c++
\
...
...
c++/src/kj/array-test.c++
View file @
31ef7c2d
...
@@ -101,13 +101,15 @@ TEST(Array, TrivialConstructor) {
...
@@ -101,13 +101,15 @@ TEST(Array, TrivialConstructor) {
{
{
Array
<
char
>
chars
=
heapArray
<
char
>
(
32
);
Array
<
char
>
chars
=
heapArray
<
char
>
(
32
);
// Somewhat hacky: We can't guarantee that the new array is allocated in the same place, but
// TODO(test): The following doesn't work in opt mode -- I guess some allocators zero the
// any reasonable allocator is highly likely to do so. If it does, then we expect that the
// memory? Is there some other way we can test this? Maybe override malloc()?
// memory has not been initialized.
// // Somewhat hacky: We can't guarantee that the new array is allocated in the same place, but
if
(
chars
.
begin
()
==
ptr
)
{
// // any reasonable allocator is highly likely to do so. If it does, then we expect that the
EXPECT_NE
(
chars
[
0
],
0
);
// // memory has not been initialized.
EXPECT_NE
(
chars
[
1
],
0
);
// if (chars.begin() == ptr) {
}
// EXPECT_NE(chars[0], 0);
// EXPECT_NE(chars[1], 0);
// }
}
}
}
}
...
...
c++/src/kj/array.h
View file @
31ef7c2d
...
@@ -77,8 +77,7 @@ public:
...
@@ -77,8 +77,7 @@ public:
other
.
ptr
=
nullptr
;
other
.
ptr
=
nullptr
;
other
.
size_
=
0
;
other
.
size_
=
0
;
}
}
template
<
typename
=
EnableIfConst
<
T
>>
inline
Array
(
Array
<
RemoveConstOrBogus
<
T
>>&&
other
)
noexcept
inline
Array
(
Array
<
RemoveConst
<
T
>>&&
other
)
noexcept
:
ptr
(
other
.
ptr
),
size_
(
other
.
size_
),
disposer
(
other
.
disposer
)
{
:
ptr
(
other
.
ptr
),
size_
(
other
.
size_
),
disposer
(
other
.
disposer
)
{
other
.
ptr
=
nullptr
;
other
.
ptr
=
nullptr
;
other
.
size_
=
0
;
other
.
size_
=
0
;
...
...
c++/src/kj/common-test.c++
View file @
31ef7c2d
...
@@ -158,6 +158,13 @@ TEST(Common, MaybeConstness) {
...
@@ -158,6 +158,13 @@ TEST(Common, MaybeConstness) {
Maybe
<
int
&>
mi
=
i
;
Maybe
<
int
&>
mi
=
i
;
const
Maybe
<
int
&>
cmi
=
mi
;
const
Maybe
<
int
&>
cmi
=
mi
;
// const Maybe<int&> cmi2 = cmi; // shouldn't compile! Transitive const violation.
// const Maybe<int&> cmi2 = cmi; // shouldn't compile! Transitive const violation.
KJ_IF_MAYBE
(
i2
,
cmi
)
{
EXPECT_EQ
(
&
i
,
i2
);
}
else
{
ADD_FAILURE
();
}
Maybe
<
const
int
&>
mci
=
mi
;
Maybe
<
const
int
&>
mci
=
mi
;
const
Maybe
<
const
int
&>
cmci
=
mci
;
const
Maybe
<
const
int
&>
cmci
=
mci
;
const
Maybe
<
const
int
&>
cmci2
=
cmci
;
const
Maybe
<
const
int
&>
cmci2
=
cmci
;
...
...
c++/src/kj/common.h
View file @
31ef7c2d
...
@@ -243,6 +243,10 @@ template <typename T> struct EnableIfConst_;
...
@@ -243,6 +243,10 @@ template <typename T> struct EnableIfConst_;
template
<
typename
T
>
struct
EnableIfConst_
<
const
T
>
{
typedef
T
Type
;
};
template
<
typename
T
>
struct
EnableIfConst_
<
const
T
>
{
typedef
T
Type
;
};
template
<
typename
T
>
using
EnableIfConst
=
typename
EnableIfConst_
<
T
>::
Type
;
template
<
typename
T
>
using
EnableIfConst
=
typename
EnableIfConst_
<
T
>::
Type
;
template
<
typename
T
>
struct
RemoveConstOrBogus_
{
struct
Type
;
};
template
<
typename
T
>
struct
RemoveConstOrBogus_
<
const
T
>
{
typedef
T
Type
;
};
template
<
typename
T
>
using
RemoveConstOrBogus
=
typename
RemoveConstOrBogus_
<
T
>::
Type
;
// =======================================================================================
// =======================================================================================
// Equivalents to std::move() and std::forward(), since these are very commonly needed and the
// Equivalents to std::move() and std::forward(), since these are very commonly needed and the
// std header <utility> pulls in lots of other stuff.
// std header <utility> pulls in lots of other stuff.
...
...
c++/src/kj/memory.h
View file @
31ef7c2d
...
@@ -88,8 +88,7 @@ public:
...
@@ -88,8 +88,7 @@ public:
Own
(
const
Own
&
other
)
=
delete
;
Own
(
const
Own
&
other
)
=
delete
;
inline
Own
(
Own
&&
other
)
noexcept
inline
Own
(
Own
&&
other
)
noexcept
:
disposer
(
other
.
disposer
),
ptr
(
other
.
ptr
)
{
other
.
ptr
=
nullptr
;
}
:
disposer
(
other
.
disposer
),
ptr
(
other
.
ptr
)
{
other
.
ptr
=
nullptr
;
}
template
<
typename
=
EnableIfConst
<
T
>>
inline
Own
(
Own
<
RemoveConstOrBogus
<
T
>>&&
other
)
noexcept
inline
Own
(
Own
<
RemoveConst
<
T
>>&&
other
)
noexcept
:
disposer
(
other
.
disposer
),
ptr
(
other
.
ptr
)
{
other
.
ptr
=
nullptr
;
}
:
disposer
(
other
.
disposer
),
ptr
(
other
.
ptr
)
{
other
.
ptr
=
nullptr
;
}
template
<
typename
U
>
template
<
typename
U
>
inline
Own
(
Own
<
U
>&&
other
)
noexcept
inline
Own
(
Own
<
U
>&&
other
)
noexcept
...
...
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