On Friday, May 19, 2017 9:04:24 PM PDT Stefan Koch via Digitalmars-d wrote:
> On Friday, 19 May 2017 at 21:01:09 UTC, Jonathan M Davis wrote:
> > Wait, what? Doesn't D specifically _not_ have SFINAE? You can
> > use static if to test what compiles, and the branch whose
> > condition compiles is
On Friday, 19 May 2017 at 21:25:22 UTC, Stefan Koch wrote:
On Friday, 19 May 2017 at 21:23:11 UTC, Dominikus Dittes
Scherkl wrote:
And it's not visible from the API or documentation - you need
to look into the source to disambiguate - I'm not convinced
and still consider this bad style.
If
On Friday, 19 May 2017 at 21:23:11 UTC, Dominikus Dittes Scherkl
wrote:
On Friday, 19 May 2017 at 21:04:24 UTC, Stefan Koch wrote:
If a template does trigger a static assert,
that static assert is ignored if there is another template in
the overload set that could match.
Wow. Didn't know
On Friday, 19 May 2017 at 21:23:11 UTC, Dominikus Dittes Scherkl
wrote:
On Friday, 19 May 2017 at 21:04:24 UTC, Stefan Koch wrote:
If a template does trigger a static assert,
that static assert is ignored if there is another template in
the overload set that could match.
Wow. Didn't know
On Friday, 19 May 2017 at 21:04:24 UTC, Stefan Koch wrote:
If a template does trigger a static assert,
that static assert is ignored if there is another template in
the overload set that could match.
Wow. Didn't know that.
Is this really part of the D grammar?
Sometimes D is soo cool.
Still
On Friday, 19 May 2017 at 21:01:09 UTC, Jonathan M Davis wrote:
Wait, what? Doesn't D specifically _not_ have SFINAE? You can
use static if to test what compiles, and the branch whose
condition compiles is then the on that gets compiled in, which
kind of emulates what you'd get with SFINAE,
On Friday, May 19, 2017 8:31:52 PM PDT Stefan Koch via Digitalmars-d wrote:
> On Friday, 19 May 2017 at 20:23:16 UTC, Dominikus Dittes Scherkl
>
> wrote:
> > On Friday, 19 May 2017 at 17:47:42 UTC, Stefan Koch wrote:
> >> On Friday, 19 May 2017 at 17:34:28 UTC, Dominikus Dittes
> >>
> >> Scherkl
On Friday, 19 May 2017 at 20:23:16 UTC, Dominikus Dittes Scherkl
wrote:
On Friday, 19 May 2017 at 17:47:42 UTC, Stefan Koch wrote:
On Friday, 19 May 2017 at 17:34:28 UTC, Dominikus Dittes
Scherkl wrote:
[...]
the static assert tells what's going on.
It it does result in a simple overload not
On Friday, 19 May 2017 at 17:47:42 UTC, Stefan Koch wrote:
On Friday, 19 May 2017 at 17:34:28 UTC, Dominikus Dittes
Scherkl wrote:
On Friday, 19 May 2017 at 00:14:05 UTC, Stefan Koch wrote:
string enumToString(E)(E v)
{
static assert(is(E == enum),
"emumToString is only meant for
On Friday, 19 May 2017 at 17:34:28 UTC, Dominikus Dittes Scherkl
wrote:
On Friday, 19 May 2017 at 00:14:05 UTC, Stefan Koch wrote:
string enumToString(E)(E v)
{
static assert(is(E == enum),
"emumToString is only meant for enums");
Why that assert? We can check it at compiletime.
On Friday, 19 May 2017 at 00:14:05 UTC, Stefan Koch wrote:
string enumToString(E)(E v)
{
static assert(is(E == enum),
"emumToString is only meant for enums");
Why that assert? We can check it at compiletime. Doesn't this cry
for a constraint? I would use asserts only ever for
On Thursday, 18 May 2017 at 23:15:46 UTC, ag0aep6g wrote:
On 05/19/2017 12:31 AM, Stefan Koch wrote:
string enumToString(E)(E v)
{
static assert(is(E == enum), "emumToString is only meant
for enums");
mixin ({
string result = "final switch(v) {\n";
On Thu, May 18, 2017 at 11:42:25PM +, Stefan Koch via Digitalmars-d wrote:
> On Thursday, 18 May 2017 at 22:31:47 UTC, Stefan Koch wrote:
>
> > Granted this version will result in undefined behavior if you pass
> > something like (cast(ET) 3) to it.
> > But the 55x increase in compilation
On Thursday, 18 May 2017 at 22:31:47 UTC, Stefan Koch wrote:
Granted this version will result in undefined behavior if you
pass something like (cast(ET) 3) to it.
But the 55x increase in compilation speed is well worth it :)
This code will replicate to!string behavior perfectly but will
On 05/19/2017 12:31 AM, Stefan Koch wrote:
string enumToString(E)(E v)
{
static assert(is(E == enum), "emumToString is only meant for enums");
mixin ({
string result = "final switch(v) {\n";
foreach(m;[__traits(allMembers, E)])
{
result ~= "\tcase E." ~ m ~ "
On Thursday, 18 May 2017 at 22:31:47 UTC, Stefan Koch wrote:
Hi,
I just took a look into commonly used functionality of Phobos.
Such as getting the string representation of a enum.
[...]
Nice, thank you. I dream of a guide to compile time optimization
in D. :)
On Thursday, 18 May 2017 at 22:31:47 UTC, Stefan Koch wrote:
Hi,
I just took a look into commonly used functionality of Phobos.
Such as getting the string representation of a enum.
[...]
Using -vcg-ast we see that it expands to ~50 lines.
Hi,
I just took a look into commonly used functionality of Phobos.
Such as getting the string representation of a enum.
the following code:
import std.conv;
enum ET
{
One,
Two
}
static assert(to!string(ET.One) == "One");
takes about 220 milliseconds to compile.
creating a 7.5k object
18 matches
Mail list logo