Hi,
I read about inout functions in the language documentation which allows
to use inout in order to set the constness of the return type based on
the constness of some argument. What is not mentioned is that this also
works for the this-reference by marking the function itself inout:
So instead
On 07/19/2012 03:00 PM, Namespace wrote:
> Is there any way to avoid the implizit copy ctor by array concatenation?
> Or is the only way to use a pointer?
Yes, in some way you have to. If you want to not copy a lot of data (or
avoid additional on-copy effort) you either have to you pointers
explic
On 07/19/2012 02:27 PM, Namespace wrote:
> I have a 2 questions.
>
> I have this code:
>
> [code]
> import std.stdio;
>
> struct Test {
> public:
> this(int i = 0) {
> writeln("Test CTor.");
> }
>
> this(this) {
> writeln("Test Copy CTor");
> }
>
> ~this() {
On 07/19/2012 06:44 AM, Jonathan M Davis wrote:
> On Thursday, July 19, 2012 04:39:26 Francisco Soulignac wrote:
>> So, my question is how can I (correctly) traverse a const SList,
>> const DList, etc?
>
> Right now? I'm pretty sure that that's impossible. Hopefully that will
> change,
> but get
On 06/29/2012 12:47 PM, Namespace wrote:
> A friend of mine ask me why D's foreach isn't like C#
>
> Means, why is it like
> int[] arr = [1, 2, 3];
>
> foreach (int val; arr) {
>
> and not
> foreach (int val in arr) {
>
> which it is more intuitive.
>
> I could give him no clever answer to, so
Hi,
I have a const std.container object (e.g., a const(Array!int)) of which
I'd like to have a range which can traverse that container having
read-only access. This does not seem to be possible with opSlice(). Is
there an alternative?
Best regards,
Matthias
On 06/10/2012 12:30 AM, Era Scarecrow wrote:
> On Saturday, 9 June 2012 at 10:09:25 UTC, Matthias Walter wrote:
>> First, thank you for your answer. I've already made some tiny
>> modifications in order to make BitArray work for my purposes:
>>
>> https:
On 2012-06-08 22:47, Era Scarecrow wrote:
> On Friday, 8 June 2012 at 16:33:28 UTC, Matthias Walter wrote:
>> Hi,
>>
>> trying to traverse the entries of a std.bitmanip.BitArray I stumbled
>> upon the following problem:
>>
>> In case I want to accept cons
0; i < len; i++)
{
bool b = opIndex(i);
result = dg(b);
if (result)
break;
}
return result;
}
Can one glue both things together into a single routine (using inout
magic or whatever)?
Best regards,
Matthias Walter
On 2012-05-19 15:28, Philippe Sigaud wrote:
> On Sat, May 19, 2012 at 12:23 PM, Matthias Walter
> wrote:
>
>> I would open a bug report with the following code which is a bit smaller
>> than my first wrong version:
>>
>> =
> (...)
On 2012-05-19 09:05, Philippe Sigaud wrote:
> On Fri, May 18, 2012 at 11:51 PM, Simen Kjaeraas
> wrote:
>
>> Because Wrapper!(AliasStruct).Wrap does not exist. And _error_ is not
>> equal to any other type.
>
> Yes. Wrap is included in the complete template name (Wrapper!(Wrap))
> and has no in
On 2012-05-18 16:12, Steven Schveighoffer wrote:
> On Fri, 18 May 2012 06:06:45 -0400, Matthias Walter wrote:
>> how do I test two types for equality? Suppose I have A and B aliasing
>> some type(s), how do I find out if they are aliases the same thing?
>>
>> I tried
Hi,
how do I test two types for equality? Suppose I have A and B aliasing
some type(s), how do I find out if they are aliases the same thing?
I tried the "is(A == B)" expression, but this does not always work (tell
me if I shall give an example).
On the other hand, according to the spec the IsEx
On 03/09/2012 10:51 AM, newcomer[bob] wrote:
> On Friday, 9 March 2012 at 09:22:47 UTC, newcomer[bob] wrote:
>> On Friday, 9 March 2012 at 05:50:03 UTC, newcomer[bob] wrote:
>>> The following is a matrix implementation of the fibonacci
>>> algorithm:
>>>
>>> int fib(int n)
>>> {
>>> int M[2][2]
On 03/08/2012 10:48 AM, James Miller wrote:
> On Thursday, March 08, 2012 10:21:48 Matthias Walter wrote:
>> but the following did not work:
>>
>> std.algorithm.swap(arrayInstance[i], arrayInstance[j]);
>
> What error did you get exactly? Since that exact call sho
Hi,
I wanted to have a binary heap where I can update entries and restore
the heap structure.
1. First I observed that due to the implementation of
std.container.BinaryHeap, keeping track of the position of a certain
value in the heap cannot be done directly, but it would be helpful to
pass a "Sw
Hi,
I'd like to have a function foo which shall depend on several
compile-time expressions (e.g. strings) and gets several arguments whose
types are templatized. Here, "several" means in both cases that the
number of expressions/arguments are to be determined at compile-time.
Here is an example:
On 2011-11-27 23:48, mta`chrono wrote:
> that's a real good question. it fails with the following error:
>
> Error: function std.bitmanip.BitArray.dup () is not callable using
> argument types () const
>
>
> here is a hack:
>
> ---
> import std.bitmanip;
> import core.stdc.string;
>
> void mai
Hi,
Recently, I realized that several "dup" methods in D2's phobos are
declared like the one for BitArray:
@property BitArray dup()
My question is why it is declared without "const"? Is it a bug or is
there a reason for it? I can think of a case where one only has
implemented a shallow copy and
Hi all,
suppose I have an array of comparable Foo structs which I want to access
in a sorted order (e.g. a priority queue) using a BinaryHeap object (I
know that for just sorting, the BinHeap is not the right tools), but I
do not want to change the order of the objects in the original array.
I ha
On 12/12/2010 08:43 PM, Andrej M. wrote:
> I can't seem to find an easy remove method in std.algorithm that takes an
> object and a range (an array in this case) and removes any matches from the
> range. I'm using this snippet for now:
>
> private DrawingElement[] elements;
>
> public override vo
On 12/11/2010 01:00 AM, Christopher Nicholson-Sauls wrote:
> On 12/10/10 22:36, Matthias Walter wrote:
>> On 12/10/2010 09:57 PM, Matthias Walter wrote:
>>> Hi all,
>>>
>>> I currently work on a parser for some file format. I wanted to use the
>>> st
On 12/10/2010 09:57 PM, Matthias Walter wrote:
> Hi all,
>
> I currently work on a parser for some file format. I wanted to use the
> std.stdio.ByChunk Range to read from a file and extract tokens from the
> chunks. Obviously it can happen that the current chunk ends before a
Hi all,
I currently work on a parser for some file format. I wanted to use the
std.stdio.ByChunk Range to read from a file and extract tokens from the
chunks. Obviously it can happen that the current chunk ends before a
token can be extracted, in which case I can ask for the next chunk from
the Ra
> The only thing I've been able to think of is
>
>byte[][] a;
>a.length = size;
>for (int i; i < size; i++) {
> a[i].length = size;
>}
Well, you can do at least:
auto a = new byte[][size];
foreach (ref row; a)
row = new byte[size];
Matthias
On 11/27/2010 02:05 PM, bearophile wrote:
>> Reduced case for bugzilla:
>>
> http://d.puremagic.com/issues/show_bug.cgi?id=5281
>
I investigated into the bug and the reason is the signature of opEquals,
which currently is
bool opEquals(Tdummy=void)(ref const BigInt y) const
bool opEquals(T
On 11/18/2010 12:04 AM, Jonathan M Davis wrote:
> On Wednesday 17 November 2010 19:48:30 Matthias Walter wrote:
>
>> Hi,
>>
>> I'm currently using DMD v2.049 with phobos. I found an old discussion
>> about how toString should be designed and how it is su
Hi,
I'm currently using DMD v2.049 with phobos. I found an old discussion
about how toString should be designed and how it is supposed to work. As
the following code does not print out the number, I wonder what is the
current status of how to implement a toString function for a struct/class:
| au
On 06/28/2010 09:49 AM, Justin Spahr-Summers wrote:
> On Sun, 27 Jun 2010 18:51:35 +0200, Matthias Walter
> wrote:
>>
>> Hi list,
>>
>> I tried to write a traits class comparable to iterator_traits in C++ STL
>> or graph_traits in Boost Graph Library in D 2.0,
On 06/28/2010 05:32 AM, Simen kjaeraas wrote:
> Matthias Walter wrote:
>
>> Can I handle this in another way (like making the template a conditional
>> one)?
>
> Template constraints[1] sounds like what you want.
>
> Basically, you want the following:
&g
;
| }
The error message is:
"bug.d(8): Error: template instance ambiguous template declaration
b.Base(T : T*) and a.Base(T)"
Can I handle this in another way (like making the template a conditional
one)?
best regards
Matthias Walter
.
Best regards
Matthias Walter
32 matches
Mail list logo