3 ms·
Errors that you can recover from. I simply appreciate the added flexibility. Have you ever tried making a container of arbitrary types in C++?
by Pay08 6mo ago
Errors that you can recover from. I simply appreciate the added flexibility. Have you ever tried making a container of arbitrary types in C++?
- lmm 6mo agoIf C++ was the only static type system I'd experienced, I would also think it was a bad idea. Have you ever used an ML-family language?
- Pay08 6mo agoNope. Closest thing I have used was probably Haskell.
- lmm 6mo agoHaskell ought to be good enough. Did you struggle with making your containers there?
- Pay08 6mo agoInterestingly enough, I have never needed them there. Granted, I have written a few orders of magnitude less Haskell than I have C++. Still, the difference is worth interrogating (when I'm less sleep deprived).
- SuperV1234 6mo agoYou cannot do anything meaningful with a container of arbitrary types, it's just bad design. If you want to apply the same operation on all of them, then they share some API commonality -- therefore you can use polymorphism or type erasure. If they don't, you still need to know what types they are -- therefore you can use `std::variant`. If they really are unrelated, why are you storing them together in the same container? Even then, it's trivial in C++: `std::vector<std::any>`.