Re: std::array - if only it knew its size
On 2011-04-07 10:07, Ricky65 wrote:
Thank you for you're feedback. The make_array template you provided
seems like a good solution for now, thanks for sharing it. However, am
I right in saying that variadic templates only take a finite number of
arguments?
I'm not sure that I properly understand your question: How would you call a variadic function with an infinite number of arguments?
The requirements on variadic template parameter are indirectly described by those on template arguments and function call arguments. The guidelines for the minimum number of to be supported template arguments is 1024, which compares quite well against the corresponding guideline in regard to the minimum number of arguments in any function call (256).
Do you have an example where this pure-library solution would not work?
[Let me add that my make_array suggestion requires a fix as noted by Johannes Schaub in another message: It currently relies on the fact that the used form of list-initialization with elided braces is supported, which is incorrect. Also needed is a special solution for the zero-length case, because there exists no portable unique syntax based on list-initialization for std::array. Fortunately we can fall-back to the well-known parenthesized form of value-initialization here, which I will fix in my follow-up contribution]
After reading the standards committee link I am hopefull that this
will be addressed at the next revision of the standard. Personally I'd
eventually like to be able to do "std::array<int> a = { 1, 4, 6 };"
but it's not worth fussing over I guess.
I think this will be very hard to realize without considerable change of the language, thus this won't happen before the nest standard revision and would probably require a good proposal that explains how that should work in the general case. I doubt the core language would accept an extra rule limited to the library component std::array ;-)
HTH & Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]