local const functions - bug ?
Marc Schütz via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 8 02:01:10 PDT 2016
On Thursday, 7 July 2016 at 15:02:29 UTC, Jonathan M Davis wrote:
> On Thursday, July 07, 2016 10:33:39 Basile B. via
> Digitalmars-d-learn wrote:
>> this compiles without error:
>>
>>
>> struct Foo
>> {
>> int i;
>> void bar()
>> {
>> void foo() const
>> {
>> i = 1;
>> }
>> foo;
>> }
>> }
>>
>> In this case "const" seems to be a noop. Do you think it's a
>> bug ? Shouldn't "const" be applied, despite of foo()
>> inaccessibility ?
>
> It makes no sense for const to be used on foo. foo is not a
> member function, so there's nothing for the const to apply to.
`foo()` is effectively a delegate, therefore `const` applies to
the context.
More information about the Digitalmars-d-learn
mailing list