Commit 4af3faef80dc66f9b1a540059590006de2cb166e
1 parent
33f4c578
Adding forwarding version of hlpers
Showing
1 changed file
with
11 additions
and
7 deletions
include/CLI/App.hpp
| @@ -1048,16 +1048,20 @@ namespace detail { | @@ -1048,16 +1048,20 @@ namespace detail { | ||
| 1048 | /// This class is simply to allow tests access to App's protected functions | 1048 | /// This class is simply to allow tests access to App's protected functions |
| 1049 | struct AppFriend { | 1049 | struct AppFriend { |
| 1050 | 1050 | ||
| 1051 | - /// Wrap _parse_short | ||
| 1052 | - static void parse_short(App* app, std::vector<std::string> &args) { | ||
| 1053 | - return app->_parse_short(args); | 1051 | + /// Wrap _parse_short, perfectly forward arguments and return |
| 1052 | + template<typename ...Args> | ||
| 1053 | + static auto parse_short(App* app, Args && ...args) | ||
| 1054 | + -> typename std::result_of<decltype(&App::_parse_short)(App, Args...)>::type { | ||
| 1055 | + return app->_parse_short(std::forward<Args>(args)...); | ||
| 1054 | } | 1056 | } |
| 1055 | 1057 | ||
| 1056 | - /// Wrap _parse_long | ||
| 1057 | - static void parse_long(App* app, std::vector<std::string> &args) { | ||
| 1058 | - return app->_parse_long(args); | 1058 | + |
| 1059 | + /// Wrap _parse_long, perfectly forward arguments and return | ||
| 1060 | + template<typename ...Args> | ||
| 1061 | + static auto parse_long(App* app, Args && ...args) | ||
| 1062 | + -> typename std::result_of<decltype(&App::_parse_long)(App, Args...)>::type { | ||
| 1063 | + return app->_parse_long(std::forward<Args>(args)...); | ||
| 1059 | } | 1064 | } |
| 1060 | - | ||
| 1061 | 1065 | ||
| 1062 | }; | 1066 | }; |
| 1063 | } | 1067 | } |