Re:Template Metaprogramming with Modern C++: templates in depth
by Manu343726 on Monday September 29, 2014 @05:06PM
(#8385301)
There could be a bug on the code snippets included inside the post, sorry. Check the code running at compiler explorer, it's working and you can see clearly the result string literal at the end of the assembly.
The point of the example is: We represent a string as a variadic pack of chars, and build_string is a metafunction that builds that kind of string recursively given a starting character and a size. Inside that metafunction we define an aux metafunction build_string_impl that does the job, we only have to pass the required initial parameters (The count of chars and the initial empty string). The first partial specialization acts as the recursive case of that function, and the second is the base case (note count is 0 in that case).
Where I get lost is here:
This attempts to instantiate the build_string_impl template with a size_t and a string. But there is no implementation of the template with these types - only for size_t and variadic char. So how does this get instantiated?