On Friday, November 19, 2010 11:37:16 Sean Kelly wrote: > Jonathan M Davis Wrote: > > In particular, needing to pass LineInfo() to assertExcThrown!() to know > > the file and line number was disliked (though it was by far the best > > solution that I'd been able to come up with). > > Not sure if this helps, but if you default-initialize template function > parameters with __LINE__ and __FILE__ they get the line and file of where > the template was instantiated.
Yes. The problem was that the function was a _variadic_ template. So, you couldn't have default arguments. LineInfo had default arguments in its opCall() which were the file and line number, so you passed LineInfo() as the first argument to the function, thereby not having to pass __FILE__ and __LINE__, but ideally, they would be default arguments of the original function as you suggest. It's just that the variadic part got in the way. The new version is neither variadic (since whole call is a single string rather than passing the function name and arguments separately), and it doesn't even need the __FILE__ and __LINE__ number as default arguments, since they're just used directly in the string that's mixed in. - Jonathan M Davis