Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMT_VARIADIC_CONST - Support for const variadic methods #591

Merged
merged 3 commits into from
Oct 22, 2017
Merged

FMT_VARIADIC_CONST - Support for const variadic methods #591

merged 3 commits into from
Oct 22, 2017

Conversation

ludekvodicka
Copy link
Contributor

Implementation of FMT_VARIDIC_CONST as discussed here #589

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but could you format the code according to the coding style: Please format according to our coding style: https://github.com/fmtlib/fmt/blob/master/CONTRIBUTING.rst (mostly Google style).

Thanks for contributing!

fmt/format.h Outdated
@@ -3647,35 +3647,35 @@ void arg(WStringRef, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFINED;
#else
// Defines a wrapper for a function taking __VA_ARGS__ arguments
// and n additional arguments of arbitrary types.
# define FMT_WRAP(Char, ReturnType, func, call, n, ...) \
# define FMT_WRAP(Const,Char, ReturnType, func, call, n, ...) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing space after ,

fmt/format.h Outdated
fmt::internal::ArgArray<n>::Type arr; \
FMT_GEN(n, FMT_ASSIGN_##Char); \
call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), fmt::ArgList( \
fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), arr)); \
}

# define FMT_VARIADIC_(Char, ReturnType, func, call, ...) \
inline ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__)) { \
# define FMT_VARIADIC_(Const,Char, ReturnType, func, call, ...) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also here

fmt/format.h Outdated
@@ -3706,10 +3706,16 @@ void arg(WStringRef, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFINED;
\endrst
*/
#define FMT_VARIADIC(ReturnType, func, ...) \
FMT_VARIADIC_(char, ReturnType, func, return func, __VA_ARGS__)
FMT_VARIADIC_(,char, ReturnType, func, return func, __VA_ARGS__)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

@ludekvodicka
Copy link
Contributor Author

Sure, done. Sorry for this, I overlooked it.

TEST(FormatTest, ConstFormatMessage) {
test_class c;
EXPECT_EQ("[42] something happened",
c.format_message(42, "{} happened", "something"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Please use 2-space indent instead of tabs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It's interesting because it's copy-paste from your code. Visual studio had to reformat it.

@vitaut vitaut merged commit 7a9c1ba into fmtlib:master Oct 22, 2017
@vitaut
Copy link
Contributor

vitaut commented Oct 22, 2017

Merged, thanks!

@ludekvodicka
Copy link
Contributor Author

You're welcome. And thank you for your patience, this was my first public PR ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants