digitalmars.D.bugs - [Issue 7182] New: Call const or immutable member functions from class invariant
- d-bugmail puremagic.com (35/35) Dec 29 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7182
- d-bugmail puremagic.com (8/8) Dec 29 2011 http://d.puremagic.com/issues/show_bug.cgi?id=7182
http://d.puremagic.com/issues/show_bug.cgi?id=7182 Summary: Call const or immutable member functions from class invariant Product: D Version: D2 Platform: Other OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: full.demon gmail.com --- Comment #0 from Taco <full.demon gmail.com> 2011-12-29 06:17:44 PST --- The following code yields an error: class A { public: int f() const { return 5; } protected: invariant() { assert (f() == 5); } } "Error: cannot call public/export function f from invariant" Why? f() is const and cannot change the state of an instance of A. Invariant checks are redundant around const/immutable public member functions. What if 'this' was passed to the member function? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 29 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7182 Taco <full.demon gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |enhancement -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 29 2011