How to use std::addressof in Clipper 11
In this article, the editor introduces in detail "how to use std::addressof in Category 11". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use std::addressof in Craft 11" can help you solve your doubts.
1. Source code preparation
This article is based on the analysis of the source code of gcc-4.9.0, std::addressof is added to the standard, so the lower version of gcc source code does not have this, it is recommended to choose 4.9.0 or newer version to learn, different versions of gcc source code should be different, but the principle and design ideas are the same.
2. Introduction to std::addressof
The purpose of std::addressof is to get the actual address of an object, even if the & operator of that object has been overloaded. It accepts a parameter that is a reference to the object to which the address is to be obtained. Let's take a look at how to use std::addressof through a very simple example
# include # include # include class Test {public: int* operator& () {return & b;} int* a_addr () {return & a;} int* b_addr () {return & b;} private: int a; int b;}; int main (int argc, char* argv []) {Test t; std::cout