const(Class) is mangled as Class const* const
Namespace via Digitalmars-d
digitalmars-d at puremagic.com
Sun Mar 26 07:51:28 PDT 2017
On Sunday, 26 March 2017 at 14:30:00 UTC, deadalnix wrote:
> On Sunday, 26 March 2017 at 10:43:11 UTC, Benjamin Thaut wrote:
>> As you see from the above example D mangles the getClassConst
>> as a "Class const * const" instead of a "Class const *"
>> ("YAQEBV" vs "YAPEBV"). Is this expected behavior?
>
> It's consistent. D's const is transitive, and D doesn't allow
> you to specify const on the indirection of a reference type. So
> there is no problem on the C++ mangling side of things, but,
> arguably, there is one in D's sementic, that isn't new.
>
> Something like differentiating "const(C) i" and "const C i" may
> be a good idea.
After reading your post, I wonder: How could I translate the
following C++ code to D?
----
int a = 2;
int* const p = &a;
----
More information about the Digitalmars-d
mailing list