Deutsch English Français Italiano |
<velpmk$1mv43$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Thiago Adams <thiago.adams@gmail.com> Newsgroups: comp.lang.c Subject: Re: constexpr keyword is unnecessary Date: Tue, 15 Oct 2024 10:11:48 -0300 Organization: A noiseless patient Spider Lines: 61 Message-ID: <velpmk$1mv43$1@dont-email.me> References: <veb5fi$3ll7j$1@dont-email.me> <vebp8r$3ok6d$1@raubtier-asyl.eternal-september.org> <vebpo5$3olu3$1@dont-email.me> <vebtjp$3p9sm$1@raubtier-asyl.eternal-september.org> <vebubq$3p8oj$1@dont-email.me> <vecuhe$1o44$1@raubtier-asyl.eternal-september.org> <vedt8k$64du$1@dont-email.me> <veduu9$6eql$1@raubtier-asyl.eternal-september.org> <veeq6a$ar0c$1@dont-email.me> <veg8m7$laio$1@raubtier-asyl.eternal-september.org> <veknk0$1icjf$1@dont-email.me> <velkbv$1mkr0$1@raubtier-asyl.eternal-september.org> <velp3q$1n73p$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 15 Oct 2024 15:11:49 +0200 (CEST) Injection-Info: dont-email.me; posting-host="77a1174b06f1d1508764a1a6759a5811"; logging-data="1801347"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Re0YJx+rpD5ZCuxeZzhNey7HMUO+dH7o=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:2yX1IU9rYLhK4zcZAJTVOL6KxXc= Content-Language: en-US In-Reply-To: <velp3q$1n73p$1@dont-email.me> Bytes: 3814 On 15/10/2024 10:01, Bart wrote: > On 15/10/2024 12:41, Bonita Montero wrote: >> Am 15.10.2024 um 05:30 schrieb DFS: >>> On 10/13/2024 6:51 AM, Bonita Montero wrote: >>>> Am 12.10.2024 um 23:37 schrieb Thiago Adams: >>>> >>>>> If you are afraid your constant is not constant expression put a >>>>> static_assert. Then remove. >>>> >>>> This is unnecessary work if you have constexpr. >>>> >>>>> (C++ is a TOTAL mess. const in C++ already could be used n constant >>>>> expression) >>>> >>>> C++ is five to ten times less work for the same problem. >>> >>> >>> How do you measure "work'? >> >> In lines of code. Imagine you would specialize a container like >> unordered_map by hand in C. That would be days of work. In C++ >> it's one line of code and you get nearly optimal performance. >> Or just think about what an emplace_back on a vector of strings >> all does; if the capacity isn't sufficient a doubled vector is >> allocated (libstdc++, libc++), all objects are moved there and >> a new item is emplaced at the end. That's one line of code, but >> in C that's a half day's work. >> > > > Sure, because every time you start a new C app, you're starting from zero. > > There are no existing libraries to use. No online examples to use as > templates. There are no examples of hashtables or growable arrays that > you've implemented over decades of your own work to draw from. > > There is NOTHING. > > In reality it isn't like that. > > Use of C++ does have the advantage when posting bits of code in on-line > forums, since there are a much larger number of /standard/ libraries > that someone running your code will have access to in their > installation, if the code fragment happens to use them. > > Posted C code using a non-standard library would be problematical. > That's probably why C code that use a hash-map, for example, may need to > come with its implementation so it may appear to have a higher line count. > I think C could be improved a lot with something like ChatGPT to create parametrized containers. I was planing to create something (not as advanced of course) but something I could just write "create a vector of int" "create map of strings to int" , "create single linked list" etc.