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.
That's a complicated question in D. Only simple cases fit one or
the other exactly.
E.g.
A class always has reference semantics, but may contain any
combination of reference and value semantic fields.
A struct has value semantics, but may contain any combination of
reference and value semantic fields.
A slice has value semantics w.r.t. its length and start point,
but reference semantics for its data.
A static array has value semantics.
For your problem you should look at the set of IsSomething traits
in the table at the top of
http://dlang.org/phobos-prerelease/std_traits.html as they will
hopefully be sufficient.