0
"템플릿 함수 포인터"의 유형을 정의 할 수 있습니까? 이러한"템플릿 함수 포인터"의 유형을 정의 할 수 있습니까?
void (*tfp<99>)(); // can't compile
으로 템플릿 클래스가 할 수있는 것처럼 :
Someclass<99>();
더 내 문제를 설명하기 위해, 나는 다음과 같은 코드가 있습니다
template <int N>
class Foo {};
template <int N>
void foo() {}
template <int N, template <int> class OP>
void test_foo(OP<N> op) { std::cout << N << std::endl; }
내가 test_foo(Foo<99>())
를 호출 할 수 있지만, 수 인수가 인 test_foo()
으로 전화하기 :
test_foo(Foo<99>()); //OK
test_foo(foo<99>); //error: candidate template ignored: could not match '<N>' against 'void (*)()'
test_foo<void (*)()>(foo<99>); //error: candidate template ignored: invalid explicitly-specified argument for template parameter 'N'
test_foo<void (*<99>)()>(foo<99>); //error: expected expression
test_foo<void (*<99>)()<99> >(foo<99>); //error: expected expression
접근 방식 템플릿 매개 변수 N
을 에 넣고 foo<99>
처럼 test_foo(Foo<99>())
처럼 할 수 있습니까? 당신이 할 수