Boost logo

Boost :

From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2006-08-05 23:55:06

On Aug 5, 2006, at 9:06 PM, Ion Gaztañaga wrote:
> [moderator: this might be a bit off-topic, sorry]

Naah, don't worry about it. Boost isn't about effecting change in the
language, but some changes could have enough of an impact on Boost to
warrant discussion. Besides, I'm hoping that the Boost membership can
come up with some good new tricks with variadic templates :)

> Douglas Gregor wrote:
>> On Aug 5, 2006, at 3:04 PM, Ion Gaztañaga wrote:
>>> -> First-class parameter packs
>> Will not be implemented. There are serious technical problems with
>> implementing first-class parameter packs that we had not foreseen. In
>> particular, to do a decent job of making sure parameter packs are
>> used properly when a template is defined, you need to know *exactly*
>> which things are parameter packs and which things aren't. With first-
>> class parameter packs, you don't always have this information
>> because.
> Umm. Native tuple without needing recursive instantiation trick was a
> very good idea to speed up compilation. Maybe the next time!

Sure, but that's a much bigger change to the language, and adding a
primitive tuple met some some implementor resistance. Eliminating the
need for the preprocessor to generate N versions of tuple, function,
bind, etc. should improve compile times quite nicely.

>>> -> Initializer lists are parameter packs
>> Still thinking about this one. It looks like it might be a good idea.
> In your vector example, the parameter list is introduced with a
> recursive function:
> template<typename T>
> class vector {
> public:
> template<typename... Values>
> vector(const Values&... values) {
> reserve(sizeof(values...));
> push back all(values...);
> }
> private:
> void push_back_all() { }
> template<typename... Values>
> void push_back_all(const T& value, const Values&... values) {
> push_back(value);
> push_back_all(values...);
> }
> };
> It would nice (just an idea) to have a way to execute an expression
> for
> every parameter, just like it was a function unrolling, implemented
> with
> with macros:
> template<typename... Values>
> void push back all(const T& value, const Values&... values) {
> std::variadic_unroll(push_back(value));
> }
> Just an idea for the future. I don't know if implementing this is too
> difficult. That would help with compilation time.

Oh, you can do that already, if you don't mind turning that push_back
call into a non-void expression:

   template<typename... Args>
   void variadic_unroll(const Args&...) { }

   template<typename... Values>
   void push_back_all(const Values&... values) {
     variadic_unroll((push_back(values), 0)...);


Boost list run by bdawes at, gregod at, cpdaniel at, john at