Skip to content

Add Transparent Comparator Support #134

@joesdiner

Description

@joesdiner

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions