Я пишу класс-оболочку, который скрывает реализацию. Как я могу получить подпись функции данного параметра шаблона?
template <class T>
struct wrapper
{
static typename std::result_of<&T::impl>::type
call(...) { // this function has the same signature of T::impl();
// here goes the jobs to do, such as logging or something
return T::impl(...);
}
};
struct sum : public wrapper<sum>
{
private:
friend class wrapper<func>
static int impl(int a, int b, int c) {
return a + b + c;
}
};
int main()
{
bind_to(&sum::call); // set binding
std::cout << sum::call(1,2,3) << std::endl;
}
struct sum : wrapper<sum>
? - person Mikhail   schedule 05.09.2013impl()
является частной функцией. @Mikhail Пример слишком упрощен, но вwrapper::call()
есть еще несколько заданий. Я создаю привязку к другому языку, поэтому я думаю, что это единственный способ, иначе мне нужно скопировать и вставить задания вwrapper::call()
. - person Inbae Jeong   schedule 05.09.2013