oadams
oadams

Reputation: 3087

Boost.Program_options syntax

I'm currently reading the Boost.Program_options tutorial.

Here is some of the code they introduce:

// Declare the supported options.
po::options_description desc("Allowed options");
desc.add_options()
    ("help", "produce help message")
    ("compression", po::value<int>(), "set compression level")
;

I understand the purpose behind this code, however the syntax confuses me. Are the indented lines arguments to a function? What is with the brackets?

Upvotes: 1

Views: 316

Answers (1)

vitaut
vitaut

Reputation: 55524

I suppose desc.get_options() returns an object of a class that defines operator() which in turn returns the same object. So the indented lines are calls to this operator with arguments in brackets.

Looking at boost/program_options/options_description.hpp you can see that the class in question is options_description_easy_init which indeed has several operator()'s such as:

    options_description_easy_init&
    operator()(const char* name,
               const char* description);

Upvotes: 2

Related Questions