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: nob...@puremagic.com
        ReportedBy: full.de...@gmail.com


--- Comment #0 from Taco <full.de...@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: -------

Reply via email to