Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
55d166a2
Commit
55d166a2
authored
May 17, 2010
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds GTEST_REMOVE_REFERENCE_AND_CONST_.
parent
65f2fd59
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
gtest-internal.h
include/gtest/internal/gtest-internal.h
+5
-1
gtest_unittest.cc
test/gtest_unittest.cc
+15
-0
No files found.
include/gtest/internal/gtest-internal.h
View file @
55d166a2
...
...
@@ -842,6 +842,10 @@ struct RemoveConst<T[N]> {
#define GTEST_REMOVE_CONST_(T) \
typename ::testing::internal::RemoveConst<T>::type
// Turns const U&, U&, const U, and U all into U.
#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \
GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))
// Adds reference to a type if it is not a reference type,
// otherwise leaves it unchanged. This is the same as
// tr1::add_reference, which is not widely available yet.
...
...
@@ -1046,7 +1050,7 @@ class NativeArray {
// Ensures that the user doesn't instantiate NativeArray with a
// const or reference type.
static_cast
<
void
>
(
StaticAssertTypeEqHelper
<
Element
,
GTEST_REMOVE_
CONST_
(
GTEST_REMOVE_REFERENCE_
(
Element
)
)
>
());
GTEST_REMOVE_
REFERENCE_AND_CONST_
(
Element
)
>
());
if
(
relation_to_source_
==
kCopy
)
delete
[]
array_
;
}
...
...
test/gtest_unittest.cc
View file @
55d166a2
...
...
@@ -6834,6 +6834,21 @@ TEST(RemoveConstTest, MacroVersion) {
TestGTestRemoveConst
<
char
,
const
char
>
();
}
// Tests GTEST_REMOVE_REFERENCE_AND_CONST_.
template
<
typename
T1
,
typename
T2
>
void
TestGTestRemoveReferenceAndConst
()
{
CompileAssertTypesEqual
<
T1
,
GTEST_REMOVE_REFERENCE_AND_CONST_
(
T2
)
>
();
}
TEST
(
RemoveReferenceToConstTest
,
Works
)
{
TestGTestRemoveReferenceAndConst
<
int
,
int
>
();
TestGTestRemoveReferenceAndConst
<
double
,
double
&>
();
TestGTestRemoveReferenceAndConst
<
char
,
const
char
>
();
TestGTestRemoveReferenceAndConst
<
char
,
const
char
&>
();
TestGTestRemoveReferenceAndConst
<
const
char
*
,
const
char
*>
();
}
// Tests that AddReference does not affect reference types.
TEST
(
AddReferenceTest
,
DoesNotAffectReferenceType
)
{
CompileAssertTypesEqual
<
int
&
,
AddReference
<
int
&>::
type
>
();
...
...
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