3 ms·
C++ does have something along the lines of Rust traits now, it is called concepts and was added in C++ 20. Mind you it probably has very little real world usag
by TinkersW 6y ago
C++ does have something along the lines of Rust traits now, it is called concepts and was added in C++ 20.
Mind you it probably has very little real world usage right now..
Concepts aren't as powerful as Rust traits in that they are static dispatch only, while Rust supports both static & dynamic-- but they should make for cleaner code than <type_traits>
- steveklabnik 6y agoAnother large difference (in my understanding) is that you're not actually forced to use concepts; they help if you do use them, but they're not required. Rust pretty much requires that you use a trait for these cases.