program_options library, options_description object copying
Hello, Today I upgraded to boost 1.33, which broke the 'program options' part of my application. Copying of a boost::program_options::options_description is not allowed anymore, because of a const unsigned int m_line_length, defined at line 211 of <boost/program_options/options_descriptions.hpp> : ===================================================================== Compiling: Configurator.o Configurator.cpp: In member function ` boost::program_options::options_description& boost::program_options::options_description::operator=(const boost::program_options::options_description&)': Configurator.cpp:13: error: non-static const member `const unsigned int boost::program_options::options_description::m_line_length', can't use default assignment operator make: *** [Configurator.o] Error 1 ===================================================================== I wonder, why is this not allowed anymore (except the obvious answer that a const variable cannot be assigned a new value) ? What is the "new", preferred way to copy these objects ? Right now, I've fixed it by removing the const qualifier of that variable, but I can see that's not the preferred way... :) Regards, Leon Mergen
Hi Leon,
Today I upgraded to boost 1.33, which broke the 'program options' part of my application. Copying of a boost::program_options::options_description is not allowed anymore, because of a const unsigned int m_line_length, defined at line 211 of <boost/program_options/options_descriptions.hpp> : .... I wonder, why is this not allowed anymore (except the obvious answer that a const variable cannot be assigned a new value) ? What is the "new", preferred way to copy these objects ?
This was not an explicit design decision -- I just did not though anybody will even want to copy options_description instances. Why do you do it? I think I can just remove "const". - Volodya
On Thu, 2005-09-01 at 18:14 +0400, Vladimir Prus wrote:
Today I upgraded to boost 1.33, which broke the 'program options' part of my application. Copying of a boost::program_options::options_description is not allowed anymore, because of a const unsigned int m_line_length, defined at line 211 of <boost/program_options/options_descriptions.hpp> : .... I wonder, why is this not allowed anymore (except the obvious answer that a const variable cannot be assigned a new value) ? What is the "new", preferred way to copy these objects ?
This was not an explicit design decision -- I just did not though anybody will even want to copy options_description instances.
Why do you do it? I think I can just remove "const".
Hello Vladimir, Thanks for your response! I've created a generic program options parsing class, which uses static functions that allow any class to access the program options without complications. The initialization of the program options requires a 'void addProgramOption ( boost::program_options::options_description )', which copies the program description. I could of course use the obvious solution and start using pointers instead of objects, but I really feel I shouldn't have to... :) Regards, Leon Mergen
participants (2)
-
Leon Mergen
-
Vladimir Prus