Я пытаюсь реализовать ограниченную команду Linux версии cdecl через шаблоны.На данный момент у меня есть
#include <iostream>
using namespace std;
template<class T, class I = void> struct F {
void operator() () {
cout << ">";
F<T> f;
f();
}
};
template<class T> struct F<T[]> {
void operator() () {
cout << "array of ";
F<T> f;
f();
}
};
template<class T> struct F<T()> {
void operator() () {
cout << "function returning ";
F<T> f;
f();
}
};
template<class T, class I> struct F<T(I)> {
void operator() () {
cout << "function accepting ";
F<I> f1;
f1();
cout << "and returning ";
F<T> f;
f();
}
};
template<class T> struct F<T*> {
void operator() () {
cout << "pointer to ";
F<T> f;
f();
}
};
template<> struct F<char> {
void operator() () {
cout << "char ";
}
};
template<> struct F<int> {
void operator() () {
cout << "int ";
}
};
template<> struct F<long> {
void operator() () {
cout << "long ";
}
};
int main()
{
F< char *(*[])(long) > f;
f();
}
, но, похоже, не самый лучший способ, было бы здорово увидеть другие подходы.