2 ms·
Cleaner but far less powerful in some respects. Or perhaps, as usual, the restrictions are front-loaded. For example in Rust for some operations on a generic ty
by sidlls 10y ago
Cleaner but far less powerful in some respects. Or perhaps, as usual, the restrictions are front-loaded. For example in Rust for some operations on a generic type you must specify the appropriate Trait in the declaration ("<T: TheTrait>"). In C++ this would be deferred until you tried to perform an operation on the type for which no valid code exists after something has been instantiated.
Other than metaprogramming, Rust's implementation can provide the same functionality that templates do, in a cleaner way in my view.