When is deleting a template instantiation preferable to deleting a non-template overload?

后端 未结 4 888
再見小時候
再見小時候 2021-02-05 06:04

Suppose I have a template that works with raw pointers:

template
void processPointer(T* ptr);

I don\'t want this to be called

4条回答
  •  甜味超标
    2021-02-05 06:48

    I don't see any reason to go templating here

    In fact, by deleting the non-template overload you may wiggle your way out of some edge-case ambiguous calls that I can't think of right now, since non-templates take precedence over template instantiations. And thus make this work as desired in a majority of cases.

提交回复
热议问题