次のコードでコンパイラ エラーが発生しないのはなぜですか?
template<typename T>
const T testFunc()
{
return T();
}
float* ptr = testFunc<float*>(); // ptr is not const - should be a compiler error!
この例では、testFunc() は定数の float* を返す必要があるため、非 const の float* に代入しようとするとコンパイラ エラーが発生するはずではありませんか?