HibernateD and DDBC - ORM and DB abstraction layer for D

Dicebot m.strashun at gmail.com
Fri Apr 5 08:52:41 PDT 2013


On Friday, 5 April 2013 at 15:20:06 UTC, Jacob Carlborg wrote:
> On 2013-04-05 16:03, Vadim Lopatin wrote:
>
>> 2) Read/write property
>>    @property T someProperty() { ... }
>>    @property xxx someProperty(T value) { ... }
>>    treated as property with name 'someProperty'
>>
>> BTW, I don't know how to check if property is read/write in 
>> compile time.
>
> If there's no better way you can always use __traits(compiles), 
> something like this:
>
> __traits(compiles, { auto c = new Class; T v = c.someProperty; 
> c.someProperty = T.init; });
>
> Currently that will compile regardless of @property or not.

Quoting 
https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/http/restutil.d 
:

template isPropertyGetter(T)
{
	enum isPropertyGetter = (functionAttributes!(T) & 
FunctionAttribute.property) != 0
		&& !is(ReturnType!T == void);
}

template isPropertySetter(T)
{
	enum isPropertySetter = (functionAttributes!(T) & 
FunctionAttribute.property) != 0
		&& is(ReturnType!T == void);
}


More information about the Digitalmars-d-announce mailing list