If I have a type tuple TL, which happens to be:
alias TypeTuple!(const(int), immutable(double), string) TL;
How can I convert it into a tuple of (int, double, string)?
Effectively I need a way to get a new UnqualTL where each type in
the list is itself unqualified. I need to do this without k
On 21.11.2012 21:56, Masahiro Nakagawa wrote:
On Tuesday, 20 November 2012 at 11:38:46 UTC, Tobias Pankrath wrote:
Is there any template library like Jinja? (jinja.pocoo.org).
I'm pretty sure we can do even better by leveraging CTFE and a
precompiler, but speed is no concern for me.
I'm not f
On Tuesday, 20 November 2012 at 11:38:46 UTC, Tobias Pankrath
wrote:
Is there any template library like Jinja? (jinja.pocoo.org).
I'm pretty sure we can do even better by leveraging CTFE and a
precompiler, but speed is no concern for me.
I'm not familiar with Jinja.
So I may not meet your exp
On 11/20/2012 11:56 PM, Jonathan M Davis wrote:
...
clearly, as if with static arrays, you'd have to be careful with slices being
passed around, since they're not owned by the GC. And I'm not sure what would
happen if you were foolish enough to try and append to them.
...
It works as expected.
Ugly C++ like template and mixin magic solution:
struct r(T){ alias T type;}
template str(alias A) if(is(A == r!(A.type))) { const char[] str
= "ref " ~ A.type.stringof; }
template str(T) { const char[] str = T.stringof; }
template str(T, A...) { const char[] str = str!T ~ ", " ~ str!A; }
stru
On Wednesday, 21 November 2012 at 10:15:52 UTC, Timon Gehr wrote:
This also duplicates the data if you move the struct in memory
and then mutate. Probably you just need to have a boolean owner
flag and set it to false on postblit.
Hadn't thought of a move being involved.. I was trying to use
On Wednesday, 21 November 2012 at 04:23:56 UTC, Era Scarecrow
wrote:
Here's a quick thrown together example of what I'm talking
about.
I think I see where you are going. After the copy creation of
new_ca you have two objects referencing exactly the same data. It
doesn't show it, but the bene
On 11/21/12, Jack Applegame wrote:
> This problem appears also in std.signals.
> There is no possibility to use functions with ref parameters as
> signal handler.
>
> import std.signals;
>
> class Foo {
>mixin Signal!(int);
> }
> class Bar {
>void handler(ref int a) {}
> }
>
> void main()
alias void function(ref int) funcType;
void foo(ref int a) { a--; }
struct functor(A...) {
A[0] func;
}
void main()
{
functor!funcType f;
f.func = &foo;
}
I think the best way is using @property.
alias void function(ref int) funcType;
void foo(ref int a) { a--; }
struct functor(A...) {
This problem appears also in std.signals.
There is no possibility to use functions with ref parameters as
signal handler.
import std.signals;
class Foo {
mixin Signal!(int);
}
class Bar {
void handler(ref int a) {}
}
void main() {
Foo foo = new Foo;
Bar bar = new Bar;
foo.connect(&b
On Wed, 21 Nov 2012 12:32:24 -, Regan Heath
wrote:
On Wed, 21 Nov 2012 12:30:08 -, Regan Heath
wrote:
On Wed, 21 Nov 2012 12:02:45 -, Jack Applegame
wrote:
void foo(ref int a) { a--; }
struct functor(A...) {
void function(A) functor;
}
functor!int f;// functor!(ref
storage classes on function parameters affect the type of the
function, but
they do not affect the type of the parameter. If a function has
a parameter
named foo, then typeof(foo) is going to be the same whether ref
is on it or
not.
- Jonathan M Davis
Ok. But how to pass storage class to tem
On Wed, 21 Nov 2012 12:30:08 -, Regan Heath
wrote:
On Wed, 21 Nov 2012 12:02:45 -, Jack Applegame
wrote:
void foo(ref int a) { a--; }
struct functor(A...) {
void function(A) functor;
}
functor!int f;// functor!(ref int) - wrong
f.functor = &foo; // Error: cannot implicitly
On Wed, 21 Nov 2012 12:02:45 -, Jack Applegame
wrote:
void foo(ref int a) { a--; }
struct functor(A...) {
void function(A) functor;
}
functor!int f;// functor!(ref int) - wrong
f.functor = &foo; // Error: cannot implicitly convert expression (& foo)
of type void function(ref int a
On Wednesday, November 21, 2012 13:09:05 Jack Applegame wrote:
> On Wednesday, 21 November 2012 at 12:05:23 UTC, bearophile wrote:
> > In one case the function expects a pointer and in one case it
> > expects a int value. The assembly code of the two functions is
> > different and does different th
On Wednesday, 21 November 2012 at 12:05:23 UTC, bearophile wrote:
In one case the function expects a pointer and in one case it
expects a int value. The assembly code of the two functions is
different and does different things.
Of course. And it is mean that ref indeed is a part of type.
Jack Applegame:
A brony? :-)
But sometimes ref becomes a part of type. For example "void
delegate(ref int)" and "void delegate(int)" are different
types. Is it possible to cast from one to another safely? For
example:
void foo(ref int);
void function(int) fp;
fp = cast(typeof(fp)) foo; ///
On Wednesday, November 21, 2012 12:57:57 Jack Applegame wrote:
> But sometimes ref becomes a part of type. For example "void
> delegate(ref int)" and "void delegate(int)" are different types.
> Is it possible to cast from one to another safely? For example:
That's because ref is being used on a fu
How to implement functor-like objects if ref is storage class?
void foo(ref int a) { a--; }
struct functor(A...) {
void function(A) functor;
}
functor!int f;// functor!(ref int) - wrong
f.functor = &foo; // Error: cannot implicitly convert expression
(& foo) of type void function(ref int a
But sometimes ref becomes a part of type. For example "void
delegate(ref int)" and "void delegate(int)" are different types.
Is it possible to cast from one to another safely? For example:
void foo(ref int);
void function(int) fp;
fp = cast(typeof(fp)) foo; /// is it safe???
On Wednesday, November 21, 2012 11:55:53 Jack Applegame wrote:
> Why this could not compile?
>
> struct Foo(T) {}
> Foo!(ref int) foo;
>
> Output:
>
> Error: expression expected, not 'ref'
> Error: found 'int' when expecting ')' following template argument
> list
> Error: no identifier for decla
Why this could not compile?
struct Foo(T) {}
Foo!(ref int) foo;
Output:
Error: expression expected, not 'ref'
Error: found 'int' when expecting ')' following template argument
list
Error: no identifier for declarator Foo!(0)
Error: semicolon expected, not ')'
Error: found ')' instead of state
On 11/21/2012 05:23 AM, Era Scarecrow wrote:
I was thinking briefly and glancing over documentation regarding cluts
and non-cluts (Reference vs value types), and considering my BitArray
implementation. I was having a problem trying to solve how to avoid
duplicating it unless it actually was nee
23 matches
Mail list logo