Live data from Hacker News

C++20 Concepts: The Definitive Guide

thecodepad.com

41–50 of 102 posts

Re: C++20 Concepts: The Definitive Guide

#41
post #38

Earlier quoted context omitted.

What do you mean? I'm pretty sure no two distinct floats compare as equal.

-0.0 and +0.0?

Are those floats actually distinct? I mean you could represent 3.0 + 4.0 = 7.0 as well. Are "-0.0" and "0.0" actually different?

(This is a serious question I honestly don't know.)

Re: C++20 Concepts: The Definitive Guide

#42
post #38

Earlier quoted context omitted.

-0.0 and +0.0?

Are those floats actually distinct? I mean you could represent 3.0 + 4.0 = 7.0 as well. Are "-0.0" and "0.0" actually different? (This is a serious question I honestly don't know.)

They are distinct values but they compare equal. For almost all uses they are effectively equal, except where you are producing infinities.

Re: C++20 Concepts: The Definitive Guide

#43
post #37
post #11

Another language-changing paradigm added to C++. I haven't even finished learning the old ones yet. Sometimes I think C++ would be better off if the committee stopped accepting proposals that add new features.

I think there's more to it (changing the language) than you are crediting it. First, you don't have to use the new features (though eventually you'll be reading the code of people who did, so this is only half-valuable). There is new c++11 code being written every day -- in volume (a hard to pin down amount) it's sadly more than 50%. The usage surveys don't really capture this clearly (and it's not clear they could).…

I think you hit it on head, that most new features are for library writers who need to capture every edge case succinctly. As someone who has used c++98 and only a little c++11, for nearly 15 years, and writes no libraries; I've had little real need for any new features.

Re: C++20 Concepts: The Definitive Guide

#44
post #11

Another language-changing paradigm added to C++. I haven't even finished learning the old ones yet. Sometimes I think C++ would be better off if the committee stopped accepting proposals that add new features.

Scott Meyers thinks similarly, I think. https://www.youtube.com/watch?v=KAWA1DuvCnQ

Scott Meyers was never a production coder. His schtick was teaching, and he got tired.

The additions since he bowed out improve the experience of production coders.

Re: C++20 Concepts: The Definitive Guide

#45
post #42

Earlier quoted context omitted.

Are those floats actually distinct? I mean you could represent 3.0 + 4.0 = 7.0 as well. Are "-0.0" and "0.0" actually different? (This is a serious question I honestly don't know.)

They are distinct values but they compare equal. For almost all uses they are effectively equal, except where you are producing infinities.

I hadn't thought about the infinities part. If they had the same behavior in all operations involving other numbers, then I could see how they could nonetheless be the same from a C++ type perspective, but given they behave differently, C++ certainly couldn't consider them the same.

Thanks for clearing that up!

Re: C++20 Concepts: The Definitive Guide

#46
post #2

Is it just me, or have C++ errors gotten a lot better? Below example from guide seems a lot more ergonomic than in years past. test.cpp: In instantiation of ‘T add(T, T) [with T = std::basic_string ]’: test.cpp:17:21: required from here test.cpp:11:22: error: static assertion failed 11 | static_assert(std::is_integral_v ); | ~~~~~^~~~~~~~~~~~~~~~ test.cpp:11:22: note: ‘std::is_integral_v >’ evaluates to false Build f…

clang kinda started the race

And now lags behind in C++20 support, as apparently not everyone is keen to upstream whatever they are doing.

Clang concepts were implemented by one guy.

https://cppcast.com/saar-raz-clang-hacking/

Re: C++20 Concepts: The Definitive Guide

#47
post #11

Another language-changing paradigm added to C++. I haven't even finished learning the old ones yet. Sometimes I think C++ would be better off if the committee stopped accepting proposals that add new features.

Just like Java, VB and C# are getting theirs.

Re: C++20 Concepts: The Definitive Guide

#48

I guess this is somewhat besides the point but checking if something can be multiplied by -1 is not great as a definition of subtraction. You'll typically want to use the additive inverse directly. I mean sure you can extend any commutative group into a module over the integers but you probably don't want to make this a hard requirement just to have subtraction.

Why would this be an issue? I'm under the impression that this is fine if we're operating with the standard addition operator and the standard field that everyone is used to working under. Isn't that the definition of the inverse? I understand that in different fields you have different operators but is that relevant here?

Re: C++20 Concepts: The Definitive Guide

#49

Earlier quoted context omitted.

I think you're trying to say you like C but dislike C++'s complexity. You will enjoy Go. Go can be understood as an improved, modernized C that doesn't abandon C's simplicity.

The "Go is like C" comparison never made any sense to me. Go has a sophisticated runtime with transparent N:M threading and built-in concurrency primitives, Interfaces, garbage collection and a large standard library. Go is only simple when compared to the other languages that sit in a similar space, like Java and C#.

C's runtime is UNIX, that is why we got POSIX.

Re: C++20 Concepts: The Definitive Guide

#50
post #11

Another language-changing paradigm added to C++. I haven't even finished learning the old ones yet. Sometimes I think C++ would be better off if the committee stopped accepting proposals that add new features.

Concepts have existed informally since the original C++ STL. For the last 25 years people have been trying to make them a language construct. The current design is the one compromise people could agree on while being implementable and backward compatible.

I haven't used it much yet, but I would still say it is pretty good although far from a proper template type system.

Post reply on HN