Variadic Templates For Gnu Cpp

VariadicTemplates are an addition to CeePlusPlus which were implemented on a trial basis by modifying the GnuCpp compiler.

They are now available with compilers which support the new standard CeePlusPlusEleven.


Historic notes

For details see http://www.osl.iu.edu/~dgregor/cpp/variadic-templates.html

There are some binaries on Doug Gregor's website to download and try out.

One of the motivations for this is to use it to implement some of the items in TechnicalReportOne in a more efficient way. The modified compiler includes implementations of a lot of this, including tuple and bind from the BoostLibraries.

I have been exploring using this in combination with FunctoidsInCpp. -- JohnFletcher

I'm curious how they implemented this. Does the compiler create a full recursive expansion for every permutation of parameters that gets used, or does it do some sort of fancy dispatch at runtime? The former tends to optimize for speed, while the latter tends to optimize for code size. I suppose a SufficientlySmartCompiler could do both, favoring runtime dispatch unless it can achieve a significant speed-up by expanding for some particular sequence of types. Anyone know what GnuCpp does? -- MichaelSparks

Yes, the compiler creates a full recursive expansion for every permutation of parameters that gets used, because we did not want to change how template instantiation works for a relatively small addition to the C++ template system. -- Douglas Gregor

It is possible to inspect the source code at the web reference given. What is supplied is a patch file for gcc 4.1.1. -- JohnFletcher


April 2007 The variadic additions are now available in an experimental version of gcc 4.3

See the web site above.

I have used the experimental compilers to build a variadic version of the BoostFusionUserExtension which makes it much easier for the user to write a new structure.

February 2009 This has evolved into a variadic tuple for BoostFusion. Work is in progress on a variadic version of BoostMpl.

November 2009 I have also worked a variadic version of FunctoidsInCpp - see VariadicFunctoidsInCpp.

-- JohnFletcher


CategoryCpp CategoryCppTemplates


EditText of this page (last edited April 2, 2012) or FindPage with title or text search