On 04/02/2011 12:14 AM, enuhtac wrote:
template isA( T )
{
static if( is( T U == A!( U, s ), string s ) )
enum bool isA = true;
else
enum bool isA = false;
};
What does ", string s" do here inside the is expression?
Denis
--
_
vita es estrany
spir.wi
Am 02.04.2011 11:24, schrieb spir:
> On 04/02/2011 12:14 AM, enuhtac wrote:
>> template isA( T )
>> {
>> static if( is( T U == A!( U, s ), string s ) )
>> enum bool isA = true;
>> else
>> enum bool isA = false;
>> };
>
> What does ", string s" do here inside the is expre
Am 02.04.2011 04:00, schrieb Caligo:
> On Fri, Apr 1, 2011 at 5:14 PM, enuhtac wrote:
>> Hello,
>>
>> the "is" expression is a great feature of D - but its use is not very
>> intuitive, at least for me.
>> I'm trying to write a template that figures out if the template
>> parameter is of a given t
http://digitalmars.com/d/2.0/arrays.html says static arrays are
limited to 16mb, but I can only allocate 1mb.
My fault, or bug?
enum size = (16 * 1024 * 1024) / int.sizeof;
//int[size] a; // Error: index 4194304 overflow for static
array
enum size2 = (16 * 1000 * 1000) /
This is using dmd 2.052 on windows by the way.
On 2011-04-02 06:21, simendsjo wrote:
> http://digitalmars.com/d/2.0/arrays.html says static arrays are
> limited to 16mb, but I can only allocate 1mb.
> My fault, or bug?
>
> enum size = (16 * 1024 * 1024) / int.sizeof;
> //int[size] a; // Error: index 4194304 overflow for static
>
I think you missed my "/int.sizeof" at the end.
enum size = (16*1024*1024)/int.sizeof;
int[size] a; // "Error index overflow for static" as expected
int[size-1] b; // stack overflow
int[250_001] c; // stack overflow
int[250_000] d; // ok
immutable(int[]) a = [1,2,3];
assert(!is(typeof({a[0] = 0;}))); // cannot change elements
assert(!is(typeof({a = [1,1,1];}))); // cannot rebind
// but I'm allowed to sort in place...
a.reverse;
assert(a == [3,2,1]);
simendsjo:
> http://digitalmars.com/d/2.0/arrays.html says static arrays are
> limited to 16mb, but I can only allocate 1mb.
> My fault, or bug?
It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof = 4_194_304
ints. I don't know why it's designed this way... I'd like 4_194_304 ints
simendsjo:
> // but I'm allowed to sort in place...
> a.reverse;
> assert(a == [3,2,1]);
It's a known bug, already in Bugzilla.
Bye,
bearophile
It turns out the receiveTimeout technique didn't work well for me. In
my case, there's a timer which spawns a high-priority thread calling
`foo` several hundred times per second. What I really needed is to
exhaust the message queue, and then do some other work after that. So
I've added a `shared in
On 02.04.2011 16:45, bearophile wrote:
simendsjo:
http://digitalmars.com/d/2.0/arrays.html says static arrays are
limited to 16mb, but I can only allocate 1mb.
My fault, or bug?
It accepts 4_000_000 ints, but not (16 * 1024 * 1024) / int.sizeof = 4_194_304
ints. I don't know why it's designe
simendsjo:
> The main problem is that it gives a Stack Overflow already at 250_001
I meant with the array as a global variable.
The stack on Windows can be set very large too, with -L/STACK:1000
Bye,
bearophile
13 matches
Mail list logo