Re: opIndex overload for slice not working...

2016-01-24 Thread Ali Çehreli via Digitalmars-d-learn
On 01/24/2016 10:37 PM, Enjoys Math wrote: > class V(T) { > public: > this() {} > V opIndex(size_t i, size_t j) { > writeln("Hello, foo!"); > return this; > } > } > > main() { > auto v = new V!int(); > auto u = v[3..4];// ERROR > } > > Error: > no [] operato

Re: opIndex overload for slice not working...

2016-01-24 Thread biozic via Digitalmars-d-learn
On Monday, 25 January 2016 at 06:37:13 UTC, Enjoys Math wrote: class V(T) { public: this() {} V opIndex(size_t i, size_t j) { writeln("Hello, foo!"); return this; } } main() { auto v = new V!int(); auto u = v[3..4];// ERROR } Error: no [] operator overload for t

opIndex overload for slice not working...

2016-01-24 Thread Enjoys Math via Digitalmars-d-learn
class V(T) { public: this() {} V opIndex(size_t i, size_t j) { writeln("Hello, foo!"); return this; } } main() { auto v = new V!int(); auto u = v[3..4];// ERROR } Error: no [] operator overload for type the_module.V!int

Re: Collapsing n-dimensional array to linear (1 dimensional)

2016-01-24 Thread Solomon E via Digitalmars-d-learn
On Saturday, 23 January 2016 at 07:57:55 UTC, Ali Çehreli wrote: auto collapse(R)(R r) if (isArray!R) { return r.joiner.collapse.joiner; } auto collapse(R)(R r) if (!isArray!R) { return r; } Ali, that code only passed the one test it had for collapsing a three level

Re: Difference between toLower() and asLowerCase() for strings?

2016-01-24 Thread Jon D via Digitalmars-d-learn
On Sunday, 24 January 2016 at 21:04:46 UTC, Adam D. Ruppe wrote: On Sunday, 24 January 2016 at 20:56:20 UTC, Jon D wrote: I'm trying to identify the preferred ways to lower case a string. In std.uni there are two functions that return the lower case form of a string: toLower() and asLowerCase()

Re: Difference between toLower() and asLowerCase() for strings?

2016-01-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 24 January 2016 at 20:56:20 UTC, Jon D wrote: I'm trying to identify the preferred ways to lower case a string. In std.uni there are two functions that return the lower case form of a string: toLower() and asLowerCase(). There is also toLowerInPlace(). toLower will allocate a new s

Difference between toLower() and asLowerCase() for strings?

2016-01-24 Thread Jon D via Digitalmars-d-learn
I'm trying to identify the preferred ways to lower case a string. In std.uni there are two functions that return the lower case form of a string: toLower() and asLowerCase(). There is also toLowerInPlace(). I'm having trouble figuring out what the relationship is between these, and when to pr

Re: Define "createXXX" functions for the constructors of class XXX

2016-01-24 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 23 January 2016 at 19:42:29 UTC, Johan Engelen wrote: Hi all, While trying to interface C++ and D, I have to new a few D objects in C++ code. I am doing this using a D function: "XXX createXXX(...) { return new XXX(...); }". An easier way for trivial constructors (note parents!

Re: Output range for file?

2016-01-24 Thread Tofu Ninja via Digitalmars-d-learn
On Sunday, 24 January 2016 at 15:08:33 UTC, H. S. Teoh wrote: On Sun, Jan 24, 2016 at 12:38:22PM +, Tofu Ninja via Digitalmars-d-learn wrote: I tried looking for this in phobos but cant seem to find it which is really annoying. For my uses this works: What kind of data do you need to write

Re: First project: questions on how-to, and on language features

2016-01-24 Thread Chris Wright via Digitalmars-d-learn
On Sun, 24 Jan 2016 06:07:13 +, Alex Vincent wrote: > Source code: > https://alexvincent.us/d-language/samples/intervalmap-rev1.d.txt There is no documentation, so I have no idea what you're trying to achieve here. So your questions about why this isn't in Phobos, whether there are any othe

Re: Possible to get Class of Interface at runtime

2016-01-24 Thread Josh Phillips via Digitalmars-d-learn
On Saturday, 23 January 2016 at 21:06:32 UTC, Adam D. Ruppe wrote: Are you sure you correctly casted first? Nope sorry. Thanks for the help!!

Re: Output range for file?

2016-01-24 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jan 24, 2016 at 12:38:22PM +, Tofu Ninja via Digitalmars-d-learn wrote: > I tried looking for this in phobos but cant seem to find it which is > really annoying. For my uses this works: What kind of data do you need to write to file? If it's textual data, use File.lockingTextWriter,

Re: Templates, templates, templates...

2016-01-24 Thread anonymous via Digitalmars-d-learn
On 24.01.2016 10:02, Voitech wrote: I added base class for Rule -> BaseRule. But this class is just a shell without implementation. Is there any way to avoid this ? What's the problem with BaseRule not having any implementation? When the different Rule instantiations don't have any common oper

Output range for file?

2016-01-24 Thread Tofu Ninja via Digitalmars-d-learn
I tried looking for this in phobos but cant seem to find it which is really annoying. For my uses this works: struct fileOutRange { File f; void put(ubyte[] a) { f.rawWrite(a); } } But was just wondering if there was a real output range for files

Re: First project: questions on how-to, and on language features

2016-01-24 Thread Marc Schütz via Digitalmars-d-learn
On Sunday, 24 January 2016 at 06:07:13 UTC, Alex Vincent wrote: (1) It's not clear how to specify certain parts of a module or library as non-exportable. Is that possible? Is it desirable? (It's not that important, yet, but still...) Yes, definitely. By default symbols in a module are `publ

Re: alias template parameter

2016-01-24 Thread Marc Schütz via Digitalmars-d-learn
On Friday, 21 June 2013 at 14:08:43 UTC, Sergei Nosov wrote: If I have a function auto apply(alias fun, T...)(T args) { return fun(args); } And then I have int y = 2; apply!(x => y)(1); How in the world does this work? Is the context address known at compile-time? No, but because lambdas

Re: Define "createXXX" functions for the constructors of class XXX

2016-01-24 Thread Johan Engelen via Digitalmars-d-learn
Thanks for the rapid explanations and code! Such a great forum :-) Much obliged, Johan

Re: Templates, templates, templates...

2016-01-24 Thread Voitech via Digitalmars-d-learn
On Saturday, 23 January 2016 at 13:19:34 UTC, anonymous wrote: On 23.01.2016 12:30, Voitech wrote: Ok so i want to hold different types in LogicRule maybe Algebraic implementation would do? private alias ControllTemplate(T) =Rule!(T,ControllFlag); private alias SymbolRule =ControllTemplate!(Sy