0

I stumbled upon an error, and I am unsure what is causing it. You can find the code here: https://godbolt.org/z/F9zdHg

#include <utility>

#define USE_PACK 1

#if USE_PACK == 1
template<int N, typename ...type_pack>
auto ap(type_pack...pack)
#else
template<int N>
auto ap()
#endif
{
    auto sum = []<int ...Is>(std::index_sequence<Is...>) { return (Is + ...); };
    return sum(std::make_index_sequence<N>{});
}

int main()
{
    return ap<5>();
}

If you set USE_PACK 0 everything compiles fine, otherwise I get a strange error about the expansion of Is.... Is this a compiler bug, or am I doing something wrong?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
lightxbulb
  • 1,251
  • 12
  • 29
  • It's kind of hard to tell without seeing the error. – Nicol Bolas Oct 20 '19 at 15:17
  • @NicolBolas That's what the godbolt link was meant for. But this is the first error that I get at the `Is...` expansion: `error C3546: '...': there are no parameter packs available to expand`. If `USE_PACK 0` then there's no error whatsoever. The only difference being the parameter pack in the parent function, but I don't think that should affect the lambda. – lightxbulb Oct 20 '19 at 15:20
  • 2
    On G++/Clang works fine with `-std=c++2a` flag and with one change: `int...Is` should be `size_t ... Is`, [live demo](https://godbolt.org/z/-Nn_ZD). – rafix07 Oct 20 '19 at 15:53
  • 1
    @rafix07 So I guess this is a compiler bug then. I will report it to MS. – lightxbulb Oct 20 '19 at 15:56

0 Answers0