I was expecting something like going out of scope for that
```(D)
import std.stdio;
struct S
{
~this()
{
writeln("S is being destructed");
}
}
void main()
{
S[int] aa;
aa[1] = S();
aa.remove(1);
writeln("Why no dtor call on remove?");
}
I was expecting
On Thursday, 12 August 2021 at 16:12:39 UTC, Paul Backus wrote:
On Thursday, 12 August 2021 at 15:39:40 UTC, Learner wrote:
[...]
You have forgotten to add a member variable of type `A` to your
`B` struct. If you add one, you will see the following error
message:
[...]
"implicit
On Thursday, 12 August 2021 at 15:50:05 UTC, Tejas wrote:
On Thursday, 12 August 2021 at 15:39:40 UTC, Learner wrote:
On Thursday, 12 August 2021 at 14:57:16 UTC, Steven
Schveighoffer wrote:
[...]
It is not clear to me why the inout generated copy constructor
of the B structure is not able
On Thursday, 12 August 2021 at 14:57:16 UTC, Steven Schveighoffer
wrote:
On 8/12/21 10:08 AM, Learner wrote:
On Thursday, 12 August 2021 at 13:56:17 UTC, Paul Backus wrote:
On Thursday, 12 August 2021 at 12:10:49 UTC, Learner wrote:
That worked fine, but the codebase is @safe:
```d
cast
On Thursday, 12 August 2021 at 13:56:17 UTC, Paul Backus wrote:
On Thursday, 12 August 2021 at 12:10:49 UTC, Learner wrote:
That worked fine, but the codebase is @safe:
```d
cast from `int[]` to `inout(int[])` not allowed in safe code
```
So copy constructors force me to introduce trusted
On Thursday, 12 August 2021 at 11:32:03 UTC, Paul Backus wrote:
On Thursday, 12 August 2021 at 11:19:34 UTC, drug wrote:
```D
struct A {
int[] data;
this(ref return scope inout A rhs) /* no inout here */ {
data = rhs.data.dup; }
}
```
The problem is that if you qualify the ctor itself
On Thursday, 12 August 2021 at 11:07:24 UTC, drug wrote:
12.08.2021 12:36, Learner пишет:
> It seems that there is no easy way to transition from a
postblit to a
copy constructor, no?
You just need both const and mutable copy ctors to replace
inout one:
```D
struct A {
int[] data;
On Thursday, 12 August 2021 at 10:10:17 UTC, rikki cattermole
wrote:
On 12/08/2021 9:36 PM, Learner wrote:
It seems that there is no easy way to transition from a
postblit to a copy constructor, no?
struct Foo {
this(ref Foo other) {
foreach(i, v; other.tupleof)
On Thursday, 12 August 2021 at 09:14:02 UTC, Paul Backus wrote:
On Thursday, 12 August 2021 at 08:42:27 UTC, Learner wrote:
struct A {
int[] data
this(ref return scope A rhs) { data = ths.data.dup; }
}
Generating an `inout` copy constructor for `struct B`
failed,
I have a structure like, used by other structures:
struct A {
int[] data;
this(this) { data = data.dup; }
}
I am trying to upgrade it to use copy constructor:
struct A {
int[] data
this(ref return scope A rhs) { data = ths.data.dup; }
}
On Thursday, 7 May 2020 at 14:53:10 UTC, Steven Schveighoffer
wrote:
On 5/7/20 5:22 AM, learner wrote:
[...]
Because VariantN (the base of Algebraic) can literally hold
anything, it cannot be pure, @safe, nothrow, @nogc.
As others have recommended, I suggest using TaggedAlgebraic. I
On Thursday, 7 May 2020 at 10:41:01 UTC, Simen Kjærås wrote:
On Thursday, 7 May 2020 at 09:22:28 UTC, learner wrote:
Good morning,
Is there a reason why std.variant.visit is not inferring pure?
```
void test() pure {
Algebraic!(int, string) alg;
visit!( (string) => 0, (int) =>
Good morning,
Is there a reason why std.variant.visit is not inferring pure?
```
void test() pure {
Algebraic!(int, string) alg;
visit!( (string) => 0, (int) => 0)(alg);
}
Error: pure function test cannot call impure function
test.visit!(VariantN!(16LU, int, string)).visit
```
Thank
On Wednesday, 6 May 2020 at 08:04:16 UTC, Jacob Carlborg wrote:
On 2020-05-05 19:11, learner wrote:
On Tuesday, 5 May 2020 at 16:41:06 UTC, Adam D. Ruppe wrote:
typeof(return)
Thank you, that was indeed easy!
Is it possible to retrieve also the caller return type?
Something like:
Yes,
On Tuesday, 5 May 2020 at 19:24:41 UTC, WebFreak001 wrote:
On Tuesday, 5 May 2020 at 18:41:50 UTC, learner wrote:
Good morning,
Trying to do this:
```
bool foo(string s) nothrow { return s.all!isDigit; }
```
I realised that the conversion from char to dchar could throw.
I need to validate
Good morning,
Trying to do this:
```
bool foo(string s) nothrow { return s.all!isDigit; }
```
I realised that the conversion from char to dchar could throw.
I need to validate and operate over ascii strings and utf8
strings, possibly in separate functions, what's the best way to
transition
On Tuesday, 5 May 2020 at 16:41:06 UTC, Adam D. Ruppe wrote:
typeof(return)
Thank you, that was indeed easy!
Is it possible to retrieve also the caller return type? Something
like:
```
int foo() {
return magic();
}
auto magic(maybesomedefaulttemplateargs = ??)() {
alias R =
Good morning,
Is it possible something like this?
```
int foo() {
__traits(some_trait, some_generic_this) theInt = 0;
```
I mean, without using the function name in the body, like
ReturnType!foo ?
abstract class AbstractObject(S)
if (IsSomeString!S)
{
}
class OtherObject(S, bool R) : AbstractObject!S
{
int x;
void Foo(int a, int b)
{
x = a + b;
static if (R) // error
{
// more codes .
}
}
}
class OtherObjects(S) :
On Wednesday, 15 June 2016 at 21:54:22 UTC, Seb wrote:
On Wednesday, 15 June 2016 at 21:51:25 UTC, learner wrote:
Hi,
How can i get the number of cols and rows in and ndarray that
has already been created?
learner
how about `shape`?
Hi,
How can i get the number of cols and rows in and ndarray that has
already been created?
learner
On Friday, 1 April 2016 at 01:09:32 UTC, Ali Çehreli wrote:
On 03/31/2016 05:34 PM, learner wrote:
Hi,
I have the following code in C++.
rectangles.erase(rectangles.begin() + index);
where rectangles is:
std::vector rectangles;
how can I do something similar in D.
Learner.
import
Hi,
I have the following code in C++.
rectangles.erase(rectangles.begin() + index);
where rectangles is:
std::vector rectangles;
how can I do something similar in D.
Learner.
23 matches
Mail list logo