On Wednesday, 20 January 2016 at 15:25:10 UTC, Jonathan M Davis
wrote:
On Wednesday, January 20, 2016 13:06:00 chardetm via
Digitalmars-d-learn wrote:
Anyone who has the same problem: I found
std.range.primitives.hasSlicing
(https://dlang.org/phobos/std_range_primitives.html#hasSlicing) which
On Wednesday, 20 January 2016 at 10:44:36 UTC, Rikki Cattermole
wrote:
template CanSlice(T) {
enum CanSlice = __traits(compiles, {T t; auto v = t[0 .. 1];})
|| __traits(compiles, {T t; auto v = t.opSlice();});
}
Should work.
Thanks it works just fine!
Hi everyone,
I was wondering if it was possible to know at compile time if
opSlice is defined for a type, including built-in types like
"string". Here is the code I have:
import std.stdio;
struct Test {
Test opSlice(size_t i, size_t j) {
return this; // We don't
Anyone who has the same problem: I found
std.range.primitives.hasSlicing
(https://dlang.org/phobos/std_range_primitives.html#hasSlicing)
which does exactly what I want!
On Monday, 6 April 2015 at 17:55:42 UTC, Iain Buclaw wrote:
On Monday, 6 April 2015 at 17:47:27 UTC, chardetm wrote:
Hello everyone,
I have a problem with the fromStringz function
(std.string.fromStringz) when I try to compile with the GDC
compiler (it works fine with DMD).
Here is a
Hello everyone,
I have a problem with the fromStringz function
(std.string.fromStringz) when I try to compile with the GDC
compiler (it works fine with DMD).
Here is a minimal code to see the error:
import std.stdio, std.string, std.c.stdlib;
int main () {
char* s;
s = cast(char*)
Thanks a lot Ali, now it works perfectly!
It is quite hard to get used to D's logic, I have to stop
thinking in terms of C++...
Anyway, thanks again!
Hello everyone,
I am currently learning D by coding a project, but I encountered
a problem with one of my structures. I managed to reduce the code
to the minimum:
import std.stdio;
import std.container.rbtree;
struct Container {
private RedBlackTree!int _rbtree = new