Ambiguous overload accessing argument-less template functions with variadic parameters

依然范特西╮ 提交于 2019-12-06 06:40:20

Variadic template arguments mean you take 0..n template arguments, thus both your versions are matches.
You could resolve the ambiguity by adding another template parameter to the second version, so that it takes 1..n arguments.
Something like this should work:

template< class T, class Arg1, class... Args > 
boost::shared_ptr< T > make_shared(Arg1&& arg1, Args && ... args )

But as UncleBens correctly pointed out, you don't even need two versions. The following should be enough in your case:

template< class T, class... Args > 
boost::shared_ptr<T> make_shared(Args && ... args );

If you use only one template argument (i.e. T), you get the 0-argument version of make_shared().

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