mirror of
https://github.com/fmtlib/fmt.git
synced 2025-08-02 04:04:44 +02:00
FMT_TEMPLATE -> FMT_WRAP
This commit is contained in:
15
format.h
15
format.h
@@ -893,12 +893,15 @@ public:
|
|||||||
# define FMT_GEN7(f) FMT_GEN6(f), f(7)
|
# define FMT_GEN7(f) FMT_GEN6(f), f(7)
|
||||||
# define FMT_GEN8(f) FMT_GEN7(f), f(8)
|
# define FMT_GEN8(f) FMT_GEN7(f), f(8)
|
||||||
# define FMT_GEN9(f) FMT_GEN8(f), f(9)
|
# 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_TEMPLATE_ARG(n) typename T##n
|
||||||
# define FMT_MAKE_ARG(n) const T##n &v##n
|
# define FMT_MAKE_ARG(n) const T##n &v##n
|
||||||
# define FMT_MAKE_REF(n) fmt::Writer::MakeArg(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)> \
|
template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \
|
||||||
inline void func(arg_type arg1, FMT_GEN(n, FMT_MAKE_ARG)) { \
|
inline void func(arg_type arg1, FMT_GEN(n, FMT_MAKE_ARG)) { \
|
||||||
const fmt::internal::ArgInfo args[] = {FMT_GEN(n, FMT_MAKE_REF)}; \
|
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.
|
// Emulates a variadic function returning void on a pre-C++11 compiler.
|
||||||
# define FMT_VARIADIC_VOID(func, arg_type) \
|
# define FMT_VARIADIC_VOID(func, arg_type) \
|
||||||
FMT_TEMPLATE(func, arg_type, 1) FMT_TEMPLATE(func, arg_type, 2) \
|
FMT_WRAP(func, arg_type, 1) FMT_WRAP(func, arg_type, 2) \
|
||||||
FMT_TEMPLATE(func, arg_type, 3) FMT_TEMPLATE(func, arg_type, 4) \
|
FMT_WRAP(func, arg_type, 3) FMT_WRAP(func, arg_type, 4) \
|
||||||
FMT_TEMPLATE(func, arg_type, 5) FMT_TEMPLATE(func, arg_type, 6) \
|
FMT_WRAP(func, arg_type, 5) FMT_WRAP(func, arg_type, 6) \
|
||||||
FMT_TEMPLATE(func, arg_type, 7) FMT_TEMPLATE(func, arg_type, 8) \
|
FMT_WRAP(func, arg_type, 7) FMT_WRAP(func, arg_type, 8) \
|
||||||
FMT_TEMPLATE(func, arg_type, 9)
|
FMT_WRAP(func, arg_type, 9) FMT_WRAP(func, arg_type, 10)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -45,12 +45,12 @@ int result;
|
|||||||
result += args[i].int_value; \
|
result += args[i].int_value; \
|
||||||
}
|
}
|
||||||
|
|
||||||
MAKE_TEST(TestTemplate)
|
MAKE_TEST(TestFunc)
|
||||||
FMT_TEMPLATE(TestTemplate, const char *, 1)
|
FMT_WRAP(TestFunc, const char *, 1)
|
||||||
|
|
||||||
TEST(UtilTest, Template) {
|
TEST(UtilTest, Template) {
|
||||||
result = 0;
|
result = 0;
|
||||||
TestTemplate("", 42);
|
TestFunc("", 42);
|
||||||
EXPECT_EQ(42, result);
|
EXPECT_EQ(42, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user