What to do with template typenames for optional arguments?

You could add an overload for ForEachField : template void ForEachField (Func normalHandler) { ForEachField(normalHandler, NULL, true); }.

You could add an overload for ForEachField: template void ForEachField (Func normalHandler) { ForEachField(normalHandler, NULL, true); }.

This is actually a great idea. Obviously it should be ForEachField or I will run into the same problem ;) But now I ran into another problem..!arrayHandler if arrayHandler is a lambda doesn't work, trying to find a solution now :O – Andreas Bonini Jul 7 '10 at 20:39 Ok, well the original version did compile though I didn't run it. – jon h.

Jul 7 '10 at 20:42.

Since you're using C++0x features already (lambdas), just use another one: default template arguments template void ForEachField(Func normalHandler, Func2 arrayHandler = NULL, bool skipUnknowns = true).

It doesn't seem to work: error C4519: default template arguments are only allowed on a class template – Andreas Bonini Jul 7 '10 at 20:37 Must be a difference between g++ and MSVC++. It works on g++. – Tyler McHenry Jul 7 '10 at 20:55 3 Yup, MSVC doesn't support that yet.(And since both compilers are missing support for major parts of C++0x, it's a bit optimistic to say "just use another C++0x feature":)) – jalf Jul 7 '10 at 22:47.

What about making the second parameter non-default, and creating an overloaded wrapper method that takes a single typename Func parameter.

I know that code duplication is usually regarded as "bad", however in this case I would probably NOT use a runtime check to detect whether or not I passed an argument... whenever the check can be done at compile time... template void ForEachField(Func normalHandler, Func2 arrayHandler, bool skipUnknowns = true) { for(int I = 0; I IsUnknown()) { continue; } if(f->GetCount() == 1) { normalHandler(f); } else { arrayHandler(f); } } } template void ForEachField(Func normalHandler, bool skipUnknowns = true) { for(int I = 0; I IsUnknown()) { continue; } if(f->GetCount() == 1) { normalHandler(f); } } } Remember that you can perfectly overload functions templates as usual. This will in turn solve the two problems: Second parameter is now optional (for all intents and purposes) No more application of operator! On a lambda (which does not work).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions