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
bf25ef64
Commit
bf25ef64
authored
Jun 28, 2014
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FMT_TEMPLATE -> FMT_WRAP
parent
08e2dffa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
format.h
format.h
+18
-15
test/macro-test.cc
test/macro-test.cc
+3
-3
No files found.
format.h
View file @
bf25ef64
...
...
@@ -884,21 +884,24 @@ public:
#else
// Generates a comma-separated list with results of applying f to numbers 1..n.
# define FMT_GEN(n, f) FMT_GEN##n(f)
# define FMT_GEN1(f) f(1)
# define FMT_GEN2(f) FMT_GEN1(f), f(2)
# define FMT_GEN3(f) FMT_GEN2(f), f(3)
# define FMT_GEN4(f) FMT_GEN3(f), f(4)
# define FMT_GEN5(f) FMT_GEN4(f), f(5)
# define FMT_GEN6(f) FMT_GEN5(f), f(6)
# define FMT_GEN7(f) FMT_GEN6(f), f(7)
# define FMT_GEN8(f) FMT_GEN7(f), f(8)
# define FMT_GEN9(f) FMT_GEN8(f), f(9)
# define FMT_GEN1(f) f(1)
# define FMT_GEN2(f) FMT_GEN1(f), f(2)
# define FMT_GEN3(f) FMT_GEN2(f), f(3)
# define FMT_GEN4(f) FMT_GEN3(f), f(4)
# define FMT_GEN5(f) FMT_GEN4(f), f(5)
# define FMT_GEN6(f) FMT_GEN5(f), f(6)
# define FMT_GEN7(f) FMT_GEN6(f), f(7)
# define FMT_GEN8(f) FMT_GEN7(f), f(8)
# define FMT_GEN9(f) FMT_GEN8(f), f(9)
# define FMT_GEN10(f) FMT_GEN9(f), f(10)
# define FMT_MAKE_TEMPLATE_ARG(n) typename T##n
# define FMT_MAKE_ARG(n) const T##n &v##n
# define FMT_MAKE_REF(n) fmt::Writer::MakeArg(v##n)
# define FMT_TEMPLATE(func, arg_type, n) \
// Defines a wrapper for a function taking one argument of type arg_type
// and n additional arguments of arbitrary types.
# define FMT_WRAP(func, arg_type, n) \
template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \
inline void func(arg_type arg1, FMT_GEN(n, FMT_MAKE_ARG)) { \
const fmt::internal::ArgInfo args[] = {FMT_GEN(n, FMT_MAKE_REF)}; \
...
...
@@ -907,11 +910,11 @@ public:
// Emulates a variadic function returning void on a pre-C++11 compiler.
# define FMT_VARIADIC_VOID(func, arg_type) \
FMT_
TEMPLATE(func, arg_type, 1) FMT_TEMPLATE
(func, arg_type, 2) \
FMT_
TEMPLATE(func, arg_type, 3) FMT_TEMPLATE
(func, arg_type, 4) \
FMT_
TEMPLATE(func, arg_type, 5) FMT_TEMPLATE
(func, arg_type, 6) \
FMT_
TEMPLATE(func, arg_type, 7) FMT_TEMPLATE
(func, arg_type, 8) \
FMT_
TEMPLATE(func, arg_type, 9
)
FMT_
WRAP(func, arg_type, 1) FMT_WRAP
(func, arg_type, 2) \
FMT_
WRAP(func, arg_type, 3) FMT_WRAP
(func, arg_type, 4) \
FMT_
WRAP(func, arg_type, 5) FMT_WRAP
(func, arg_type, 6) \
FMT_
WRAP(func, arg_type, 7) FMT_WRAP
(func, arg_type, 8) \
FMT_
WRAP(func, arg_type, 9) FMT_WRAP(func, arg_type, 10
)
#endif
/**
...
...
test/macro-test.cc
View file @
bf25ef64
...
...
@@ -45,12 +45,12 @@ int result;
result += args[i].int_value; \
}
MAKE_TEST
(
Test
Template
)
FMT_
TEMPLATE
(
TestTemplate
,
const
char
*
,
1
)
MAKE_TEST
(
Test
Func
)
FMT_
WRAP
(
TestFunc
,
const
char
*
,
1
)
TEST
(
UtilTest
,
Template
)
{
result
=
0
;
Test
Template
(
""
,
42
);
Test
Func
(
""
,
42
);
EXPECT_EQ
(
42
,
result
);
}
...
...
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