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
be51ee1c
Commit
be51ee1c
authored
Dec 17, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable broken copy ctor of dynamic_format_arg_store
parent
659de779
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
32 deletions
+12
-32
include/fmt/args.h
include/fmt/args.h
+1
-8
test/args-test.cc
test/args-test.cc
+11
-24
No files found.
include/fmt/args.h
View file @
be51ee1c
...
@@ -146,14 +146,7 @@ class dynamic_format_arg_store
...
@@ -146,14 +146,7 @@ class dynamic_format_arg_store
constexpr
dynamic_format_arg_store
()
=
default
;
constexpr
dynamic_format_arg_store
()
=
default
;
constexpr
dynamic_format_arg_store
(
constexpr
dynamic_format_arg_store
(
const
dynamic_format_arg_store
<
Context
>&
store
)
const
dynamic_format_arg_store
<
Context
>&
store
)
=
delete
;
:
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
basic_format_args
<
Context
>
(),
#endif
data_
(
store
.
data_
),
named_info_
(
store
.
named_info_
)
{
}
/**
/**
\rst
\rst
...
...
test/args-test.cc
View file @
be51ee1c
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include "gtest/gtest.h"
#include "gtest/gtest.h"
TEST
(
args_test
,
basic
)
{
TEST
(
args_test
,
basic
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
store
.
push_back
(
42
);
store
.
push_back
(
42
);
store
.
push_back
(
"abc1"
);
store
.
push_back
(
"abc1"
);
store
.
push_back
(
1.5
f
);
store
.
push_back
(
1.5
f
);
...
@@ -19,7 +19,7 @@ TEST(args_test, basic) {
...
@@ -19,7 +19,7 @@ TEST(args_test, basic) {
TEST
(
args_test
,
strings_and_refs
)
{
TEST
(
args_test
,
strings_and_refs
)
{
// Unfortunately the tests are compiled with old ABI so strings use COW.
// Unfortunately the tests are compiled with old ABI so strings use COW.
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
char
str
[]
=
"1234567890"
;
char
str
[]
=
"1234567890"
;
store
.
push_back
(
str
);
store
.
push_back
(
str
);
store
.
push_back
(
std
::
cref
(
str
));
store
.
push_back
(
std
::
cref
(
str
));
...
@@ -48,7 +48,7 @@ template <> struct formatter<custom_type> {
...
@@ -48,7 +48,7 @@ template <> struct formatter<custom_type> {
FMT_END_NAMESPACE
FMT_END_NAMESPACE
TEST
(
args_test
,
custom_format
)
{
TEST
(
args_test
,
custom_format
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
auto
c
=
custom_type
();
auto
c
=
custom_type
();
store
.
push_back
(
c
);
store
.
push_back
(
c
);
++
c
.
i
;
++
c
.
i
;
...
@@ -77,7 +77,7 @@ template <> struct formatter<to_stringable> {
...
@@ -77,7 +77,7 @@ template <> struct formatter<to_stringable> {
FMT_END_NAMESPACE
FMT_END_NAMESPACE
TEST
(
args_test
,
to_string_and_formatter
)
{
TEST
(
args_test
,
to_string_and_formatter
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
auto
s
=
to_stringable
();
auto
s
=
to_stringable
();
store
.
push_back
(
s
);
store
.
push_back
(
s
);
store
.
push_back
(
std
::
cref
(
s
));
store
.
push_back
(
std
::
cref
(
s
));
...
@@ -85,13 +85,13 @@ TEST(args_test, to_string_and_formatter) {
...
@@ -85,13 +85,13 @@ TEST(args_test, to_string_and_formatter) {
}
}
TEST
(
args_test
,
named_int
)
{
TEST
(
args_test
,
named_int
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
store
.
push_back
(
fmt
::
arg
(
"a1"
,
42
));
store
.
push_back
(
fmt
::
arg
(
"a1"
,
42
));
EXPECT_EQ
(
"42"
,
fmt
::
vformat
(
"{a1}"
,
store
));
EXPECT_EQ
(
"42"
,
fmt
::
vformat
(
"{a1}"
,
store
));
}
}
TEST
(
args_test
,
named_strings
)
{
TEST
(
args_test
,
named_strings
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
char
str
[]
=
"1234567890"
;
char
str
[]
=
"1234567890"
;
store
.
push_back
(
fmt
::
arg
(
"a1"
,
str
));
store
.
push_back
(
fmt
::
arg
(
"a1"
,
str
));
store
.
push_back
(
fmt
::
arg
(
"a2"
,
std
::
cref
(
str
)));
store
.
push_back
(
fmt
::
arg
(
"a2"
,
std
::
cref
(
str
)));
...
@@ -100,7 +100,7 @@ TEST(args_test, named_strings) {
...
@@ -100,7 +100,7 @@ TEST(args_test, named_strings) {
}
}
TEST
(
args_test
,
named_arg_by_ref
)
{
TEST
(
args_test
,
named_arg_by_ref
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
char
band
[]
=
"Rolling Stones"
;
char
band
[]
=
"Rolling Stones"
;
store
.
push_back
(
fmt
::
arg
(
"band"
,
std
::
cref
(
band
)));
store
.
push_back
(
fmt
::
arg
(
"band"
,
std
::
cref
(
band
)));
band
[
9
]
=
'c'
;
// Changing band affects the output.
band
[
9
]
=
'c'
;
// Changing band affects the output.
...
@@ -108,7 +108,7 @@ TEST(args_test, named_arg_by_ref) {
...
@@ -108,7 +108,7 @@ TEST(args_test, named_arg_by_ref) {
}
}
TEST
(
args_test
,
named_custom_format
)
{
TEST
(
args_test
,
named_custom_format
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
auto
c
=
custom_type
();
auto
c
=
custom_type
();
store
.
push_back
(
fmt
::
arg
(
"c1"
,
c
));
store
.
push_back
(
fmt
::
arg
(
"c1"
,
c
));
++
c
.
i
;
++
c
.
i
;
...
@@ -121,7 +121,7 @@ TEST(args_test, named_custom_format) {
...
@@ -121,7 +121,7 @@ TEST(args_test, named_custom_format) {
}
}
TEST
(
args_test
,
clear
)
{
TEST
(
args_test
,
clear
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
store
.
push_back
(
42
);
store
.
push_back
(
42
);
auto
result
=
fmt
::
vformat
(
"{}"
,
store
);
auto
result
=
fmt
::
vformat
(
"{}"
,
store
);
...
@@ -138,7 +138,7 @@ TEST(args_test, clear) {
...
@@ -138,7 +138,7 @@ TEST(args_test, clear) {
}
}
TEST
(
args_test
,
reserve
)
{
TEST
(
args_test
,
reserve
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
store
.
reserve
(
2
,
1
);
store
.
reserve
(
2
,
1
);
store
.
push_back
(
1.5
f
);
store
.
push_back
(
1.5
f
);
store
.
push_back
(
fmt
::
arg
(
"a1"
,
42
));
store
.
push_back
(
fmt
::
arg
(
"a1"
,
42
));
...
@@ -163,7 +163,7 @@ template <> struct formatter<copy_throwable> {
...
@@ -163,7 +163,7 @@ template <> struct formatter<copy_throwable> {
FMT_END_NAMESPACE
FMT_END_NAMESPACE
TEST
(
args_test
,
throw_on_copy
)
{
TEST
(
args_test
,
throw_on_copy
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
()
;
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
store
;
store
.
push_back
(
std
::
string
(
"foo"
));
store
.
push_back
(
std
::
string
(
"foo"
));
try
{
try
{
store
.
push_back
(
copy_throwable
());
store
.
push_back
(
copy_throwable
());
...
@@ -171,16 +171,3 @@ TEST(args_test, throw_on_copy) {
...
@@ -171,16 +171,3 @@ TEST(args_test, throw_on_copy) {
}
}
EXPECT_EQ
(
fmt
::
vformat
(
"{}"
,
store
),
"foo"
);
EXPECT_EQ
(
fmt
::
vformat
(
"{}"
,
store
),
"foo"
);
}
}
TEST
(
args_test
,
copy_constructor
)
{
auto
store
=
fmt
::
dynamic_format_arg_store
<
fmt
::
format_context
>
();
store
.
push_back
(
fmt
::
arg
(
"test1"
,
"value1"
));
store
.
push_back
(
fmt
::
arg
(
"test2"
,
"value2"
));
store
.
push_back
(
fmt
::
arg
(
"test3"
,
"value3"
));
auto
store2
=
store
;
store2
.
push_back
(
fmt
::
arg
(
"test4"
,
"value4"
));
auto
result
=
fmt
::
vformat
(
"{test1} {test2} {test3} {test4}"
,
store2
);
EXPECT_EQ
(
result
,
"value1 value2 value3 value4"
);
}
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