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
b55ea587
Commit
b55ea587
authored
Feb 01, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
string_view::char_type -> value_type (#1539)
parent
4098970d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
include/fmt/core.h
include/fmt/core.h
+3
-2
test/core-test.cc
test/core-test.cc
+5
-1
No files found.
include/fmt/core.h
View file @
b55ea587
...
@@ -313,7 +313,8 @@ template <typename Char> class basic_string_view {
...
@@ -313,7 +313,8 @@ template <typename Char> class basic_string_view {
size_t
size_
;
size_t
size_
;
public:
public:
using
char_type
=
Char
;
using
char_type
FMT_DEPRECATED_ALIAS
=
Char
;
using
value_type
=
Char
;
using
iterator
=
const
Char
*
;
using
iterator
=
const
Char
*
;
FMT_CONSTEXPR
basic_string_view
()
FMT_NOEXCEPT
:
data_
(
nullptr
),
size_
(
0
)
{}
FMT_CONSTEXPR
basic_string_view
()
FMT_NOEXCEPT
:
data_
(
nullptr
),
size_
(
0
)
{}
...
@@ -471,7 +472,7 @@ struct is_string : std::is_class<decltype(to_string_view(std::declval<S>()))> {
...
@@ -471,7 +472,7 @@ struct is_string : std::is_class<decltype(to_string_view(std::declval<S>()))> {
template
<
typename
S
,
typename
=
void
>
struct
char_t_impl
{};
template
<
typename
S
,
typename
=
void
>
struct
char_t_impl
{};
template
<
typename
S
>
struct
char_t_impl
<
S
,
enable_if_t
<
is_string
<
S
>::
value
>>
{
template
<
typename
S
>
struct
char_t_impl
<
S
,
enable_if_t
<
is_string
<
S
>::
value
>>
{
using
result
=
decltype
(
to_string_view
(
std
::
declval
<
S
>
()));
using
result
=
decltype
(
to_string_view
(
std
::
declval
<
S
>
()));
using
type
=
typename
result
::
char
_type
;
using
type
=
typename
result
::
value
_type
;
};
};
struct
error_handler
{
struct
error_handler
{
...
...
test/core-test.cc
View file @
b55ea587
...
@@ -402,8 +402,12 @@ TEST(ArgTest, VisitInvalidArg) {
...
@@ -402,8 +402,12 @@ TEST(ArgTest, VisitInvalidArg) {
fmt
::
visit_format_arg
(
visitor
,
arg
);
fmt
::
visit_format_arg
(
visitor
,
arg
);
}
}
TEST
(
StringViewTest
,
ValueType
)
{
static_assert
(
std
::
is_same
<
string_view
::
value_type
,
char
>::
value
,
""
);
}
TEST
(
StringViewTest
,
Length
)
{
TEST
(
StringViewTest
,
Length
)
{
// Test that
StringRef
::size() returns string length, not buffer size.
// Test that
string_view
::size() returns string length, not buffer size.
char
str
[
100
]
=
"some string"
;
char
str
[
100
]
=
"some string"
;
EXPECT_EQ
(
std
::
strlen
(
str
),
string_view
(
str
).
size
());
EXPECT_EQ
(
std
::
strlen
(
str
),
string_view
(
str
).
size
());
EXPECT_LT
(
std
::
strlen
(
str
),
sizeof
(
str
));
EXPECT_LT
(
std
::
strlen
(
str
),
sizeof
(
str
));
...
...
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