On Friday, 24 October 2014 at 16:12:48 UTC, ketmar via
Digitalmars-d-learn wrote:
On Fri, 24 Oct 2014 16:00:41 +
via Digitalmars-d-learn
wrote:
On Friday, 24 October 2014 at 14:06:08 UTC, ketmar via
Digitalmars-d-learn wrote:
> On Thu, 23 Oct 2014 18:28:04 +
> Max Samukha via Digita
On Friday, 24 October 2014 at 17:08:00 UTC, Max Samukha wrote:
Apparently, D doesn't allow type variables in value parameters
at all.
Nor does it allow passing delegates to value parameters, only
alias parameters.
On Friday, 24 October 2014 at 14:13:10 UTC, ketmar via
Digitalmars-d-learn wrote:
sorry if this is not what you mean, template magic sometimes
scares me
and i'm loosing my mind. ;-)
What I meant was your example with the delegate parameter moved
to the template list:
template Foo(T delega
On Fri, 24 Oct 2014 16:00:41 +
via Digitalmars-d-learn wrote:
> On Friday, 24 October 2014 at 14:06:08 UTC, ketmar via
> Digitalmars-d-learn wrote:
> > On Thu, 23 Oct 2014 18:28:04 +
> > Max Samukha via Digitalmars-d-learn
> >
> > wrote:
> >
> > um-hm... maybe this:
> >
> > void Foo(
On Friday, 24 October 2014 at 14:06:08 UTC, ketmar via
Digitalmars-d-learn wrote:
On Thu, 23 Oct 2014 18:28:04 +
Max Samukha via Digitalmars-d-learn
wrote:
um-hm... maybe this:
void Foo(T, U) (T delegate (U) a) {
// here T is bool, U is int for the following sample
import std.s
On Fri, 24 Oct 2014 17:05:57 +0300
ketmar via Digitalmars-d-learn
wrote:
> On Thu, 23 Oct 2014 18:28:04 +
> Max Samukha via Digitalmars-d-learn
> wrote:
>
> um-hm... maybe this:
>
> void Foo(T, U) (T delegate (U) a) {
> // here T is bool, U is int for the following sample
> impor
On Thu, 23 Oct 2014 18:28:04 +
Max Samukha via Digitalmars-d-learn
wrote:
um-hm... maybe this:
void Foo(T, U) (T delegate (U) a) {
// here T is bool, U is int for the following sample
import std.stdio;
writeln(a(3));
}
Foo((int x) => x%2 == 0);
signature.asc
Description:
On Friday, 24 October 2014 at 08:53:05 UTC, Kagamin wrote:
maybe
template Foo(T a, T: T[U], U)
No luck. Error: undefined identifier T
maybe
template Foo(T a, T: T[U], U)
On Thursday, 23 October 2014 at 11:25:01 UTC, Kagamin wrote:
Maybe, argument deduction?
template Foo(T: T[U], U)
{
...
}
Foo!(int[long]) // instantiates Foo with T set to int, U set
to long
Yes, but for a value template parameter.
template Foo(int[long] a);
{
}
Foo!([1: 2]); // ok, thi
Maybe, argument deduction?
template Foo(T: T[U], U)
{
...
}
Foo!(int[long]) // instantiates Foo with T set to int, U set to
long
If I remember correctly, at some point a syntax was introduced
for pattern-matching functions passed to templates. Something
like:
template Foo(B(A) foo, A, B)
{
}
alias f = Foo!((int x) => x % 2 == 0);
That would instantiate Foo with B == bool, A == int and foo bound
to the lambda.
The co
12 matches
Mail list logo