[Issue 14964] __traits(isAlias, foo)
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jan 23 10:27:42 PST 2017
https://issues.dlang.org/show_bug.cgi?id=14964
b2.temp at gmx.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |b2.temp at gmx.com
--- Comment #5 from b2.temp at gmx.com ---
(In reply to Mike Parker from comment #4)
> (In reply to Mike Parker from comment #3)
> > Not at all. allMembers returns FuncPtr and funcPtr as distinct symbols. What
> > I'm looking for is a generic way to know that one is an alias declaration
> > and the other is not.
>
> And to be clear, I'm talking about at compile time. I realize it's not
> possible at runtime, but surely the compiler knows the difference.
Imagine a text-based serializer (like JSON, in opposite to a binary serializer)
- The serializer writes a size_t under a x86_64 OS and send it over the network
- An x86 machine reads it in a size_t
=> overflow...
In this case I wish to use __traits(isAlias) in a template constraint or in a
static assert to reject the value (e.g "cannot write an aliased type"). The
serializer, without type info, really doesn't want any platform specific type.
To get the info at CT or at RT doesn't make any difference. Any custom type
info structure would use __traits(isAlias) to generate a static instance for an
aggregate field of whatever.
--
More information about the Digitalmars-d-bugs
mailing list