+1 vote
in D Programming by
What Is Transitive Const?

1 Answer

0 votes
by
Transitive const means that once const is applied to a type, it applies recursively to every sub-component of that type. Hence:

const(int*)** p;

p += 1;   // ok, p is mutable

*p += 1;  // ok, *p is mutable

**p += 1; // error, **p is const

***p += 1; // error, ***p is const

With transitivity, there is no way to have a const pointer to mutable int.

C++ const is not transitive.

Related questions

0 votes
asked Mar 5, 2021 in D Programming by SakshiSharma
0 votes
asked Apr 7, 2021 in Maven - Coalescing Pipeline by SakshiSharma
...