I don't see im3w1l's example as copying code for some particular functionality, it's copying boilerplate code needed to use a particular library. First the library is initialised, passing in a number of parameters to an initialisation function. If the values of these parameters are the same in multiple instances in the same codebase then that is violating DRY, but if the parameters differ it's just the scaffolding that you are reusing.
The difference, to me, is that it's scaffolding code that can be abstracted. You can't abstract writing a class - it's a primary activity in the language. Only macros can help you there - either the broken ones provided by the C preprocessor, or real ones provided by languages like Racket or Rust.
But boilerplate code that interacts with an external library is not a primary activity in the language. You can hide it behind a class or a family of functions.