In function call, why doesn't nullptr match a pointer to a template object?

后端 未结 5 1910
萌比男神i
萌比男神i 2021-02-20 11:29

Here is an example of a code that works perfectly:


#include
#include

template< class D, template< class D, class A >         


        
5条回答
  •  情歌与酒
    2021-02-20 12:35

    That's to prevent you from creating a template that has nullptr as a argument. You most likely don't want that. You want the template to use a propper class as an argument and take nullptr as a value for that argument.

    You can either

    • explicitly call the right version of the template
    • cast nullptr to a propper type for the template.
    • create a local var of the right pointer type, give it value nullptr and make the call using that var.

提交回复
热议问题