How to find out which functions the compiler generated?

前端 未结 2 1525
我在风中等你
我在风中等你 2021-02-08 02:29

I know about compiler-generated functions, the rule of three and the rule of five. In real-world scenarios, it may not be trivial to figure out exactly which of the compiler-gen

相关标签:
2条回答
  • 2021-02-08 02:41

    The rules are complicated. I will steal from another answer which quotes a table from Howard Hinnant's presentation.

    The moral here is that a good practice is to not rely on compiler implicit declares and explicitly declare every special member (as defaulted or deleted, depending on your needs)

    0 讨论(0)
  • 2021-02-08 02:53

    "Is there any way to list the compiler-generated functions for a specific class?"

    Of course there is. On Linux (and other Unix systems) you can use nm, readelf and objdump on the generated object files/libraries/executable to disassemble them and inspect any exported symbols (and much more).

    There are similar tools on Windows, I know, but that's not a platform I work much with, so unfortunately I cannot name exact tool names there.

    0 讨论(0)
提交回复
热议问题