Reputation: 57
I have a problem with boost::program_options
i have a class
namespace po = boost::program_options;
class imageProcess{
private:
po::options_description options;
public:
imageProcess(int argc,char** argv){
po::options_description desc("Allowed options");
this->options = desc;
It gives me these errors:
non-static const member ‘const unsigned int boost::program_options::options_description::m_min_description_length’, can’t use default assignment operator imgproc line 163, external location: /usr/include/boost/program_options/options_description.hpp C/C++ Problem non-static const member ‘const unsigned int boost::program_options::options_description::m_line_length’, can’t use default assignment operator imgproc line 163, external location: /usr/include/boost/program_options/options_description.hpp C/C++ Problem use of deleted function ‘boost::program_options::options_description& boost::program_options::options_description::operator=(const boost::program_options::options_description&)’ imageProcess.cpp /imgproc/src line 20 C/C++ Problem
What should i do to make options field instance of po::options_description?
EDIT: I know options field is already an instance but is there a way to set the description "Allowed options" after defining this field(po::options_description options("allowed options"); doesnt work too)? And how i should store previously created instances of object into class fields?
Upvotes: 0
Views: 512
Reputation: 385194
Read your errors:
non-static const member ‘
const unsigned int boost::program_options::options_description::m_min_description_length
’, can’t use default assignment operatornon-static const member ‘
const unsigned int boost::program_options::options_description::m_line_length
’, can’t use default assignment operatoruse of deleted function ‘
boost::program_options::options_description& boost::program_options::options_description::operator=(const boost::program_options::options_description&)
’
They indicate that boost::program_options::options_description
does not support the assignment operator operator=
in your version of Boost (actually since v1.33), due to the const
member within options_description
.
You'll have to — and anyway should — initialise your options_description
instance using the ctor-initializer:
namespace po = boost::program_options;
class imageProcess{
private:
po::options_description options;
public:
imageProcess(int argc, char** argv);
};
imageProcess::imageProcess(int argc, char** argv)
: options("Allowed options")
{}
The line starting :
is where your constructor arguments for the member options
go.
Upvotes: 5