P
P
Pinkman2021-10-20 13:41:56
C++ / C#
Pinkman, 2021-10-20 13:41:56

How to pass template function to function parameters?

Hello. There are two template functions max and min, you need to test them) I don’t want to write extra code, I want one testFuncTemplate function that will take three arguments: T a, T b, T (*f)) (T& a, T& b).
But as far as I understand, the compiler cannot determine the type of the passed function, how can this be done?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2021-10-20
@famousman204

testFuncTemplate(a, b, func<T>)
testFuncTemplate(a, b, func<decltype(a)>)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question