假設你有2個免費功能:如何拋出重載的自由函數來解決過載衝突?
void do_something(dog d);
void do_something(cat c);
沒有說你要這些功能傳遞給模板函數:
template <typename DoSomethingFunc>
void do_something_template(DoSomethingFunc func);
什麼是首選的方法來調用do_something_template
以避免方式重載解決衝突?它會鑄造嗎?
do_something_template做什麼?我懷疑它需要一個動物論證,它應該選擇和調用這個動物的適當功能? –