On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote:
> On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote:
>> On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote:
>>> Thanks! I was surprised this is not straightforward.
>>
>>enum isLvalue(alias A) =
On 02/01/16 21:42, Artur Skawina wrote:
> On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote:
>> That looks much nicer. It still needs work to properly handle functions with
>> non-empty argument lists.
>
> Then it gets a bit long for a one-liner ;)
>
>enum isLvalue(A...) =
On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote:
On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn
wrote:
Thanks! I was surprised this is not straightforward.
enum isLvalue(alias A) = is(typeof((ref _){}(A)));
artur
That looks much nicer. It still needs
On 2/1/16 2:47 PM, Meta wrote:
On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote:
On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote:
Thanks! I was surprised this is not straightforward.
enum isLvalue(alias A) = is(typeof((ref _){}(A)));
artur
That
On Monday, 1 February 2016 at 20:53:35 UTC, Artur Skawina wrote:
On 02/01/16 21:42, Artur Skawina wrote:
On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote:
That looks much nicer. It still needs work to properly handle
functions with non-empty argument lists.
Then it gets a bit long for a
On Sunday, 31 January 2016 at 22:11:45 UTC, Steven Schveighoffer
wrote:
Thanks! I was surprised this is not straightforward.
-Steve
For function return values, at least, you can do this:
import std.traits, std.stdio;
int foo()
{
return 0;
}
ref int bar()
{
static int x = 0;
On 2/1/16 5:20 PM, tsbockman wrote:
On Sunday, 31 January 2016 at 22:11:45 UTC, Steven Schveighoffer wrote:
Thanks! I was surprised this is not straightforward.
-Steve
For function return values, at least, you can do this:
import std.traits, std.stdio;
int foo()
{
return 0;
}
ref int
On 1/31/16 5:12 PM, Meta wrote:
On Sunday, 31 January 2016 at 22:11:45 UTC, Steven Schveighoffer wrote:
On 1/31/16 4:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively tested it.
There's probably a simpler way but this is the first thing I could come
up with that
On Monday, 1 February 2016 at 22:32:26 UTC, Steven Schveighoffer
wrote:
What I wanted essentially was a template constraint that says
"this type has a member named foo, and t.foo is an lvalue"
-Steve
Like this?
template hasLValProperty(T, string property) {
enum hasLValProperty =
On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote:
> Thanks! I was surprised this is not straightforward.
enum isLvalue(alias A) = is(typeof((ref _){}(A)));
artur
On 1/31/16 4:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively tested it.
There's probably a simpler way but this is the first thing I could come
up with that works.
Thanks! I was surprised this is not straightforward.
-Steve
On Sunday, 31 January 2016 at 22:11:45 UTC, Steven Schveighoffer
wrote:
On 1/31/16 4:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively
tested it.
There's probably a simpler way but this is the first thing I
could come
up with that works.
Thanks! I was
struct S
{
int x;
ref int y() { return x; }
int z() { return 1; }
}
What can I use, given S, to determine that x and y yield lvalues, while
z yields an rvalue?
I was expecting something like isLvalue somewhere, but cannot find it.
__traits(isRef, ...) doesn't work.
-Steve
On Sunday, 31 January 2016 at 20:49:43 UTC, Steven Schveighoffer
wrote:
struct S
{
int x;
ref int y() { return x; }
int z() { return 1; }
}
What can I use, given S, to determine that x and y yield
lvalues, while z yields an rvalue?
I was expecting something like isLvalue somewhere, but
On 01/31/2016 01:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively tested it.
There is hasLvalueElements() as well. Its implementation my be similar
or give other ideas:
https://dlang.org/phobos/std_range_primitives.html#hasLvalueElements
Ali
On Monday, 1 February 2016 at 00:20:00 UTC, Ali Çehreli wrote:
On 01/31/2016 01:48 PM, Meta wrote:
This seems to do the trick, although I haven't extensively
tested it.
There is hasLvalueElements() as well. Its implementation my be
similar or give other ideas:
16 matches
Mail list logo