passing __FILE__, __MODULE__, etc... with varadic types
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jul 19 08:32:14 PDT 2013
On Friday, July 19, 2013 11:06:26 JS wrote:
> I would like to pass to all my templates the file and module
> locations where they are used(this goes into a debugging system I
> have come up with).
>
> The problem is, with varadic types being passed I can't do this:
>
> template T!(T..., string file = __FILE__)
>
> doesn't work.
>
> I think there is no way around except to explicitly pass
> __FILE__... which would be a mess?
As long as you're using a templated function and thus can use IFTI (implicit
function template instantation) instead of giving the template arguments
explicitly, you don't have to put the template parameters with default
arguments last. You'd just have to put it after the variadic parameter if you
intended to give the template arguments explicitly. So, as long as you don't
have to give the template arguments explicitly, you're fine. If you need to
give them explicitly though, I think that you're stuck.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list