boostorg / boostorg/program_options
Add Transparent Comparator Support
- 主要言語
- C++
- スター
- 136
- フォーク
- 117
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
まず variables_map の宣言と、それが継承する std::map の基底クラスを特定します。C++14 の透過比較器の要件と、issue に示されている既存の find の使用方法を確認し、その後、variables_map のルックアップに関するモジュールのテストを調べます。完了の条件は、ルックアップが不要な一時 std::string オブジェクトを作成せずに互換性のある string-like キーを受け入れ、既存の動作が維持されることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- cpp
- 領域
- cli
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100