propertySemantics

Tells you if a name is a read and/or write property

propertySemantics
(
T
string name
)
()
if ()

Return Value

Type: auto

Tuple!(bool, "isRead", bool, "isWrite")

Examples

import std.typecons;

struct S
{
	int m;
	@property int rp()
	{
		return m;
	}

	@property void wp(int)
	{
	}

	@property int rwp()
	{
		return m;
	}

	@property void rwp(int)
	{
	}
}

static assert(!__traits(compiles, propertySemantics!(S, "na")));
static assert(!__traits(compiles, propertySemantics!(S, "m")));

static assert(propertySemantics!(S, "rp") == tuple!("canRead", "canWrite")(true, false));
static assert(propertySemantics!(S, "wp") == tuple!("canRead", "canWrite")(false, true));
static assert(propertySemantics!(S, "rwp") == tuple!("canRead", "canWrite")(true, true));

Meta