why is this extra check? You already set func in the constructor. If you want extra protection against programmer errors, use CV_Assert() instead.