Re: Different visibility in template for class and struct?

2020-05-11 Thread Shigeki Karita via Digitalmars-d-learn
On Monday, 11 May 2020 at 16:10:36 UTC, Steven Schveighoffer wrote: On 5/11/20 11:40 AM, Shigeki Karita wrote: On Monday, 11 May 2020 at 15:29:53 UTC, Steven Schveighoffer wrote: [...] Thanks for your answer. Now I understand that POD matters here. When I add a dtor: `struct LocalS {

Re: Different visibility in template for class and struct?

2020-05-11 Thread Shigeki Karita via Digitalmars-d-learn
On Monday, 11 May 2020 at 15:29:53 UTC, Steven Schveighoffer wrote: On 5/11/20 11:11 AM, Shigeki Karita wrote: [...] First, it actually does compile, I think because the compiler recognizes that LocalS is POD (plain old data), without methods, so it doesn't need a context pointer. e.g.:

Different visibility in template for class and struct?

2020-05-11 Thread Shigeki Karita via Digitalmars-d-learn
Why is local struct visible in this outer template, while local class is not? https://wandbox.org/permlink/MfsDa68qgaMSIr4a https://dlang.org/spec/template.html#instantiation_scope --- enum p(T) = __traits(compiles, new T()); class GlobalC {} struct GlobalS {} void main() { class

Re: Catching std.conv.ConvException in readf causes a buffer overrun

2018-06-26 Thread Shigeki Karita via Digitalmars-d-learn
On Wednesday, 27 June 2018 at 02:39:49 UTC, Shigeki Karita wrote: import std.stdio; import std.conv; void main() { int i; try { readf("%d\n", ); // "a" } catch (ConvException e) { auto s = readln(); writeln(s); // "aa", "aaa" or SEGV ??? } }

Catching std.conv.ConvException in readf causes a buffer overrun

2018-06-26 Thread Shigeki Karita via Digitalmars-d-learn
import std.stdio; import std.conv; void main() { int i; try { readf("%d\n", ); // "a" } catch (ConvException e) { auto s = readln(); writeln(s); // "aa", "aaa" or SEGV ??? } } https://wandbox.org/permlink/NMYNjpOgQtfUprBQ I just want to retry reading if

Re: Why does BinaryHeap sometime cause compile-error in foeach?

2017-09-30 Thread Shigeki Karita via Digitalmars-d-learn
Oh, struct/class semantics really confuses me!

Why does BinaryHeap sometime cause compile-error in foeach?

2017-09-30 Thread Shigeki Karita via Digitalmars-d-learn
https://dpaste.dzfl.pl/cd605899d050 why this code cannot convert to foreach (over Structs and Classes with Ranges). auto h = new BinaryHeap!(int[])(new int[0]); typeof(h).stringof.writeln; static assert(isInputRange!(typeof(h))); h.insert(3); h.insert(1); h.insert(2);