Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many arguments to std::bind (VC 11 only supports 4)

I'm playing with the developer preview of Visual Studio 11.

One of the short-comings I've stumbled upon is std::bind only supporting 4 function arguments.

I can't find anything about this in the C++11 standards paper. Is there defined a minimum number of arguments, or is that all implementation dependent?

like image 995
jgaa Avatar asked Feb 05 '12 10:02

jgaa


2 Answers

In VC11, you can crank up the number of max arguments used by the variadiac templates emulation scheme by setting _VARIADIC_MAX. Default is 5.

See here : http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx

If you need more arguments (e.g. you had code compiling with VC9 SP1 or VC10 that used 6-tuples), there's an escape hatch. You can define _VARIADIC_MAX project-wide between 5 and 10 inclusive (it defaults to 5). Increasing it will make the compiler consume more memory, and may require you to use the /Zm option to reserve more space for PCHes.

like image 93
Thomas Petit Avatar answered Sep 30 '22 10:09

Thomas Petit


Actually, this is an implication of VC11 not supporting variadic templates yet. They could however hard code more than four. The Boost libraries do this all the time with boilerplate for up to ten arguments (check signals2 for example down in the details directory). Four arguments is an awful small number to stop with.

like image 35
emsr Avatar answered Sep 30 '22 10:09

emsr