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
dea7fde8
Commit
dea7fde8
authored
Dec 24, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate u8string_view
parent
5390e29d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
28 deletions
+11
-28
include/fmt/core.h
include/fmt/core.h
+2
-1
include/fmt/format.h
include/fmt/format.h
+3
-4
test/format-impl-test.cc
test/format-impl-test.cc
+5
-1
test/format-test.cc
test/format-test.cc
+1
-22
No files found.
include/fmt/core.h
View file @
dea7fde8
...
@@ -1535,7 +1535,8 @@ inline void print(std::FILE* f, const S& format_str, Args&&... args) {
...
@@ -1535,7 +1535,8 @@ inline void print(std::FILE* f, const S& format_str, Args&&... args) {
/**
/**
\rst
\rst
Prints formatted data to ``stdout``.
Formats ``args`` according to specifications in ``format_str`` and writes the
output to ``stdout``.
**Example**::
**Example**::
...
...
include/fmt/format.h
View file @
dea7fde8
...
@@ -559,8 +559,7 @@ class buffer_range : public internal::output_range<
...
@@ -559,8 +559,7 @@ class buffer_range : public internal::output_range<
:
internal
::
output_range
<
iterator
,
T
>
(
std
::
back_inserter
(
buf
))
{}
:
internal
::
output_range
<
iterator
,
T
>
(
std
::
back_inserter
(
buf
))
{}
};
};
// A UTF-8 string view.
class
FMT_DEPRECATED
u8string_view
:
public
basic_string_view
<
char8_t
>
{
class
u8string_view
:
public
basic_string_view
<
char8_t
>
{
public:
public:
u8string_view
(
const
char
*
s
)
u8string_view
(
const
char
*
s
)
:
basic_string_view
<
char8_t
>
(
reinterpret_cast
<
const
char8_t
*>
(
s
))
{}
:
basic_string_view
<
char8_t
>
(
reinterpret_cast
<
const
char8_t
*>
(
s
))
{}
...
@@ -571,8 +570,8 @@ class u8string_view : public basic_string_view<char8_t> {
...
@@ -571,8 +570,8 @@ class u8string_view : public basic_string_view<char8_t> {
#if FMT_USE_USER_DEFINED_LITERALS
#if FMT_USE_USER_DEFINED_LITERALS
inline
namespace
literals
{
inline
namespace
literals
{
inline
u8string_view
operator
""
_u
(
const
char
*
s
,
std
::
size_t
n
)
{
inline
basic_string_view
<
char8_t
>
operator
""
_u
(
const
char
*
s
,
std
::
size_t
n
)
{
return
{
s
,
n
};
return
{
reinterpret_cast
<
const
char8_t
*>
(
s
)
,
n
};
}
}
}
// namespace literals
}
// namespace literals
#endif
#endif
...
...
test/format-impl-test.cc
View file @
dea7fde8
...
@@ -427,7 +427,11 @@ TEST(FormatTest, FormatErrorCode) {
...
@@ -427,7 +427,11 @@ TEST(FormatTest, FormatErrorCode) {
}
}
TEST
(
FormatTest
,
CountCodePoints
)
{
TEST
(
FormatTest
,
CountCodePoints
)
{
EXPECT_EQ
(
4
,
fmt
::
internal
::
count_code_points
(
fmt
::
u8string_view
(
"ёжик"
)));
#ifndef __cpp_char8_t
using
fmt
::
char8_t
;
#endif
EXPECT_EQ
(
4
,
fmt
::
internal
::
count_code_points
(
fmt
::
basic_string_view
<
char8_t
>
(
reinterpret_cast
<
const
char8_t
*>
(
"ёжик"
))));
}
}
// Tests fmt::internal::count_digits for integer type Int.
// Tests fmt::internal::count_digits for integer type Int.
...
...
test/format-test.cc
View file @
dea7fde8
...
@@ -2467,27 +2467,10 @@ TEST(FormatTest, FmtStringInTemplate) {
...
@@ -2467,27 +2467,10 @@ TEST(FormatTest, FmtStringInTemplate) {
using
fmt
::
char8_t
;
using
fmt
::
char8_t
;
#endif
#endif
TEST
(
FormatTest
,
ConstructU8StringViewFromCString
)
{
fmt
::
u8string_view
s
(
"ab"
);
EXPECT_EQ
(
s
.
size
(),
2u
);
const
char8_t
*
data
=
s
.
data
();
EXPECT_EQ
(
data
[
0
],
'a'
);
EXPECT_EQ
(
data
[
1
],
'b'
);
}
TEST
(
FormatTest
,
ConstructU8StringViewFromDataAndSize
)
{
fmt
::
u8string_view
s
(
"foobar"
,
3
);
EXPECT_EQ
(
s
.
size
(),
3u
);
const
char8_t
*
data
=
s
.
data
();
EXPECT_EQ
(
data
[
0
],
'f'
);
EXPECT_EQ
(
data
[
1
],
'o'
);
EXPECT_EQ
(
data
[
2
],
'o'
);
}
#if FMT_USE_USER_DEFINED_LITERALS
#if FMT_USE_USER_DEFINED_LITERALS
TEST
(
FormatTest
,
U8StringViewLiteral
)
{
TEST
(
FormatTest
,
U8StringViewLiteral
)
{
using
namespace
fmt
::
literals
;
using
namespace
fmt
::
literals
;
fmt
::
u8string_view
s
=
"ab"
_u
;
fmt
::
basic_string_view
<
char8_t
>
s
=
"ab"
_u
;
EXPECT_EQ
(
s
.
size
(),
2u
);
EXPECT_EQ
(
s
.
size
(),
2u
);
const
char8_t
*
data
=
s
.
data
();
const
char8_t
*
data
=
s
.
data
();
EXPECT_EQ
(
data
[
0
],
'a'
);
EXPECT_EQ
(
data
[
0
],
'a'
);
...
@@ -2496,10 +2479,6 @@ TEST(FormatTest, U8StringViewLiteral) {
...
@@ -2496,10 +2479,6 @@ TEST(FormatTest, U8StringViewLiteral) {
}
}
#endif
#endif
TEST
(
FormatTest
,
FormatU8String
)
{
EXPECT_EQ
(
format
(
fmt
::
u8string_view
(
"{}"
),
42
),
fmt
::
u8string_view
(
"42"
));
}
TEST
(
FormatTest
,
EmphasisNonHeaderOnly
)
{
TEST
(
FormatTest
,
EmphasisNonHeaderOnly
)
{
// Ensure this compiles even if FMT_HEADER_ONLY is not defined.
// Ensure this compiles even if FMT_HEADER_ONLY is not defined.
EXPECT_EQ
(
fmt
::
format
(
fmt
::
emphasis
::
bold
,
"bold error"
),
EXPECT_EQ
(
fmt
::
format
(
fmt
::
emphasis
::
bold
,
"bold error"
),
...
...
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