r/cpp • • Jun 07 '21

Satire dynamic_cast<std::integer>(C)++

https://www.teamten.com/lawrence/writings/dynamic_cast_std_integer_c.html
202 Upvotes

41 comments sorted by

View all comments

42

u/ihamsa Jun 07 '21

std::integer would be a good name for the standard bignum class. Now please remind me why there isn't any.

15

u/Ipiano42 Jun 07 '21

The argument I always hear is that there are a lot of different things you might optimize a bignum for depending on your use case. This would make it difficult to design a bignum interface which suits most applications well because of how varied the usages and needs of such a type would be (and this is why there's multiple libraries for it). And on top of that, implementing a bignum right (e.g. performant, for some definition of the word) is hard, and this is why some of the bignum libs that exist have contests to see if anyone can shave even single instructions off their runtime.

Not saying I necessarily agree that this is enough of an argument not to provide even a mediocre implementation in std::, just that this is what I've been told.

4

u/NilacTheGrim Jun 09 '21

The argument I always hear is that there are a lot of different things you might optimize a bignum for depending on your use case.

Hmm yeah I have heard this argument presented.

My problem with it is that it is a "catch all" sort of cop-out. You can use that argument for anything. Take std::unordered_map. The implementation we have sucks by many measures and definitions of the word "sucks" -- but at least we have it. I mean using that reasoning we shouldn't even have a standard library....