How do I turn the GC-allocation in toLower() to a scoped heap
allocation together with toLowerInPlace() in
void f(const scope const(char)[] expr)
{
import std.uni : toLower;
loweredExpr = toLower(expr); // temporary
// use loweredExpr as key in hash table
}
when `loweredExpr` is
On Wednesday, 12 December 2018 at 21:11:38 UTC, Paul Backus wrote:
On Wednesday, 12 December 2018 at 20:05:18 UTC, aliak wrote:
Ie:
struct S {
@disable this();
this(int i) {}
}
struct Container(T) {
T value;
this(auto ref T value) {
this.value = value;
}
}
void
Ie:
struct S {
@disable this(this);
this(int i) {}
}
struct Container(T) {
T value;
this(T value) {
this.value = value;
}
}
void main() {
auto a = Container!S(S(3)); // can't do this.
}
I can build a custom constructor for Container that makes this
work:
On Thursday, 13 December 2018 at 09:51:42 UTC, aliak wrote:
Ie:
struct S {
@disable this(this);
this(int i) {}
}
struct Container(T) {
T value;
this(T value) {
this.value = value;
}
}
void main() {
auto a = Container!S(S(3)); // can't do this.
}
I can build a
On 12/13/18 8:17 AM, aliak wrote:
On Thursday, 13 December 2018 at 12:08:22 UTC, Boris-Barboris wrote:
On Thursday, 13 December 2018 at 09:51:42 UTC, aliak wrote:
[...]
You can just move in container constructor:
struct S {
@disable this(this);
this(int i) {}
}
struct
On Thursday, 13 December 2018 at 13:46:47 UTC, Steven
Schveighoffer wrote:
If you use loweredExpr as a key in a builtin AA, then you need
to make it a heap allocation, because the GC cleans up AAs.
-Steve
I only need it for lookup not for storage.
On Thursday, 13 December 2018 at 12:08:22 UTC, Boris-Barboris
wrote:
On Thursday, 13 December 2018 at 09:51:42 UTC, aliak wrote:
[...]
You can just move in container constructor:
struct S {
@disable this(this);
this(int i) {}
}
struct Container(T) {
T value;
this(T value)
On 12/13/18 4:38 AM, Per Nordlöw wrote:
How do I turn the GC-allocation in toLower() to a scoped heap allocation
together with toLowerInPlace() in
void f(const scope const(char)[] expr)
{
import std.uni : toLower;
loweredExpr = toLower(expr); // temporary
// use loweredExpr as
On 12/13/18 9:06 AM, Per Nordlöw wrote:
On Thursday, 13 December 2018 at 13:46:47 UTC, Steven Schveighoffer wrote:
If you use loweredExpr as a key in a builtin AA, then you need to make
it a heap allocation, because the GC cleans up AAs.
I only need it for lookup not for storage.
I guess
I do not understand you?
What is wrong? It works ok.
https://run.dlang.io/is/ZFf0FQ
What do you mean by D required breaks for cases?
On Fri, Dec 14, 2018 at 1:20 AM Michelle Long via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:
> byte x = 0xF;
> ulong y = x >> 60;
>
> Does
On 12/13/18 4:32 PM, Giovanni Di Maria wrote:
Hi.
How can I know the amount of RAM allocated by a vector?
For example:
string[8][1000] array;
for(int i=0;i<1000;i++) {
array[i]=["","","","","","","",""];
}
how can I know the amount of bytes of above matrix?
Hi.
How can I know the amount of RAM allocated by a vector?
For example:
string[8][1000] array;
for(int i=0;i<1000;i++) {
array[i]=["","","","","","","",""];
}
how can I know the amount of bytes of above matrix?
Can I clean the memory ofter his use, without
byte x = 0xF;
ulong y = x >> 60;
Does not compute the proper value.
It seems that the shift amount is wrapped. My code is more
complex. The code above does give an error. I am using the code
in a template. If I change x to ulong it works as expected.
I've noticed the compiler is not
On Friday, 14 December 2018 at 02:17:20 UTC, Jonathan M Davis
wrote:
On Thursday, December 13, 2018 6:56:33 PM MST Steven
Schveighoffer via Digitalmars-d-learn wrote:
On 12/13/18 7:16 PM, Michelle Long wrote:
> I've noticed the compiler is not throwing up errors and
> warnings like it used to:
On Thursday, December 13, 2018 6:56:33 PM MST Steven Schveighoffer via
Digitalmars-d-learn wrote:
> On 12/13/18 7:16 PM, Michelle Long wrote:
> > I've noticed the compiler is not throwing up errors and warnings like it
> > used to:
> >
> > I thought D required breaks for cases? Seems it doesn't
On Fri, 14 Dec 2018 00:16:51 +, Michelle Long wrote:
> byte x = 0xF;
> ulong y = x >> 60;
"Error: shift by 60 is outside the range 0..31"
This is the result of integer promotion rules. Change the 30 to a 60 and
it works, and the result is, as you would expect, 0.
> I thought D required
On 12/13/18 7:16 PM, Michelle Long wrote:
byte x = 0xF;
ulong y = x >> 60;
Surely you meant x << 60? As x >> 60 is going to be 0, even with a ulong.
Does not compute the proper value.
It seems that the shift amount is wrapped. My code is more complex. The
code above does give an error. I
On Thursday, 13 December 2018 at 13:17:05 UTC, aliak wrote:
Ah. Is there any case where you would not want to do that when
you have a T value as parameter?
Hypothetically, yes, e.g. an object that contains references to
itself. However, D operates on the assumption that you don't have
such
On Thursday, 13 December 2018 at 13:17:05 UTC, aliak wrote:
Ah. Is there any case where you would not want to do that when
you have a T value as parameter?
And, what if it's "this()(auto ref T value)"? Then moving could
be dangerous if the parameter was passed as a ref. Or maybe it
just
19 matches
Mail list logo