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
abb6996f
Commit
abb6996f
authored
Dec 27, 2016
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MakeArg -> make_arg
parent
ee1651ce
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
30 additions
and
27 deletions
+30
-27
fmt/format.h
fmt/format.h
+20
-16
fmt/ostream.h
fmt/ostream.h
+2
-2
fmt/printf.h
fmt/printf.h
+5
-5
test/format-impl-test.cc
test/format-impl-test.cc
+1
-1
test/ostream-test.cc
test/ostream-test.cc
+1
-1
test/util-test.cc
test/util-test.cc
+1
-2
No files found.
fmt/format.h
View file @
abb6996f
...
@@ -371,6 +371,9 @@ class BasicWriter;
...
@@ -371,6 +371,9 @@ class BasicWriter;
typedef
BasicWriter
<
char
>
Writer
;
typedef
BasicWriter
<
char
>
Writer
;
typedef
BasicWriter
<
wchar_t
>
WWriter
;
typedef
BasicWriter
<
wchar_t
>
WWriter
;
template
<
typename
Char
>
class
basic_format_arg
;
template
<
typename
Char
>
template
<
typename
Char
>
class
ArgFormatter
;
class
ArgFormatter
;
...
@@ -1329,6 +1332,9 @@ class MakeValue : public Value<typename Context::char_type> {
...
@@ -1329,6 +1332,9 @@ class MakeValue : public Value<typename Context::char_type> {
template
<
typename
Char
>
template
<
typename
Char
>
class
ArgMap
;
class
ArgMap
;
template
<
typename
Context
,
typename
T
>
basic_format_arg
<
typename
Context
::
char_type
>
make_arg
(
const
T
&
value
);
}
// namespace internal
}
// namespace internal
struct
monostate
{};
struct
monostate
{};
...
@@ -1340,10 +1346,14 @@ class basic_format_args;
...
@@ -1340,10 +1346,14 @@ class basic_format_args;
// allow storage in internal::MemoryBuffer.
// allow storage in internal::MemoryBuffer.
template
<
typename
Char
>
template
<
typename
Char
>
class
basic_format_arg
{
class
basic_format_arg
{
pr
otected
:
pr
ivate
:
internal
::
Value
<
Char
>
value_
;
internal
::
Value
<
Char
>
value_
;
internal
::
Type
type_
;
internal
::
Type
type_
;
template
<
typename
Context
,
typename
T
>
friend
basic_format_arg
<
typename
Context
::
char_type
>
internal
::
make_arg
(
const
T
&
value
);
template
<
typename
Visitor
,
typename
CharType
>
template
<
typename
Visitor
,
typename
CharType
>
friend
typename
std
::
result_of
<
Visitor
(
int
)
>::
type
friend
typename
std
::
result_of
<
Visitor
(
int
)
>::
type
visit
(
Visitor
&&
vis
,
basic_format_arg
<
CharType
>
arg
);
visit
(
Visitor
&&
vis
,
basic_format_arg
<
CharType
>
arg
);
...
@@ -1426,19 +1436,13 @@ typename std::result_of<Visitor(int)>::type
...
@@ -1426,19 +1436,13 @@ typename std::result_of<Visitor(int)>::type
namespace
internal
{
namespace
internal
{
template
<
typename
Context
>
template
<
typename
Context
,
typename
T
>
class
MakeArg
:
public
basic_format_arg
<
typename
Context
::
char_type
>
{
basic_format_arg
<
typename
Context
::
char_type
>
make_arg
(
const
T
&
value
)
{
public:
basic_format_arg
<
typename
Context
::
char_type
>
arg
;
MakeArg
()
{
arg
.
type_
=
internal
::
type
<
T
>
();
this
->
type_
=
internal
::
NONE
;
arg
.
value_
=
internal
::
MakeValue
<
Context
>
(
value
);
}
return
arg
;
}
template
<
typename
T
>
MakeArg
(
const
T
&
value
)
{
this
->
value_
=
internal
::
MakeValue
<
Context
>
(
value
);
this
->
type_
=
internal
::
type
<
T
>
();
}
};
template
<
typename
T
,
T
>
struct
LConvCheck
{
template
<
typename
T
,
T
>
struct
LConvCheck
{
LConvCheck
(
int
)
{}
LConvCheck
(
int
)
{}
...
@@ -1490,7 +1494,7 @@ struct NamedArg : basic_format_arg<Char> {
...
@@ -1490,7 +1494,7 @@ struct NamedArg : basic_format_arg<Char> {
template
<
typename
T
>
template
<
typename
T
>
NamedArg
(
BasicStringRef
<
Char
>
argname
,
const
T
&
value
)
NamedArg
(
BasicStringRef
<
Char
>
argname
,
const
T
&
value
)
:
basic_format_arg
<
Char
>
(
MakeA
rg
<
basic_format_context
<
Char
>
>
(
value
)),
:
basic_format_arg
<
Char
>
(
make_a
rg
<
basic_format_context
<
Char
>
>
(
value
)),
name
(
argname
)
{}
name
(
argname
)
{}
};
};
...
@@ -1522,7 +1526,7 @@ template <bool IS_PACKED, typename Context, typename T>
...
@@ -1522,7 +1526,7 @@ template <bool IS_PACKED, typename Context, typename T>
inline
typename
std
::
enable_if
<
inline
typename
std
::
enable_if
<
!
IS_PACKED
,
basic_format_arg
<
typename
Context
::
char_type
>>::
type
!
IS_PACKED
,
basic_format_arg
<
typename
Context
::
char_type
>>::
type
make_arg
(
const
T
&
value
)
{
make_arg
(
const
T
&
value
)
{
return
MakeA
rg
<
Context
>
(
value
);
return
make_a
rg
<
Context
>
(
value
);
}
}
}
// namespace internal
}
// namespace internal
...
...
fmt/ostream.h
View file @
abb6996f
...
@@ -87,8 +87,8 @@ void format_value(BasicWriter<Char> &w, const T &value,
...
@@ -87,8 +87,8 @@ void format_value(BasicWriter<Char> &w, const T &value,
basic_format_context
<
Char
>
&
ctx
)
{
basic_format_context
<
Char
>
&
ctx
)
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
auto
str
=
internal
::
format_value
(
buffer
,
value
);
auto
str
=
internal
::
format_value
(
buffer
,
value
);
typedef
internal
::
MakeArg
<
basic_format_context
<
Char
>
>
MakeArg
;
do_format_arg
<
ArgFormatter
<
Char
>
>
(
do_format_arg
<
ArgFormatter
<
Char
>
>
(
w
,
MakeArg
(
str
),
ctx
);
w
,
internal
::
make_arg
<
basic_format_context
<
Char
>
>
(
str
),
ctx
);
}
}
FMT_API
void
vprint
(
std
::
ostream
&
os
,
CStringRef
format_str
,
format_args
args
);
FMT_API
void
vprint
(
std
::
ostream
&
os
,
CStringRef
format_str
,
format_args
args
);
...
...
fmt/printf.h
View file @
abb6996f
...
@@ -105,11 +105,11 @@ class ArgConverter {
...
@@ -105,11 +105,11 @@ class ArgConverter {
if
(
sizeof
(
TargetType
)
<=
sizeof
(
int
))
{
if
(
sizeof
(
TargetType
)
<=
sizeof
(
int
))
{
// Extra casts are used to silence warnings.
// Extra casts are used to silence warnings.
if
(
is_signed
)
{
if
(
is_signed
)
{
arg_
=
internal
::
MakeA
rg
<
format_context
>
(
arg_
=
internal
::
make_a
rg
<
format_context
>
(
static_cast
<
int
>
(
static_cast
<
TargetType
>
(
value
)));
static_cast
<
int
>
(
static_cast
<
TargetType
>
(
value
)));
}
else
{
}
else
{
typedef
typename
internal
::
MakeUnsigned
<
TargetType
>::
Type
Unsigned
;
typedef
typename
internal
::
MakeUnsigned
<
TargetType
>::
Type
Unsigned
;
arg_
=
internal
::
MakeA
rg
<
format_context
>
(
arg_
=
internal
::
make_a
rg
<
format_context
>
(
static_cast
<
unsigned
>
(
static_cast
<
Unsigned
>
(
value
)));
static_cast
<
unsigned
>
(
static_cast
<
Unsigned
>
(
value
)));
}
}
}
else
{
}
else
{
...
@@ -117,10 +117,10 @@ class ArgConverter {
...
@@ -117,10 +117,10 @@ class ArgConverter {
// glibc's printf doesn't sign extend arguments of smaller types:
// glibc's printf doesn't sign extend arguments of smaller types:
// std::printf("%lld", -42); // prints "4294967254"
// std::printf("%lld", -42); // prints "4294967254"
// but we don't have to do the same because it's a UB.
// but we don't have to do the same because it's a UB.
arg_
=
internal
::
MakeA
rg
<
format_context
>
(
arg_
=
internal
::
make_a
rg
<
format_context
>
(
static_cast
<
LongLong
>
(
value
));
static_cast
<
LongLong
>
(
value
));
}
else
{
}
else
{
arg_
=
internal
::
MakeA
rg
<
format_context
>
(
arg_
=
internal
::
make_a
rg
<
format_context
>
(
static_cast
<
typename
internal
::
MakeUnsigned
<
U
>::
Type
>
(
value
));
static_cast
<
typename
internal
::
MakeUnsigned
<
U
>::
Type
>
(
value
));
}
}
}
}
...
@@ -157,7 +157,7 @@ class CharConverter {
...
@@ -157,7 +157,7 @@ class CharConverter {
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
typename
std
::
enable_if
<
std
::
is_integral
<
T
>::
value
>::
type
operator
()(
T
value
)
{
operator
()(
T
value
)
{
arg_
=
arg_
=
internal
::
MakeA
rg
<
basic_format_context
<
Char
>>
(
static_cast
<
char
>
(
value
));
internal
::
make_a
rg
<
basic_format_context
<
Char
>>
(
static_cast
<
char
>
(
value
));
}
}
template
<
typename
T
>
template
<
typename
T
>
...
...
test/format-impl-test.cc
View file @
abb6996f
...
@@ -57,7 +57,7 @@ struct ValueExtractor {
...
@@ -57,7 +57,7 @@ struct ValueExtractor {
TEST
(
FormatTest
,
ArgConverter
)
{
TEST
(
FormatTest
,
ArgConverter
)
{
using
fmt
::
format_arg
;
using
fmt
::
format_arg
;
fmt
::
LongLong
value
=
std
::
numeric_limits
<
fmt
::
LongLong
>::
max
();
fmt
::
LongLong
value
=
std
::
numeric_limits
<
fmt
::
LongLong
>::
max
();
format_arg
arg
=
fmt
::
internal
::
MakeA
rg
<
fmt
::
format_context
>
(
value
);
format_arg
arg
=
fmt
::
internal
::
make_a
rg
<
fmt
::
format_context
>
(
value
);
visit
(
fmt
::
internal
::
ArgConverter
<
fmt
::
LongLong
,
char
>
(
arg
,
'd'
),
arg
);
visit
(
fmt
::
internal
::
ArgConverter
<
fmt
::
LongLong
,
char
>
(
arg
,
'd'
),
arg
);
EXPECT_EQ
(
value
,
visit
(
ValueExtractor
<
fmt
::
LongLong
>
(),
arg
));
EXPECT_EQ
(
value
,
visit
(
ValueExtractor
<
fmt
::
LongLong
>
(),
arg
));
}
}
...
...
test/ostream-test.cc
View file @
abb6996f
...
@@ -69,7 +69,7 @@ TEST(OStreamTest, CustomArg) {
...
@@ -69,7 +69,7 @@ TEST(OStreamTest, CustomArg) {
fmt
::
format_context
ctx
(
"}"
,
fmt
::
format_args
());
fmt
::
format_context
ctx
(
"}"
,
fmt
::
format_args
());
fmt
::
FormatSpec
spec
;
fmt
::
FormatSpec
spec
;
TestArgFormatter
af
(
writer
,
ctx
,
spec
);
TestArgFormatter
af
(
writer
,
ctx
,
spec
);
visit
(
af
,
fmt
::
internal
::
MakeA
rg
<
fmt
::
format_context
>
(
TestEnum
()));
visit
(
af
,
fmt
::
internal
::
make_a
rg
<
fmt
::
format_context
>
(
TestEnum
()));
EXPECT_EQ
(
"TestEnum"
,
writer
.
str
());
EXPECT_EQ
(
"TestEnum"
,
writer
.
str
());
}
}
...
...
test/util-test.cc
View file @
abb6996f
...
@@ -75,8 +75,7 @@ void format_value(fmt::BasicWriter<Char> &w, Test,
...
@@ -75,8 +75,7 @@ void format_value(fmt::BasicWriter<Char> &w, Test,
template
<
typename
Char
,
typename
T
>
template
<
typename
Char
,
typename
T
>
basic_format_arg
<
Char
>
make_arg
(
const
T
&
value
)
{
basic_format_arg
<
Char
>
make_arg
(
const
T
&
value
)
{
typedef
fmt
::
internal
::
MakeArg
<
fmt
::
basic_format_context
<
Char
>
>
MakeArg
;
return
fmt
::
internal
::
make_arg
<
fmt
::
basic_format_context
<
Char
>
>
(
value
);
return
MakeArg
(
value
);
}
}
}
// namespace
}
// namespace
...
...
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