I created a function that accepts a function pointer, e.g.
typedef CString(*GetLabelFunc)(const CSomeObject* const pObject);
void DoSomething(GetLabelFunc funcGetLabel);
The function may receive a null pointer and will return an empty string in that case. This works perfectly fine in MSVC++ 2010 when using NULL and nullptr as parameter as well – but I do not consider a successful compilation a safe harbor in such special cases …
Now I wondered if passing nullptr is equivalent to NULL for function pointers. The reason why I am asking is that for instance void* does not accept function pointers (or it least it should not be used). So maybe there is a similar reason that nullptr should not be used for function pointers – meaning is it designed to work for object pointers only?
Yes, nullptr is specified to be convertible to the null pointer value for all pointer types, including function pointer types.
See [conv.ptr] 4.10/1 and [basic.compound] 3.9.2/3.