|
@@ -16,26 +16,10 @@
|
|
|
#include <vector>
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "lambda_cast.h"
|
|
#include "lambda_cast.h"
|
|
|
|
|
+#include "types.h"
|
|
|
|
|
|
|
|
namespace cli {
|
|
namespace cli {
|
|
|
|
|
|
|
|
-template <typename T> struct is_string : std::false_type {};
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-struct is_string<T*> : std::is_same<std::remove_cv_t<T>, char> {};
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-struct is_string<T[]> : std::is_same<std::remove_cv_t<T>, char> {};
|
|
|
|
|
-template <typename...Ts>
|
|
|
|
|
-struct is_string<std::basic_string<Ts...>> : std::true_type {};
|
|
|
|
|
-
|
|
|
|
|
-template <typename T, typename = void> struct is_container : std::false_type {};
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-struct is_container<T, std::enable_if_t<!std::is_void_v<typename T::value_type>>> : std::true_type {};
|
|
|
|
|
-
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-static constexpr bool const is_string_v = is_string<T>::value;
|
|
|
|
|
-template <typename T>
|
|
|
|
|
-static constexpr bool const is_container_v = is_container<T>::value;
|
|
|
|
|
-
|
|
|
|
|
class cli {
|
|
class cli {
|
|
|
public:
|
|
public:
|
|
|
using args_t = std::vector<std::string>;
|
|
using args_t = std::vector<std::string>;
|
|
@@ -101,7 +85,7 @@ cli & cli::register_callback(std::string const & handle,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template <typename T> void cli_print(T const & value) {
|
|
template <typename T> void cli_print(T const & value) {
|
|
|
- if constexpr (is_container_v<T> && !is_string_v<T>) {
|
|
|
|
|
|
|
+ if constexpr (detail::is_container_v<T> && !detail::is_string_v<T>) {
|
|
|
using ::cli::cli_print;
|
|
using ::cli::cli_print;
|
|
|
for (auto & elem : value) {
|
|
for (auto & elem : value) {
|
|
|
cli_print(elem);
|
|
cli_print(elem);
|