Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
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
lvzhengyang
riscv-gcc-1
Commits
ef20ab5e
Commit
ef20ab5e
authored
Jul 29, 2015
by
Jonathan Wakely
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* testsuite/24_iterators/container_access.cc: New.
From-SVN: r226349
parent
a460d06d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
0 deletions
+89
-0
libstdc++-v3/testsuite/24_iterators/container_access.cc
+89
-0
No files found.
libstdc++-v3/testsuite/24_iterators/container_access.cc
0 → 100644
View file @
ef20ab5e
// { dg-do run }
// { dg-options "-std=gnu++17" }
// Copyright (C) 2015 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// 24.8, container access [iterator.container]
#include <iterator>
#include <vector>
#include <testsuite_hooks.h>
bool
test
__attribute__
((
unused
))
=
true
;
void
test01
()
{
int
i
[
42
];
VERIFY
(
std
::
data
(
i
)
==
i
);
VERIFY
(
std
::
size
(
i
)
==
42
);
VERIFY
(
!
std
::
empty
(
i
));
}
void
test02
()
{
static
constexpr
int
i
[
42
]{};
constexpr
auto
d
=
std
::
data
(
i
);
static_assert
(
d
==
i
);
constexpr
auto
s
=
std
::
size
(
i
);
static_assert
(
s
==
42
);
constexpr
auto
e
=
std
::
empty
(
i
);
static_assert
(
!
e
);
}
int
test03
()
{
std
::
initializer_list
<
int
>
il
{
1
,
2
,
3
};
VERIFY
(
std
::
data
(
il
)
==
il
.
begin
());
VERIFY
(
std
::
size
(
il
)
==
3
);
VERIFY
(
!
std
::
empty
(
il
));
std
::
initializer_list
<
int
>
il2
{};
VERIFY
(
std
::
size
(
il2
)
==
0
);
VERIFY
(
std
::
empty
(
il2
));
constexpr
std
::
initializer_list
<
int
>
il3
{
1
,
2
,
3
};
constexpr
auto
d
=
std
::
data
(
il3
);
static_assert
(
d
==
il3
.
begin
());
constexpr
auto
s
=
std
::
size
(
il3
);
static_assert
(
s
==
3
);
constexpr
auto
e
=
std
::
empty
(
il3
);
static_assert
(
!
e
);
}
int
test04
()
{
std
::
vector
<
int
>
v
{
1
,
2
,
3
};
VERIFY
(
std
::
data
(
v
)
==
v
.
data
());
VERIFY
(
std
::
size
(
v
)
==
v
.
size
());
VERIFY
(
!
std
::
empty
(
v
));
std
::
vector
<
int
>
v2
{};
VERIFY
(
std
::
size
(
v2
)
==
v2
.
size
());
VERIFY
(
std
::
empty
(
v2
));
}
int
main
()
{
test01
();
test02
();
test03
();
test04
();
}
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