variable_map implicit copy/move constructors
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
Research direction
Start with include/boost/program_options/variables_map.hpp around abstract_variables_map and variables_map, then reproduce the return-by-value case from the reported main.cpp with Boost 1.88.0 and Clang 19.1.7. Compare the constructor and destructor options against the linked C++ guidance, and define done as an agreed copy/move-semantics resolution with coverage for the abstraction and warning configuration.
Written by the indexing model from the issue text.
Description
We had abstracted our options and parsing (add_options(), store(), and command_line_parser()) calls to a function returning variables_map. This was working, but post updates to boost 1.88.0 (prior 1.75.0) + clang 19.1.7, this now produces an error. At this time the function was small (~15-20 lines) so moving into main was not as big of a deal but we have others where this abstraction could be beneficial from a readability perspective. Should the copy/move constructors be explicitly deleted due to the presence of the destructor, should explicit constructors be added to continue supporting this behavior, should the destructor be removed to allow default copy/move/destruct to be utilized? I am inclined to to vote for option 2 if this behavior should be persisted as the base class abstract_variables_map has a pointer member variable https://github.com/boostorg/program_options/blob/develop/include/boost/program_options/variables_map.hpp#L138 but do not have enough knowledge to know what risks might exist or what those should look like for this library.
In file included from /home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options.hpp:18:
/home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/variables_map.hpp:111:17: error: definition of implicit copy constructor for 'abstract_variables_map' is deprecated because it has a user-provided destructor [-Werror,-Wdeprecated-copy-with-user-provided-dtor]
111 | virtual ~abstract_variables_map() {}
| ^
/home/user/bitbucket/app/build/_deps/boost-src/libs/program_options/include/boost/program_options/variables_map.hpp:146:38: note: in implicit copy constructor for 'boost::program_options::abstract_variables_map' first required here
146 | class BOOST_PROGRAM_OPTIONS_DECL variables_map : public abstract_variables_map,
| ^
/home/user/bitbucket/app/apps/app_name/src/main.cpp:59:12: note: in implicit move constructor for 'boost::program_options::variables_map' first required here
59 | return in_args;
| ^
https://quuxplusone.github.io/blog/2023/05/05/deprecated-copy-with-dtor/
https://stackoverflow.com/a/51864979
- Dominant language
- C++
- Stars
- 136
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/program_options
-
Provide C++20 module Open
Difficulty 5/5 Over a week Newbie friendliness 45/100
boostorg/program_options#160 · 2 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
boostorg/program_options#159 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
boostorg/program_options#147 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
boostorg/program_options#144 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
boostorg/program_options#142 ·
All issues in boostorg/program_options
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
duckdb/duckdb-wasm#2258 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
objectionary/eo-graphs#75 ·
-
Coarray integration tests carry no LABELS, so run_tests.py silently skips them under every backend Opencoarray
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
FISCO-BCOS/FISCO-BCOS#5642 ·