The following snippet doesn't compile
I am trying to reflect on a class and only do an operation with
all member functions of a class.
But I can't seem to use a filter to only get the member functions
out of a type T.
I understand that there are two errors in my snippet.
1) It cannot mixin a
On Sunday, 11 August 2019 at 16:32:20 UTC, Simen Kjærås wrote:
[...] Something like this:
import std.meta : Filter;
import std.traits : isFunction;
import std.algorithm.searching : canFind;
enum isNonspecialMemberFunction(string name) =
!ctorAndDtor.canFind(name) &&
I've got a snippet of code which I have narrowed down to the
following:
'import std.stdio;
enum string[] mixins = ["public bool qux(int i, char c)
{
throw new Exception(\"not implemented\");
// Add all arguments to a struct and serialize
that struct.
On Friday, 27 December 2019 at 18:34:49 UTC, Adam D. Ruppe wrote:
On Friday, 27 December 2019 at 18:22:10 UTC, Sjoerd Nijboer
wrote:
When calling the mixin directly instead of through the
template mixin it breaks with thesame error message.
What exactly did you do here?
I meant to say that t
On Friday, 27 December 2019 at 18:51:31 UTC, Adam D. Ruppe wrote:
On Friday, 27 December 2019 at 18:49:32 UTC, Sjoerd Nijboer
wrote:
Should concatenating the list and mixing that in work too?
yeah that'd work too. As long as all the overloads are coming
from the same source, D allows it.
bu
Given the following code
`struct Foo(T)
if(isNumeric!T)
{
T t;
.. other code
}
struct Bar(T)
if(isNumeric!T)
{
T t;
.. other code
}
Foo!float foo_float;
Foo!double foo_double;
Bar!float bar_float;
`
I want to make a template mixin that is able t
On Thursday, 17 May 2018 at 16:27:48 UTC, Paul Backus wrote:
On Thursday, 17 May 2018 at 15:25:37 UTC, Sjoerd Nijboer wrote:
I want to make a template mixin that is able to cast one of
these generic structs to the other explicitly. I have a bunch
of these structs and therefore I thought it woul
On Thursday, 17 May 2018 at 20:38:13 UTC, Sjoerd Nijboer wrote:
But then how do you put this into a mixin template so I can ...
mixin castingRules(typeof(this) T);
I guess I can refine my question to "How do you let a mixin
template detect the template name it is instantiated with and
On Tuesday, 22 May 2018 at 22:17:05 UTC, IntegratedDimensions
wrote:
On Tuesday, 22 May 2018 at 22:10:52 UTC, Alex wrote:
On Tuesday, 22 May 2018 at 21:45:07 UTC, IntegratedDimensions
wrote:
an idea to lock data by removing the reference:
class A
{
Lockable!Data data;
}
The idea is that wh
I'm kinda puzzled.
I'm having trouble getting started with inline asm in D.
Suppowse I have the following:
void Foo(MyStrunct* first_arg, MyStrunct* second_arg)
{
asm
{
naked;
version(X86)
{
/* Do something with the content of I and J. */
}
On Sunday, 30 September 2018 at 12:07:53 UTC, Basile B. wrote:
On Sunday, 30 September 2018 at 11:53:17 UTC, Basile B. wrote:
Hello, i think this should be here
(https://dlang.org/spec/abi.html) because myself i never
remember them correctly without playing a bit with a
disassembler.
After
On Sunday, 30 September 2018 at 12:32:08 UTC, kinke wrote:
1) `asm {}` is supported by DMD and LDC, but not by GDC.
Good to know.
Guess I will be targeting DMD and LDC then.
4) For x86_64, there are 2 (completely different) ABIs, Win64
and the System V one. Specs can be found online.
In you
I've got a `struct Foo{ubyte16 field1, field2 fieldn;}` for
which I would like a heap allocation `Foo* foo = new Foo();` But
the fields itsself must be 16 bytes aligned for SIMD instructions.
Is there a neat way to do this in D?
As far as I can tell the GC_allocator doesn't do aligned
alloc
On Friday, 5 October 2018 at 10:03:35 UTC, Kagamin wrote:
GC allocations are 16 bytes aligned.
That's perfect. Thank you!
On Friday, 5 October 2018 at 14:55:04 UTC, Dennis wrote:
On Friday, 5 October 2018 at 10:03:35 UTC, Kagamin wrote:
GC allocations are 16 bytes aligned.
Is that an implementation detail or well-defined behavior?
The GC_Allocator doesn't support alignedAllocate from the
IAllocate interface, w
On Saturday, 13 October 2018 at 18:40:58 UTC, Per Nordlöw wrote:
If a D-program GC-allocates via `new` an array spanning
multiple pages but after processing only keeps a slice to it
that fits inside a single `mmape`d page will GC-collection then
free the other unreferenced pages?
I realize th
I'm trying to invert the dependency from the classes `Bar -> Foo`
to `Foo -> IFoo <- Bar` at compile time.
I do want `Foo's` to be embedded into `Bar`
So silly me tried something like this:
module main;
```import std.stdio;
import std.typecons;
void main()
{
auto bar = new Bar!(scoped
On Thursday, 8 November 2018 at 12:45:57 UTC, Alex wrote:
Hmm... not sure, if I got your idea... Do you think about
something like this?
**snip**
class Bar(TFoo) if(is(TFoo : IFoo))
{
typeof(scoped!TFoo()) _foo;
this()
{
_foo = scoped!TFoo();
On Thursday, 8 November 2018 at 16:31:26 UTC, Neia Neutuladh
wrote:
I believe what you need to do is pass a factory function into
the constructor. This is a bit awkward.
Yep, but I want a "nice and descriptive syntax" for it.
Anyway, here's some code to make it work. It's kind of ugly.
---
i
On Thursday, 8 November 2018 at 21:16:32 UTC, Sjoerd Nijboer
wrote:
I tried tom make a lazyscoped!T but I'm stuck at creating a
constructor and determining the arguments from the Type.
Unfortunately I can't find a way in D to get a list of arguments
at compile time for a given function. Is thi
On Friday, 9 November 2018 at 09:17:27 UTC, Alex wrote:
Is it this what you are looking for?
https://dlang.org/phobos/std_traits.html#Parameters
I've been looking over std.traits all day yesterday, how could
I've missed that?
I'm so glad there are people in this forum that want to help out
othe
I would like to do something like
`
dmd --buildversion=fooCollection{"a", "b", "c"} -run app.d
...
void bar()
{
static foreach(i; fooCollection)
{
...
}
}
`
The idea being that bar can be packed in a library and the
program that includes this library can decide what paramet
On Sunday, 2 December 2018 at 17:59:56 UTC, Paul Backus wrote:
The normal way to do this would be to make bar a template and
have the program that uses it pass these parameters to it as
template arguments.
Why didn't I think of that?
It's just initializing a library, of course!
Thank you for y
A small question.
Is it intended behaviour that public imports inside function
calls fail with the message "Error: found public instead of
statement", or is it an underdocumented feature?
void foo()
{
public import bar;
}
On Wednesday, 5 December 2018 at 21:21:12 UTC, Adam D. Ruppe
wrote:
Looks intended. It doesn't really make sense to have a public
import inside a function.
I was trying to find a weird corner of the language and maybe do
something funny with conditional imports.
They don't work in functions, h
On Wednesday, 5 December 2018 at 23:18:49 UTC, H. S. Teoh wrote:
Maybe if you described to us exactly what you want to do, we
could find a way to do it that doesn't involve language holes
that are not guaranteed to work?
Honestly I don't know.
I was just messing around.
My initial question was
So the following code doesn't compile for some reason, and I
can't figure out why.
enum MyEnum { A, B, C }
class MyClass(MyEnum myEnum)
{
/*...*/
}
int main()
{
MyClass!MyEnum.A a;
}
The error: Error: template instance `MyClass!(MyEnum)` does not
match template declaration `MyCl
On Friday, 5 April 2019 at 14:52:05 UTC, lithium iodate wrote:
You are just having a little issue with operator precedence
there. Your code attempts to get the member `A` from
`MyClass!MyEnum`, if you add braces around it, it'll work just
fine `MyClass!(MyEnum.A)`.
That's really funny acutal
module mymodule;
class Foo{}
Foo Bar()
{
Foo foo();
return foo;
}
int main()
{
auto foo = Bar();
return 0;
}
This code doesn't compile with a linker error that there's a
missing symbol for `Foo Bar()` on windows.
After all, `Foo foo();` isn't legitimate
On Friday, 5 April 2019 at 22:08:50 UTC, Adam D. Ruppe wrote:
Weird combination of cases that maybe should be illegal.
It errors with the highly descriptive errormessage:
app.obj(app)
Error 42: Symbol Undefined __D8mymodule3BarFZ3fooMFZCQx3Foo
Error: linker exited with status 1
I am trying to create a template function with a switch case
inside it.
The function signature is:
`static void doSwitch(T...)(int i)`
The code it must generate for `doSwitch!(foo, bar)()` is
`{
switch (int)
{
foo:
foo();
return;
bar:
b
On Sunday, 14 July 2019 at 19:59:36 UTC, Adam D. Ruppe wrote:
but I think even attempting this is overcomplicating.
static foreach (name; FunctionNames)
{
name ~ " : " ~ name ~ "(); break;";
}
I eventually went with
`switch (mixin(index))
{
static fore
I am trying to do a binary insert into my sorted array.
To sort classes and structs I would like to give a delegate `(t)
=> t.myValue` to sort on that value whitout having to implement
an interface or specifically declare opCmp for every class I want
to have sorted.
After all, I might want one
On Wednesday, 11 April 2018 at 21:29:27 UTC, Alex wrote:
I would say, alias template parameter is your friend.
https://dlang.org/spec/template.html#TemplateAliasParameter
class SortedList(T, alias comparer)
It works, thank you!
But just to be shure, there's no way to have this more strongly
t
34 matches
Mail list logo