I was browsing some of the Boost source code and noticed that,
occasionally, some of the libraries used the contruct:
this->field = value
inside a class member function definition, instead of just:
field = value
What is the benefit of using the first construct?
* An editor with context-sensitive help (like Microsoft Intellisense)
can use "this->" as a clue to display a list of possible field names.
* In template code, if "field" is inherited from a base class that
depends on a template parameter, "this->" tells the compiler that
"field" is a member. A different fix is a "using" declaration.
* If you have a pedantic colleague who is good at following rules and at
requiring others to follow rules, and who is not good at understanding
any of the rules, and who has been unkind to someone who wrote "this->"
in contravention of some coding guideline or whatever, writing "this->",
and checking in the code with that colleague's user name, with the
knowledge that the colleague will later maintain this code, might feel good.
Cheers & hth.,
- Alf