On Friday, 2 February 2024 at 23:25:37 UTC, Chris Katko wrote:
The auto solution won't work for a struct however which I'm
using:
```D
struct procTable{ //contains all the fields inside a file I'm
parsing
uint time;
int priority;
string name;
// etc
}
```
Maybe you can use
On Friday, 2 February 2024 at 21:01:53 UTC, Paul Backus wrote:
No, D only does bottom-up type inference, not top down.
If you want to avoid repeating the type, use `auto` on the left
side:
```d
auto time = to!uint(data[1]);
auto priority = to!int(data[2]);
```
Okay thanks. It finally
On Friday, 2 February 2024 at 07:43:09 UTC, Chris Katko wrote:
Is there some way to do:
```D
string[3] data; //strings from some file input, some are ints,
uints, etc.
auto into!(T)(T value){return to!???(value); } // ???
uint time = into!(data[1]); // We already know this is uint
int
On Friday, 2 February 2024 at 20:28:50 UTC, Carl Sturtivant wrote:
On Friday, 2 February 2024 at 19:22:22 UTC, Steven
Schveighoffer wrote:
```d
// shim
auto foo(Args...)(Args args) if (!allSatisfy!(isVariant, Args))
{
mixin("return foo(", argsAsVariants(args.length), ");");
}
```
Thanks
On Friday, 2 February 2024 at 19:22:22 UTC, Steven Schveighoffer
wrote:
```d
void foo(Variant x, Variant y) { ... }
import std.meta : allSatisfy;
enum isVariant(T) = is(T == Variant);
// this is going to suck at CTFE but...
string argsAsVariants(size_t count)
{
import std.format;
import
On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote:
It seems I cannot pass e.g. an int argument to a Variant
function parameter. What's the simplest way to work around this
restriction?
You'd have to implement the function that accepts the parameters
and wraps in a Variant.
I can't seem to be able to use `--profile` with vibe:
```shell
dub init -t vibe.d
dub build --build=profile
../../.dub/packages/vibe-core/2.7.3/vibe-core/source/vibe/internal/async.d-mixin-119(142,3):
Warning: statement is not reachable
On Saturday, 30 December 2023 at 19:27:08 UTC, Matheus Catarino
wrote:
Hi everyone.
Currently I'm working on D binding for sokol project (truly a
dual bindgen [sokol-tools, sokol-header]) which could be merged
into the upstream project.
Up to now, my "ideal" configuration has been to
On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote:
It seems I cannot pass e.g. an int argument to a Variant
function parameter. What's the simplest way to work around this
restriction?
The easiest thing would be to actually pass it a `Variant` with
On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote:
It seems I cannot pass e.g. an int argument to a Variant
function parameter. What's the simplest way to work around this
restriction?
Just tell the compiler clearly what you want.
```d
import std;
void f(Variant x) {
It seems I cannot pass e.g. an int argument to a Variant function
parameter. What's the simplest way to work around this
restriction?
11 matches
Mail list logo