J
Jayden Shui
Hi All,
I have a small code to calculate binary operation of two arrays
#pragma once
#include <functional>
template<template<typename T> class Fn, typename T>
struct Apply
{
template<int N>
void To(T* r, T const* left, T const* right) const
{
r[N-1] = Fn<T>()(left[N-1], right[N-1]);
Apply<Fn, T>().To<N-1>(r, left, right);
}
template<>
void To<0>(T* r, T const* left, T const* right) const
{}
};
int main()
{
int a[3], b[3], c[3];
Apply<std:lus, int>().To<3>(a, b, c); // a = b + c;
return 0;
}
When compilation, I get error:
error : no instance of function template "Apply<Fn, T>::To" matches
the specified type.
Please help me find the bug. Thanks a lot!!
Jayden
I have a small code to calculate binary operation of two arrays
#pragma once
#include <functional>
template<template<typename T> class Fn, typename T>
struct Apply
{
template<int N>
void To(T* r, T const* left, T const* right) const
{
r[N-1] = Fn<T>()(left[N-1], right[N-1]);
Apply<Fn, T>().To<N-1>(r, left, right);
}
template<>
void To<0>(T* r, T const* left, T const* right) const
{}
};
int main()
{
int a[3], b[3], c[3];
Apply<std:lus, int>().To<3>(a, b, c); // a = b + c;
return 0;
}
When compilation, I get error:
error : no instance of function template "Apply<Fn, T>::To" matches
the specified type.
Please help me find the bug. Thanks a lot!!
Jayden