fmtlib
has a function like:
template <typename S, typename... Args, typename Char = char_t<S>>
inline std::basic_string<Char> format(const S& format_str, Args&&... args) {
return internal::vformat(
to_string_view(format_str),
{internal::make_args_checked<Args...>(format_str, args...)});
}
I've defined a macro for my convenience like:
#define FMT fmt::format
I use it like:
std::cout<<FMT("Name: {0}\n", "Joe");
Is there an alternative to using macro for this in C++11, preferably one that doesn't hit performance?
You can define the same function with a shorter name (in your own code). This function is named
FMT()
and it passes its parameters tofmt::format()
, which is the original function you want to call:Demo