A library similar to boost::bind

Tom S h3r3tic at remove.mat.uni.torun.pl
Fri Jul 7 11:09:56 PDT 2006


Kirk McDonald wrote:
> I've started to write something similar for Pyd, but yours seems more 
> full-featured. One useful function of mine is a tuple_from_fn template, 
> which derives a tuple type directly from a function type, e.g.:
> 
> void func(int i, char[] s) { }
> 
> void main() {
>     tuple_from_fn!(typeof(&func)) f;
>     static assert(is(typeof(f) == tuple!(int, char[])));
> }
> 
> The closest thing my tuples have to "bind" is a simple 
> "apply_tuple_to_fn" function that calls the function with the tuple.

Ah, I've got it in the Bind module, called 'getFuncArgsTypes'. A simple 
apply function template is also in the meta package, in its own Apply.d 
file :)


> The one question I have is: How well does it handle default function 
> arguments? So far I've managed to support them pretty well in Pyd, and I 
> don't want to break that.

I'm afraid that currently it doesn't handle them at all, since it 
operates on func types, not aliases. Thanks for pointing it out though, 
I'll have to think about adding support for them :)


-- 
Tomasz Stachowiak  /+ a.k.a. h3r3tic +/



More information about the Digitalmars-d-announce mailing list