I'am trying to understand the example from program_options of the boost library (http://www.boost.org/doc/libs/1_38_0/doc/html/program_options/tutorial.html#id3761458)
Especially this part:
desc.add_options()
("help", "produce help message")
("compression", po::value<int>(), "set compression level")
;
what exactly is he doing here and which technique is that?
This part desc.add_options() could be a function call but how do the other () fit here? Is this some kind of operator overloading?
Thanks!
Best Answer
The "add_options()" function actually returns a functor, that is, an object that overrides the () operator. This means that the following function call
actually expands to
The "operator()" also returns a functor, so that the calls can be chained as you have shown.