Deutsch English Français Italiano |
<vf3a4g$g0ua$1@raubtier-asyl.eternal-september.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail From: Bonita Montero <Bonita.Montero@gmail.com> Newsgroups: comp.lang.c Subject: Re: constexpr keyword is unnecessary Date: Sun, 20 Oct 2024 18:12:27 +0200 Organization: A noiseless patient Spider Lines: 31 Message-ID: <vf3a4g$g0ua$1@raubtier-asyl.eternal-september.org> References: <veb5fi$3ll7j$1@dont-email.me> <877ca5q84u.fsf@nosuchdomain.example.com> <vf0ijd$3u54q$1@dont-email.me> <vf0l98$3un4n$1@dont-email.me> <vf1216$p0c$1@dont-email.me> <87y12jpxvl.fsf@nosuchdomain.example.com> <vf1nvj$83oo$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 20 Oct 2024 18:12:01 +0200 (CEST) Injection-Info: raubtier-asyl.eternal-september.org; posting-host="91b514c1147346236c291459ae555624"; logging-data="525258"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/glDsEBYXg0PIxI1aY3CALNqlRN7v2QFc=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:usZ5acFhYNB9WQyddX8iMIliItk= In-Reply-To: <vf1nvj$83oo$1@dont-email.me> Content-Language: de-DE Bytes: 2341 Am 20.10.2024 um 03:56 schrieb Thiago Adams: > I used to find const confusing, as it sometimes meant 'read-only' and > other times 'immutable.' > Now, it seems less confusing to me. When const is used with variables > that can be initialized (init-declarator), it acts as 'immutable,' > meaning the storage is constant. > In other contexts, like function parameters, const means 'read-only' > because we don’t know if the storage is constant or not. I'm asking myself what should be confusing with constexpr. > It’s also interesting to note that constexpr acts as a storage > qualifier. What the compiler needs to know when evaluating an expression > at compile time, without depending on flow analysis, is the guarantee > that the object is immutable. This makes it safe to use the value it has > at initialization when the initialization is also a compile time > expression. > > const used in variables that can be initialized gives the compiler the > same guarantees. > > > > > > > >