I am familiar with class specialization but came across this piece of code which I believe is function specialization
A:
template <bool include_negatives>
int average(int* array, int len) {
....
}
I could rewrite the above as this C
. I know that I am specializing a class so I need to provide B. My question is what is happening in A. Why does that not need a generic type since its being specialized.
B:
template<typename t>
int average(){
}
C:
template<>
int average<bool>(){
...
}
My question is why does the
Aucun commentaire:
Enregistrer un commentaire