On Saturday, 31 December 2022 at 02:15:56 UTC, Ali Çehreli wrote:
On 12/30/22 17:22, Salih Dincer wrote:
> I guess there is no other way but to overload.
Since the bodies of all three overloads are the same except
some types, they can easily be templatized.
You took the trouble, thanks, but
On 12/30/22 17:22, Salih Dincer wrote:
> I guess there is no other way but to overload.
Since the bodies of all three overloads are the same except some types,
they can easily be templatized.
> This is both the safest and the fastest.
I didn't think Values is fast with string copies that it
On Saturday, 31 December 2022 at 00:42:50 UTC, Salih Dincer wrote:
... it possible to infer
Let me save you the torment of code duplication 😀
Thanks everyone. Yes, I guess there is no other way but to
overload. This is both the safest and the fastest. It's also
short enough like this:
`
On Friday, 30 December 2022 at 22:02:41 UTC, Ali Çehreli wrote:
> But I couldn't find if the target will be mutable, but I
think it will
> be,
The target will always be the type the programmer specifies
explicitly. (dchar[] in this case.)
I have one more little question! Is it possible to inf
On Friday, 30 December 2022 at 22:02:41 UTC, Ali Çehreli wrote:
On 12/30/22 13:54, matheus wrote:
> But yes I think it will generate a copy (mutable) based on
this test:
In this case it does copy but in the case of dchar[] to
dchar[], there will be no copy. Similarly, there is no copy
from im
On 12/30/22 13:54, matheus wrote:
> But yes I think it will generate a copy (mutable) based on this test:
In this case it does copy but in the case of dchar[] to dchar[], there
will be no copy. Similarly, there is no copy from immutable to immutable.
> the address is different
Good test. :)
On Friday, 30 December 2022 at 15:28:05 UTC, Salih Dincer wrote:
... In this case, std.conv.to can be used for mutable dchars,
right? For example, is this solution the right approach?
```d
auto toDchar(S)(inout S str) {
import std.conv : to;
return str.to!(dchar[]);
}
void main() {
auto
On Friday, 30 December 2022 at 11:05:07 UTC, matheus wrote:
Are you sure about that?
Thank you for your answer. You contributed to the project I was
working on. In this case, std.conv.to can be used for mutable
dchars, right? For example, is this solution the right approach?
```d
auto toDch
On Friday, 30 December 2022 at 10:03:20 UTC, Salih Dincer wrote:
On Friday, 30 December 2022 at 09:29:16 UTC, novice2 wrote:
On Friday, 30 December 2022 at 04:43:48 UTC, Salih Dincer
wrote:
...
// example one:
char[] str1 = "cur:€_".dup;
...
// example two:
dchar[] str2 = cast(dchar
On Friday, 30 December 2022 at 09:29:16 UTC, novice2 wrote:
On Friday, 30 December 2022 at 04:43:48 UTC, Salih Dincer wrote:
...
// example one:
char[] str1 = "cur:€_".dup;
...
// example two:
dchar[] str2 = cast(dchar[])"cur:€_"d;
...
SDB@79
why you use .dup it example one, but
On Friday, 30 December 2022 at 04:43:48 UTC, Salih Dincer wrote:
...
// example one:
char[] str1 = "cur:€_".dup;
...
// example two:
dchar[] str2 = cast(dchar[])"cur:€_"d;
...
SDB@79
why you use .dup it example one, but not use in example two?
dchar[] str2 = cast(dchar[])"cur:€_"
On 30/12/2022 6:37 PM, Salih Dincer wrote:
On Friday, 30 December 2022 at 04:54:39 UTC, Richard (Rikki) Andrew
Cattermole wrote:
So when you duplicated it, it was no longer in ROM, and therefore
writable.
There is no such thing as a ROM within a function.
But a function can reference thing
On Friday, 30 December 2022 at 04:54:39 UTC, Richard (Rikki)
Andrew Cattermole wrote:
So when you duplicated it, it was no longer in ROM, and
therefore writable.
There is no such thing as a ROM within a function. Because str
is a reference and slc is a local copy, right? Have you tried
ru
Because, string literals are in Read Only Memory (or should be anyway).
If you write to ROM, it'll of course error by the CPU.
So when you duplicated it, it was no longer in ROM, and therefore writable.
Hi All,
What is causing the error in the code snippet below?
```d
void replaceRight(S)(ref S[] str, S[] slc)
{
size_t len1 = slc.length,
len2 = str[len1..$].length;
assert(len1 == len2);
str[len1..$] = slc;
}
import std.stdio;
void main()
{
// example one:
char[] str1 = "cur
15 matches
Mail list logo