Member function pointer issue with standard library methods

淺唱寂寞╮ 提交于 2019-12-01 05:22:49

The problem isn't with the insert functions you showed in MySet. The problem is with one of the ones you omitted. Specifically:

template< class InputIt >
void insert( InputIt first, InputIt last );

From [temp.deduct.call]:

When P is a function type, pointer to function type, or pointer to member function type:
— If the argument is an overload set containing one or more function templates, the parameter is treated as a non-deduced context.

Since &std::set<int>::insert is precisely such an overload set, the parameter is a non-deduced context and cannot be resolved. Your example of MySet does not contain a function template overload for insert, which is why it works fine. If you add one, you'll see that it will also fail to compile.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!