38#include "detail/fromstring.h"
42 template <
typename T>
struct TypeDesc {
static const char*
Name() {
return ""; } };
43 template <>
struct TypeDesc<char> {
static const char*
Name() {
return "char"; } };
44 template <>
struct TypeDesc<unsigned char> {
static const char*
Name() {
return "unsigned char"; } };
45 template <>
struct TypeDesc<signed char> {
static const char*
Name() {
return "signed char"; } };
46 template <>
struct TypeDesc<short> {
static const char*
Name() {
return "short"; } };
47 template <>
struct TypeDesc<unsigned short> {
static const char*
Name() {
return "unsigned short"; } };
48 template <>
struct TypeDesc<int> {
static const char*
Name() {
return "int"; } };
49 template <>
struct TypeDesc<unsigned int> {
static const char*
Name() {
return "unsigned int"; } };
50 template <>
struct TypeDesc<long> {
static const char*
Name() {
return "long"; } };
51 template <>
struct TypeDesc<unsigned long> {
static const char*
Name() {
return "unsigned long"; } };
52 template <>
struct TypeDesc<long long> {
static const char*
Name() {
return "long long"; } };
53 template <>
struct TypeDesc<unsigned long long> {
static const char*
Name() {
return "unsigned long long"; } };
54 template <>
struct TypeDesc<float> {
static const char*
Name() {
return "float"; } };
55 template <>
struct TypeDesc<double> {
static const char*
Name() {
return "double"; } };
56 template <>
struct TypeDesc<long double> {
static const char*
Name() {
return "long double"; } };
57 template <>
struct TypeDesc<bool> {
static const char*
Name() {
return "bool"; } };
58 template <>
struct TypeDesc<std::string> {
static const char*
Name() {
return "string"; } };
59 template <>
struct TypeDesc<std::vector<std::string>> {
static const char*
Name() {
return "words"; } };
61 template <
typename ... Args>
64 template <
typename P,
typename ... Args>
67 template <
typename F,
typename InputIt>
68 static void Exec(
const F& f, InputIt first, InputIt last)
70 assert(first != last);
71 assert(std::distance(first, last) == 1 +
sizeof...(Args));
72 const P p = detail::from_string<typename std::decay<P>::type>(*first);
73 auto g = [&](
auto ... pars) { f(p, pars...); };
81 template <
typename F,
typename InputIt>
82 static void Exec(
const F& f, InputIt first, InputIt last)
84 static_cast<void>(first);
85 static_cast<void>(last);
86 assert(first == last);
91 template <
typename ... Args>
94 template <
typename P,
typename ... Args>
97 static void Collect(std::vector<std::string>& params)
99 params.push_back(
TypeDesc<
typename std::decay<P>::type>::Name());
107 static void Collect(std::vector<std::string>& ) {}
static void Collect(std::vector< std::string > ¶ms)
static void Collect(std::vector< std::string > &)
static void Exec(const F &f, InputIt first, InputIt last)
static void Exec(const F &f, InputIt first, InputIt last)
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()
static const char * Name()