Commit 04268dac5a945b39fd3d7fc80b297aed1a7d8719
1 parent
deae5139
Minor cleanup to inter_arg_order
Showing
1 changed file
with
4 additions
and
7 deletions
examples/inter_argument_order.cpp
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | #include <iostream> | 2 | #include <iostream> |
| 3 | #include <vector> | 3 | #include <vector> |
| 4 | #include <tuple> | 4 | #include <tuple> |
| 5 | +#include <algorithm> | ||
| 5 | 6 | ||
| 6 | int main(int argc, char **argv) { | 7 | int main(int argc, char **argv) { |
| 7 | CLI::App app; | 8 | CLI::App app; |
| @@ -25,7 +26,7 @@ int main(int argc, char **argv) { | @@ -25,7 +26,7 @@ int main(int argc, char **argv) { | ||
| 25 | std::reverse(std::begin(foos), std::end(foos)); | 26 | std::reverse(std::begin(foos), std::end(foos)); |
| 26 | std::reverse(std::begin(bars), std::end(bars)); | 27 | std::reverse(std::begin(bars), std::end(bars)); |
| 27 | 28 | ||
| 28 | - std::vector<std::tuple<std::string, int>> keyval; | 29 | + std::vector<std::pair<std::string, int>> keyval; |
| 29 | for(auto option : app.parse_order()) { | 30 | for(auto option : app.parse_order()) { |
| 30 | if(option == foo) { | 31 | if(option == foo) { |
| 31 | keyval.emplace_back("foo", foos.back()); | 32 | keyval.emplace_back("foo", foos.back()); |
| @@ -38,11 +39,7 @@ int main(int argc, char **argv) { | @@ -38,11 +39,7 @@ int main(int argc, char **argv) { | ||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | // Prove the vector is correct | 41 | // Prove the vector is correct |
| 41 | - std::string name; | ||
| 42 | - int value; | ||
| 43 | - | ||
| 44 | - for(auto &tuple : keyval) { | ||
| 45 | - std::tie(name, value) = tuple; | ||
| 46 | - std::cout << name << " : " << value << std::endl; | 42 | + for(auto &pair : keyval) { |
| 43 | + std::cout << pair.first << " : " << pair.second << std::endl; | ||
| 47 | } | 44 | } |
| 48 | } | 45 | } |