Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

11
  • 2
    A note regarding template instantiation depth, msvc dies at around 1000, gcc has an option to set the recursive depth, I've been able to create a 512 element lut with this suggestion - compile times are obviously a little longer than having the lut hard-coded in source, but all-in-all it works fine!!! :D Commented Jun 6, 2010 at 8:10
  • 1
    Amazing! It essentially allows the concatenation / extension of arrays I could not realize in C++03 with metatemplate. I think you should parameterize ArrayHolder with the MetaFunction though, in order to be able to define more than 1 array with a given arity. Commented Jun 6, 2010 at 10:40
  • 2
    as a work around for the fairly limited recursion depth some compilers allow, one may add more then one value to the "variadic values list" each step, decreasing the required depth M times, where M is the number of values added. For instance, for M=2 we have: template<size_t N, template<size_t> class F, unsigned... args> struct generate_array_impl { typedef typename generate_array_impl<N-2, F, F<N-1>::value, F<N>::value, args...>::result result; }; But please do not forget to treat the case where N%M != 0 Commented Jun 20, 2011 at 15:43
  • 1
    +100 I was about to throw std::initializer_list for constructors out the window, until I found your answer. It'll certainly be a while until I understand how this works, but I am in awe of this amazing bridge from compile-time to run-time. TYVM. Commented Feb 16, 2013 at 18:41
  • 1
    @Xocoatzin That is the parameter pack expansion, see e.g. here Commented Jul 24, 2015 at 12:04