Value or Reference Semantics Trait

Orvid King blah38621 at gmail.com
Mon Jan 13 05:41:12 PST 2014


If you just want to check if specifically it's a structure, you could
always check `__traits(compiles, T()) && if(typeof(T()) == T)` beware
however that this will evaluate to true if T is a class with a static
opCall who's return type is T.

On 1/13/14, Tobias Pankrath <tobias at pankrath.net> wrote:
> On Sunday, 12 January 2014 at 20:16:15 UTC, Nordlöw wrote:
>> Is there a trait to check whether a type has value or reference
>> semantics?
>>
>> I need this in a template struct that adaptively (using static
>> if) represent histogram bins as either a dense static array or
>> a sparse associative array.
>
> Adding to the other answers: std.traits.hasIndirections
>



More information about the Digitalmars-d-learn mailing list