Hi all,
I'm trying to get the following code to work.
(This code is a simplified version of some algebraic type).
Is it possible to only declare one version of the 'apply'
function?
Or should I declare the const version and the non-const version?
I tried using "inout", but I got the following
On Thursday, 22 October 2015 at 21:52:05 UTC, anonymous wrote:
On 22.10.2015 21:13, Nordlöw wrote:
Hmm, why isn't this already in Phobos?
Working first version at
https://github.com/nordlow/justd/blob/master/conv_ex.d#L207
Next I'll make it a range.
I am trying to write a function to merge two named structs, but
am completely stuck on how to do that and was wondering if anyone
good provide any help. I know I can access the different names
with tup.fieldNames, but basically can't work out how to use that
to build the new return type. Below
On Saturday, 24 October 2015 at 08:51:58 UTC, Sebastien Alaiwan
wrote:
Hi all,
I'm trying to get the following code to work.
(This code is a simplified version of some algebraic type).
Is it possible to only declare one version of the 'apply'
function?
Or should I declare the const version and
Hi ponce,
Thanks for your suggestion.
I think I may have found the beginning of a solution:
class E
{
import std.traits;
void apply(this F, U)(void delegate(U e) f)
if(is(Unqual!U == E))
{
f(this);
}
int val;
}
int main()
{
void setToZero(E e)
{
e.val = 0;
}
void
On Saturday, 24 October 2015 at 11:28:17 UTC, Sebastien Alaiwan
wrote:
Hi ponce,
Thanks for your suggestion.
I think I may have found the beginning of a solution:
class E
{
import std.traits;
void apply(this F, U)(void delegate(U e) f)
if(is(Unqual!U == E))
{
f(this);
}
int v
On Saturday, 24 October 2015 at 08:54:40 UTC, Nordlöw wrote:
Working first version at
https://github.com/nordlow/justd/blob/master/conv_ex.d#L207
Next I'll make it a range.
Made it a range:
https://github.com/nordlow/justd/blob/master/conv_ex.d#L207
Hello. I had first expected that dynamic arrays (slices) would provide a
`.clear()` method but they don't seem to. Obviously I can always effectively
clear an array by assigning an empty array to it, but this has unwanted
consequences that `[]` actually seems to allocate a new dynamic array and
On 24.10.2015 15:18, Shriramana Sharma wrote:
int a[] = [1,2,3,4,5];
Aside: `int[] a;` is the preferred style for array declarations.
How to make it so that after clearing `a`, `b` will also point to the same
empty array? IOW the desired output is:
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
[]
[]
.
I'm afraid what you're asking for is impossible. Because 'a' and
'b' are both slices, they each have their own 'length' field.
When you do 'a = []', you're effectively doing 'a.length = 0'.
There's no way to change 'b.length' through 'a'. To get that
effect, you'd have to do something like this
On Saturday, 24 October 2015 at 13:18:26 UTC, Shriramana Sharma
wrote:
Hello. I had first expected that dynamic arrays (slices) would
provide a `.clear()` method but they don't seem to. Obviously I
can always effectively clear an array by assigning an empty
array to it, but this has unwanted co
On Saturday, 24 October 2015 at 13:18:26 UTC, Shriramana Sharma
wrote:
Hello. I had first expected that dynamic arrays (slices) would
provide a `.clear()` method but they don't seem to. Obviously I
can always effectively clear an array by assigning an empty
array to it, but this has unwanted co
Hi guys,
Apart from deriving from the same class and declaring an array of
that
root class, is there a way to create an array of templates?
This seems not possible since template are compile-time
generated, but just to be sure. For example, it seems logical to
get an array of complex numbers
On Thursday, 22 October, 2015 02:50 AM, Adam D. Ruppe wrote:
Use the .exe installer and it will offer to download and install visual
studio for you as part for its process.
Sorry to ask this but could anyone please explain why Visual Studio is
required by DMD 64-bit? (I have been away far too l
On Saturday, 24 October 2015 at 16:06:24 UTC, ric maicle wrote:
On Thursday, 22 October, 2015 02:50 AM, Adam D. Ruppe wrote:
Use the .exe installer and it will offer to download and
install visual
studio for you as part for its process.
Sorry to ask this but could anyone please explain why Vi
On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote:
Hi guys,
Apart from deriving from the same class and declaring an array
of that
root class, is there a way to create an array of templates?
This seems not possible since template are compile-time
generated, but just to be sure. F
On Saturday, 24 October 2015 at 16:58:58 UTC, qsdfghjk wrote:
On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote:
Hi guys,
Apart from deriving from the same class and declaring an array
of that
root class, is there a way to create an array of templates?
This seems not possible sin
On Saturday, 24 October 2015 at 17:06:13 UTC, Dandyvica wrote:
On Saturday, 24 October 2015 at 16:58:58 UTC, qsdfghjk wrote:
On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote:
Hi guys,
Apart from deriving from the same class and declaring an
array of that
root class, is there a w
On Saturday, 24 October 2015 at 15:57:09 UTC, Dandyvica wrote:
Hi guys,
Apart from deriving from the same class and declaring an array
of that
root class, is there a way to create an array of templates?
This seems not possible since template are compile-time
generated, but just to be sure. F
On Saturday, 24 October 2015 at 18:29:08 UTC, TheFlyingFiddle
wrote:
Variant[] array;
array ~= S!int(...);
array ~= S!double(...);
array ~= S!long(...);
array ~= "I am a string!";
And this is probably not what you want.
You can do this if you want to ensure that items stored in the
variant ar
On Saturday, 24 October 2015 at 19:00:57 UTC, TheFlyingFiddle
wrote:
One thing about variant is that if the struct you are trying to
insert is larger then (void delegate()).sizeof it will allocate
the wrapped type on the gc heap.
This is not a concern if you want to have class templates as the
On Saturday, 24 October 2015 at 18:40:02 UTC, TheFlyingFiddle
wrote:
To complete TemplateStruct simply forward the remaing members
of the
variant. Or use something like proxy!T in std.typecons. Or use
an alias this v.
(I don't really recommend alias this it has all kinds of
problems)
One thin
Hi, are there any tools for compilation time profiling? I'm
trying to find what part of the code increases compilation time
and don't want to stumble around.
On Saturday, 24 October 2015 at 21:56:05 UTC, tired_eyes wrote:
Hi, are there any tools for compilation time profiling? I'm
trying to find what part of the code increases compilation time
and don't want to stumble around.
There's this:
https://github.com/CyberShadow/DBuildStat
Example output
Hi All,
Given this code:
---
import std.traits;
import std.range;
import std.stdio;
enum isSupportedRange(T) = (isInputRange!T &&
isIntegral!(ForeachType!T));
void func(T)(T vals)
{
static if(isSupportedRange!T) {
// Do something with a range
} else {
// Do something
On Saturday, 24 October 2015 at 23:26:09 UTC, stewart wrote:
Hi All,
Given this code:
---
import std.traits;
import std.range;
import std.stdio;
enum isSupportedRange(T) = (isInputRange!T &&
isIntegral!(ForeachType!T));
void func(T)(T vals)
{
static if(isSupportedRange!T) {
// D
On Saturday, 24 October 2015 at 23:34:19 UTC, stewart wrote:
On Saturday, 24 October 2015 at 23:26:09 UTC, stewart wrote:
[...]
Oh and the workaround I'm using is this:
---
void func(T)(T vals) {
static if(isInputRange!T) {
static if(isIntegral!(ForeachType!T)) {
// D
On Saturday, 24 October 2015 at 23:59:02 UTC, qsdfghjk wrote:
On Saturday, 24 October 2015 at 23:34:19 UTC, stewart wrote:
On Saturday, 24 October 2015 at 23:26:09 UTC, stewart wrote:
[...]
Oh and the workaround I'm using is this:
---
void func(T)(T vals) {
static if(isInputRange!T) {
On Saturday, 24 October 2015 at 23:59:02 UTC, qsdfghjk wrote:
On Saturday, 24 October 2015 at 23:34:19 UTC, stewart wrote:
On Saturday, 24 October 2015 at 23:26:09 UTC, stewart wrote:
[...]
Oh and the workaround I'm using is this:
---
void func(T)(T vals) {
static if(isInputRange!T) {
rsw0x wrote:
> use std.container.array
Thanks all for all the recommendations. When would one use
std.array.appender with a built-in array vs std.container.array.Array? What
are the pros and cons on either side?
--
Shriramana Sharma, Penguin #395953
Just wondering if D's GC release memory back to the OS?
The documentation for the GC.minimize
(http://dlang.org/phobos/core_memory.html#.GC.minimize) seems to
imply that it does,
but watching my OS's memory usage for various D apps doesn't
support this.
On Saturday, 24 October 2015 at 13:18:26 UTC, Shriramana Sharma
wrote:
Hello. I had first expected that dynamic arrays (slices) would
provide a `.clear()` method but they don't seem to. Obviously I
can always effectively clear an array by assigning an empty
array to it, but this has unwanted co
32 matches
Mail list logo