boostorg / boostorg/program_options
Add Transparent Comparator Support
- Vorherrschende Sprache
- C++
- Sterne
- 136
- Forks
- 117
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
It would be great of `boost::program_options::variables_map` could have [transparent comparator](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3465.pdf) 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:
````c++
// 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
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginnen Sie damit, die Deklaration von variables_map und die std::map-Basisklasse, von der sie erbt, zu lokalisieren. Prüfen Sie die Anforderungen von C++14 an transparente Vergleichsoperatoren und die im Issue gezeigte bestehende find-Verwendung. Untersuchen Sie anschließend die Tests des Moduls auf variables_map-Lookups. Als erledigt gilt die Aufgabe, wenn Lookups kompatible stringartige Schlüssel ohne unnötige temporäre std::string-Objekte akzeptieren und das bestehende Verhalten erhalten bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp
- Bereich
- cli
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100