Error: cannot call public/export function someFunction from invariant
Jonathan M Davis
jmdavisProg at gmx.com
Fri Oct 18 02:08:37 PDT 2013
On Friday, October 18, 2013 11:04:25 bearophile wrote:
> simendsjo:
> > See topic. Why is this not allowed? The function in question is
> > not virtual.
> >
> > struct S {
> >
> > void someFunction() const {}
> > const invariant() { someFunction(); }
> >
> > }
> > void main() {
> >
> > S s;
> >
> > }
>
> It being not virtual is not important. In what cases is
> invariant() called, simendsjo? I sense an infinite loop.
Yeah, it's probably because someFunction calls the invariant before and after
it's called. If you want to call a member function from an invariant, it
should be static, or it should be a free function.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list