C++ SFINAE Resolution Order

Viewed 534

I have two functions

template <typename... Args>
void foo(Args&&... args) { /* ... */ }

template <typename... Args>
void foo(const std::string& name, Args&&... args) { /* ... */ }

Currently all calls like foo("bar", /* arguments */) try to go to the first function instead of the second. I want to reorder these functions so that the SFINAE finds the second before the first. I cannot use std::enable_if to check for char array/string because the Args... pack might contain std::string& or const char (&) []. How do I do this?

2 Answers
Related