Path: csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c++ Subject: Re: Virtual functions: To const, or not to const? Date: Mon, 10 Oct 2022 09:26:56 -0700 Organization: A noiseless patient Spider Lines: 12 Message-ID: <868rlniqzz.fsf@linuxsc.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader01.eternal-september.org; posting-host="3c67835d7e1bd6fce16ecef79276b22a"; logging-data="900710"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+XYjmYOtkDzGQn3nwECGCy6ulvV4bPbE=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:t2H5SAnTMCnFdM7er2sb/IHNeC4= sha1:AfgVhzisRdBLgNMFINrMpaIuZ6k= Xref: csiph.com comp.lang.c++:86857 Juha Nieminen writes: [...] > All possible solutions have something wrong about them. That's because what you're asking for is self-contradictory. On the one hand you want to be able to invoke the method on a const reference. On the other hand you want invoking the method on a const reference to give a compile-time error. Obviously the same interface cannot do both, because either possibility necessarily precludes the other.