Thread overview
How do I get class member type?
Jan 14, 2018
Marc
Jan 14, 2018
Marc
Jan 14, 2018
Marc
January 14, 2018
I didn't find how using traits I could get a class member type? I need to test if give class member is not immutable, I find isMutable but not how get a type from give class member to pass to it.
January 14, 2018
On Sunday, 14 January 2018 at 18:18:50 UTC, Marc wrote:
> I didn't find how using traits I could get a class member type? I need to test if give class member is not immutable, I find isMutable but not how get a type from give class member to pass to it.

for clarify, I want all this at compile time, imaginary code example:

> static foreach(field; FieldNameTuple!C) {
> 		static if(isFunction!(__traits(getMember, C, field)) &&  isMutable(typeof(__traits(getMember, C, field)))) {
>			// do something
>		}
>	}
January 14, 2018
On Sunday, 14 January 2018 at 19:08:44 UTC, Marc wrote:
> On Sunday, 14 January 2018 at 18:18:50 UTC, Marc wrote:
>> I didn't find how using traits I could get a class member type? I need to test if give class member is not immutable, I find isMutable but not how get a type from give class member to pass to it.
>
> for clarify, I want all this at compile time, imaginary code example:
>
>> static foreach(field; FieldNameTuple!C) {
>> 		static if(isFunction!(__traits(getMember, C, field)) &&  isMutable(typeof(__traits(getMember, C, field)))) {
>>			// do something
>>		}
>>	}

I solved with this:

		enum isMutableString(string field) = is(typeof(__traits(getMember, Field, field)) == string);