size_t ndim(A)(A arr) {
return std.algorithm.count(typeid(A).to!string, '[');
}
Is there a way to find out the number of dimensions in an array
at compile time?
On Monday, 8 February 2021 at 11:42:45 UTC, Vindex wrote:
size_t ndim(A)(A arr) {
return std.algorithm.count(typeid(A).to!string, '[');
}
Is there a way to find out the number of dimensions in an array
at compile time?
yeah.
---
template dimensionCount(T)
{
static if (isArray!T)
On Monday, 8 February 2021 at 12:19:26 UTC, Basile B. wrote:
On Monday, 8 February 2021 at 11:42:45 UTC, Vindex wrote:
[...]
yeah.
---
template dimensionCount(T)
{
static if (isArray!T)
{
static if (isMultiDimensionalArray!T)
{
alias DT = typeof(T.init[0]);
On Monday, 8 February 2021 at 12:19:26 UTC, Basile B. wrote:
On Monday, 8 February 2021 at 11:42:45 UTC, Vindex wrote:
size_t ndim(A)(A arr) {
return std.algorithm.count(typeid(A).to!string, '[');
}
Is there a way to find out the number of dimensions in an
array at compile time?
yeah.
-
On Monday, 8 February 2021 at 13:09:53 UTC, Rumbu wrote:
On Monday, 8 February 2021 at 12:19:26 UTC, Basile B. wrote:
[...]
dimensionCount!string should be 2.
My take without std.traits:
template rank(T: U[], U)
{
enum rank = 1 + rank!U;
}
template rank(T: U[n], size_t n)
{
enum rank
On Monday, 8 February 2021 at 13:13:33 UTC, Basile B. wrote:
On Monday, 8 February 2021 at 13:09:53 UTC, Rumbu wrote:
On Monday, 8 February 2021 at 12:19:26 UTC, Basile B. wrote:
[...]
dimensionCount!string should be 2.
My take without std.traits:
template rank(T: U[], U)
{
enum rank = 1
Thanks everyone!
The solution that works for me now looks like this:
template ndim(T) {
static if (std.traits.isArray!T) {
static if (is(typeof(T.init[0]))) {
alias SubArrayType = typeof(T.init[0]);
enum ndim = ndim!SubArrayType + 1;
}
else en
On Monday, 8 February 2021 at 13:27:14 UTC, Vindex wrote:
Thanks everyone!
The solution that works for me now looks like this:
template ndim(T) {
static if (std.traits.isArray!T) {
static if (is(typeof(T.init[0]))) {
alias SubArrayType = typeof(T.init[0]);
e
On Monday, 8 February 2021 at 15:56:24 UTC, Michael Brown wrote:
Hi all,
Is it possible to operator overload on enums? I'd like to do a
opCmp()
Kind regards,
Mike
No, it isn't. Only structs and classes can have overloaded
operators.
Hi all,
Is it possible to operator overload on enums? I'd like to do a
opCmp()
Kind regards,
Mike
On Monday, 8 February 2021 at 15:56:24 UTC, Michael Brown wrote:
Hi all,
Is it possible to operator overload on enums? I'd like to do a
opCmp()
Kind regards,
Mike
You can create custom struct type with opCmp() and create enum
with that type. Example: https://run.dlang.io/is/m7DN66
On Monday, 8 February 2021 at 13:09:53 UTC, Rumbu wrote:
On Monday, 8 February 2021 at 12:19:26 UTC, Basile B. wrote:
On Monday, 8 February 2021 at 11:42:45 UTC, Vindex wrote:
size_t ndim(A)(A arr) {
return std.algorithm.count(typeid(A).to!string, '[');
}
Is there a way to find out the num
On Sunday, 7 February 2021 at 14:13:18 UTC, vitamin wrote:
Why using 'new' is allowed in pure functions but calling
GC.addRange or GC.removeRange isn't allowed?
Does 'new' violate the 'pure' paradigm? Pure functions can only
call pure functions and GC.addRange or GC.removeRange is only
'nothr
On Saturday, 6 February 2021 at 20:24:00 UTC, frame wrote:
Hmmm.. with -m64 it's reporting 80 MB used, 203 MB are really
marked as private bytes. Constant. If I use GC.minimize() it
goes up and down and sometimes consumes more than 203 MB. Best
is 100MB. But it doesn't leak endlessly like the
I was trying to profile a d program. So I ran: dub build
--build=profile. I then ran the program and it produced trace.log
and trace.def. I then ran d-profile-viewer and got the following
error:
std.conv.ConvException@/home/jg/dlang/ldc-1.24.0/bin/../import/std/conv.d(2382):
Unexpected '-' wh
15 matches
Mail list logo