Is there any way to view the default functions ( e.g., default copy constructor, default assignment operator ) generated by a compiler such as VC++2008 for a class which does not define them?
C++ – view the default functions generated by a compiler
cvisual c++
Related Topic
- C++ – How to iterate over the words of a string
- C++ – The Definitive C++ Book Guide and List
- C++ – What does the C++ standard state the size of int, long type to be
- C++ – the “–>” operator in C/C++
- C++ – the copy-and-swap idiom
- C++ – The Rule of Three
- C++ – the difference between ‘typedef’ and ‘using’ in C++11
- C# – System.Windows.Application.GetResourceStream returns null
Best Answer
With the
clang
compiler, you can see them by passing the-ast-dump
argument. Clang is still in development stage, but you can already use it for these things:I hope that's what you asked for. Let's change the code and look again.
Notice how the implicitly declared copy constructor of
A
now has a non-const reference parameter, because one of its members has too (memberm
), and thatM
has no default constructor declared.For getting the generated code, you can let it emit virtual machine intermediate language. Let's look on the generated code for this:
Now, i don't understand that intermediate language (which is defined at llvm.org). But you can translate all that code into C using the llvm compiler:
Tada! Notice how it sets the virtual table pointer in the copy constructor and default constructor. Hope this helps.