On Monday, 9 October 2023 at 02:19:20 UTC, Jonathan M Davis wrote:
On Sunday, October 8, 2023 8:08:46 AM MDT Imperatorn via
Digitalmars-d-learn wrote:
[...]
Except that in those examples, they _do_ match. It's perfectly
valid to copy elements of a string to a char[]. It's just
copying immuta
On Sunday, 8 October 2023 at 10:09:02 UTC, IchorDev wrote:
On Wednesday, 4 October 2023 at 01:46:42 UTC, Joel wrote:
I think the if without static is still static, since it's part
of the function name part, or so (outside of the curly bracket
scope).
You can't have regular if-statements insid
On Tuesday, 3 October 2023 at 14:35:31 UTC, Joel wrote:
Oh, I found,
```d
static if (isIntegral!T)
```
seems to work.
If you are using a struct, another way to affect the whole is as
follows:
```d
struct S(T)
{
invariant() {
static assert(isIntegral!T);
}
auto addUp() { /**/ }
Let's see the following example:
```d
import std.stdio;
static foreach(i; 0 .. 10) {
mixin(create_fn!(i.stringof));
}
enum create_fn(string num) = `
void function_`~ num ~`() { writeln("Hello from function `~ num
~`!"); }
`;
void main() {
function10();
}
```
I'm trying to create a ser
use:
import std.conv;
... i.to!string ...
```
import std.stdio;
import std.conv;
static foreach(i; 0 .. 10) {
mixin(create_fn!(i.to!string));
}
enum create_fn(string num) = `
void function_`~ num ~`() { writeln("Hello from function `~ num
~`!"); }
`;
void main() {
function_9();
}
On Monday, 9 October 2023 at 16:42:38 UTC, mw wrote:
use:
import std.conv;
[...]
Damn, sorry, forgot to mention. I cannot use Phobos.
On Monday, 9 October 2023 at 16:51:31 UTC, rempas wrote:
On Monday, 9 October 2023 at 16:42:38 UTC, mw wrote:
use:
import std.conv;
[...]
Damn, sorry, forgot to mention. I cannot use Phobos.
but you `import std.stdio;`?
Or copy the std/conv.d over to your build,
or copy / write a toStrin
On Monday, 9 October 2023 at 16:53:55 UTC, mw wrote:
but you `import std.stdio;`?
Or copy the std/conv.d over to your build,
or copy / write a toString(int) function yourself, which is
compile-time callable.
I do on that example just to use "write". It wouldn't be
necessary, but I just inc
On Monday, 9 October 2023 at 16:55:41 UTC, rempas wrote:
On Monday, 9 October 2023 at 16:53:55 UTC, mw wrote:
but you `import std.stdio;`?
Or copy the std/conv.d over to your build,
or copy / write a toString(int) function yourself, which is
compile-time callable.
I do on that example just
On Monday, October 9, 2023 10:55:41 AM MDT rempas via Digitalmars-d-learn
wrote:
> On Monday, 9 October 2023 at 16:53:55 UTC, mw wrote:
> > but you `import std.stdio;`?
> >
> > Or copy the std/conv.d over to your build,
> >
> > or copy / write a toString(int) function yourself, which is
> > compil
On Monday, 9 October 2023 at 17:42:48 UTC, Imperatorn wrote:
You could just add your own int to string I guess?
That will be a good idea! I'll do it in the future if that is the
case, as it's not important, and I want to finish my job. Thank
you and have a great day!
On Monday, 9 October 2023 at 17:52:58 UTC, Jonathan M Davis wrote:
The closest to a built-in solution would be toString on classes
and structs, but structs don't necessarily have a toString.
Rather, in many cases, Phobos does introspection on the struct
to figure out how to convert the struct
On Monday, 9 October 2023 at 16:33:32 UTC, rempas wrote:
I'm trying to create a series of function. There will be ten of
them, and they will be called `function_0`, `function_1`, etc.
However, in my example, "stringof" returns the character "i"
itself and turns that into a string instead of get
On Monday, 9 October 2023 at 22:49:11 UTC, Salih Dincer wrote:
On Monday, 9 October 2023 at 16:33:32 UTC, rempas wrote:
I'm trying to create a series of function. There will be ten
of them, and they will be called `function_0`, `function_1`,
etc. However, in my example, "stringof" returns the c
14 matches
Mail list logo