Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add Transparent Comparator Support

Open
#134 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp
Domain
cli

Research direction

Start by locating the variables_map declaration and the std::map base it inherits from. Review the C++14 transparent-comparator requirements and the existing find usage shown in the issue, then inspect the module's tests for variables_map lookups. Done means lookups accept compatible string-like keys without unnecessary temporary std::string objects and existing behavior remains intact.

Written by the indexing model from the issue text.

Description

It would be great of boost::program_options::variables_map could have transparent comparator support (c++14 feature), to potentially avoid unnecessary object creation when accessing values in the map. Theoretically only a std::less<> needs to be added as the third template parameter of the std::map variables_map inherits from. Currently:

// 1
boost::program_options::variable_map vm;
vm.find("test"); // implicit std::string object created and destoryed 

// 2
std::string_view sv("test");
vm.find(sv); // does not compile

// 3
vm.find(std::string(sv)); // only way to inspect with a std::string_view, explicit std::string object created and destroyed

With a transparent comparator 1 will not create a std::string object and just compare directly against the c-string literal. 2 will work as shown without any extra objects being created. 3 will be unnecessary

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/program_options

All issues in boostorg/program_options

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.