Skip to content

Commit

Permalink
Fix compilation in C++0x mode
Browse files Browse the repository at this point in the history
Alias templates may not be supported even if variadic templates are.
  • Loading branch information
dean0x7d committed Dec 6, 2015
1 parent 983b883 commit 98ed65d
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions format.h
Original file line number Diff line number Diff line change
Expand Up @@ -1902,11 +1902,13 @@ inline uint64_t make_type(const T &arg) {
#if FMT_USE_VARIADIC_TEMPLATES

template <typename Formatter, unsigned N>
using ArgArray = typename Conditional<
N < ArgList::MAX_PACKED_ARGS,
MakeValue<Formatter>[(N > 0) ? N : 1],
MakeArg<Formatter>[N + 1]
>::type;
struct ArgArray {
typedef typename Conditional<
N < ArgList::MAX_PACKED_ARGS,
MakeValue<Formatter>[(N > 0) ? N : 1],
MakeArg<Formatter>[N + 1]
>::type Type;
};

template <typename Arg, typename... Args>
inline uint64_t make_type(const Arg &first, const Args & ... tail) {
Expand Down Expand Up @@ -1992,15 +1994,17 @@ class FormatBuf : public std::basic_streambuf<Char> {
# define FMT_VARIADIC_VOID(func, arg_type) \
template <typename... Args> \
void func(arg_type arg0, const Args & ... args) { \
fmt::internal::ArgArray<fmt::BasicFormatter<Char>, sizeof...(Args)> array{args...}; \
typename fmt::internal::ArgArray< \
fmt::BasicFormatter<Char>, sizeof...(Args)>::Type array{args...}; \
func(arg0, fmt::ArgList(fmt::internal::make_type(args...), array)); \
}

// Defines a variadic constructor.
# define FMT_VARIADIC_CTOR(ctor, func, arg0_type, arg1_type) \
template <typename... Args> \
ctor(arg0_type arg0, arg1_type arg1, const Args & ... args) { \
fmt::internal::ArgArray<fmt::BasicFormatter<Char>, sizeof...(Args)> array{args...}; \
typename fmt::internal::ArgArray< \
fmt::BasicFormatter<Char>, sizeof...(Args)>::Type array{args...}; \
func(arg0, arg1, fmt::ArgList(fmt::internal::make_type(args...), array)); \
}

Expand Down Expand Up @@ -3218,7 +3222,8 @@ void arg(WStringRef, const internal::NamedArg<Char>&) FMT_DELETED_OR_UNDEFINED;
template <typename... Args> \
ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__), \
const Args & ... args) { \
fmt::internal::ArgArray<fmt::BasicFormatter<Char>, sizeof...(Args)> array{args...}; \
typename fmt::internal::ArgArray< \
fmt::BasicFormatter<Char>, sizeof...(Args)>::Type array{args...}; \
call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), \
fmt::ArgList(fmt::internal::make_type(args...), array)); \
}
Expand Down

0 comments on commit 98ed65d

Please sign in to comment.