I've done things like this before with traits and I figured that
this way should work as well, but it gives me errors instead.
Perhaps someone can point out my flaws.
immutable(T)[] toString(T)(const(T)* str)
if(typeof(T) is dchar)//this is where the error is
{
return
Jeremy DeHaan:
It compiles if I remove the 'if(typeof(T) is dchar)' section.
Any thoughts?
Try:
if (is(T == dchar))
Bye,
bearophile
On Mon, 25 Aug 2014 15:48:10 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
It compiles if I remove the 'if(typeof(T) is dchar)' section. Any
thoughts?
is should be used as function. here. i.e.: `if (is(T == dchar))`
signature.asc
Description: PGP
On Monday, 25 August 2014 at 15:59:38 UTC, ketmar via
Digitalmars-d-learn wrote:
On Mon, 25 Aug 2014 15:48:10 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
It compiles if I remove the 'if(typeof(T) is dchar)' section.
Any thoughts?
is should be used as
On Monday, 25 August 2014 at 15:52:20 UTC, bearophile wrote:
Jeremy DeHaan:
It compiles if I remove the 'if(typeof(T) is dchar)' section.
Any thoughts?
Try:
if (is(T == dchar))
Bye,
bearophile
That one compiles, and I'm assuming it works. I didn't know you
could use is this way. I've
On Mon, 25 Aug 2014 16:11:27 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Is its ability to be used as a function like this documented
anywhere? I looked and could not find it.
http://dlang.org/concepts.html
template constraints is a special case. is not
On Monday, 25 August 2014 at 16:20:24 UTC, ketmar via
Digitalmars-d-learn wrote:
On Mon, 25 Aug 2014 16:11:27 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Is its ability to be used as a function like this documented
anywhere? I looked and could not find
On Mon, 25 Aug 2014 15:48:10 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
I've done things like this before with traits and I figured that
this way should work as well, but it gives me errors instead.
Perhaps someone can point out my flaws.
On Mon, Aug 25, 2014 at 03:48:10PM +, Jeremy DeHaan via Digitalmars-d-learn
wrote:
I've done things like this before with traits and I figured that this way
should work as well, but it gives me errors instead. Perhaps someone can
point out my flaws.
immutable(T)[] toString(T)(const(T)*
On Monday, 25 August 2014 at 17:05:48 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Mon, Aug 25, 2014 at 03:48:10PM +, Jeremy DeHaan via
Digitalmars-d-learn wrote:
I've done things like this before with traits and I figured
that this way
should work as well, but it gives me errors
On Mon, Aug 25, 2014 at 05:10:18PM +, via Digitalmars-d-learn wrote:
On Monday, 25 August 2014 at 17:05:48 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Mon, Aug 25, 2014 at 03:48:10PM +, Jeremy DeHaan via
Digitalmars-d-learn wrote:
I've done things like this before with traits
On 08/25/14 18:52, Jonathan M Davis via Digitalmars-d-learn wrote:
Another commonly used one is is(typeof(foo)). typeof(foo) gets the type of foo
and will result in void if foo doesn't exist, and is(void) is false, whereas
D is not quite that simple. ;)
static assert(is(void)==true);
(a)
12 matches
Mail list logo