PacktPublishing / Template-Metaprogramming-with-CPP

Template Metaprogramming with C++, published by Packt
MIT License
82 stars 25 forks source link

Chapter 3 - Compile Error GCC #5

Open ludvikjerabek opened 10 months ago

ludvikjerabek commented 10 months ago

GCC shows the following error.

/mnt/c/Users/ljerabek/Documents/GitHub/Template-Metaprogramming-with-CPP/src/chapter_03/main.cpp:335:56: error: expected primary-expression before ‘;’ token
  335 |    constexpr auto indexes = std::make_index_sequence<5>;

Clang shows the following error.

/mnt/c/Users/ljerabek/Documents/GitHub/Template-Metaprogramming-with-CPP/src/chapter_03/main.cpp:335:56: error: expected '(' for function-style cast or type construction
   constexpr auto indexes = std::make_index_sequence<5>;
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~^

It appears that it's easy to fix.

namespace n316
{
   template <int... R>
   constexpr int Sum = (... + R);

   template <int... I>
   constexpr auto indexes = std::make_index_sequence<5>(); // Just add parenthesis to the following line as shown.
}