0

1

template <class ...Args>
constexpr
int32_t mymin(int32_t first, Args... rest) {
    return mymin(first, mymin(rest...));
}

2

template <class ...Args>
constexpr
int32_t mymin(int32_t first, Args... rest) {
    return mymin(first, mymin(rest)...);
}

It seems like #1 looks like

template <class ...Args>
constexpr
int32_t mymin(int32_t first, Args... rest) {
    return mymin(first, mymin(rest0, rest1, rest2, ..., restn)); // not a valid C++ code
}

How about #2? How does the "expanded" version look like?

Thanks in advance.

Community
  • 1
  • 1
Hei
  • 1,844
  • 3
  • 21
  • 35
  • You're correct on #1, #2 would expand the *full* call... `mymin(first, mymin(rest0), mymin(rest1), ..., mymin(restn))` – Barry Mar 15 '16 at 01:40
  • won't it fail to compile? because there is no function with a signature like int32_t mymin(int32_t)? – Hei Mar 15 '16 at 01:50
  • Not with that signature, but there are functions `mymin` that can be called with one argument. – Barry Mar 15 '16 at 01:52
  • thanks for quick reply. would you mind sharing how the signature looks like? – Hei Mar 15 '16 at 01:55
  • 1
    There's one viable `mymin` right there - the function template instantiated with an empty pack. Of course, if that's selected then you get infinite recursion... – T.C. Mar 15 '16 at 09:05

0 Answers0