If the two signatures are the same, it is not possible. So, the first solution: add one more tag in parameter list, like struct Foo { struct Path {}; struct NonPath {}; foo(std::string, Path) { /* ... */ } foo(std::string, NonPath) { /* ... */ } }; int main() { // ... auto f1 = foo(s1, Foo::Path); auto f2 = foo(s2, Foo::NonPath); return 0; } Of course, you can also create two different Classes. The two solutions above will be subtle if you have more constructors. Best practice isNamed Constructor Idiom: struct Foo { private: std::string str; Foo(std::string s) : str(s) {} public: static Foo path(std::string s) { /* ... */ return Foo(s); } static Foo non_path(std::string s) { /* ... */ return Foo(s); } }; int main() { // ... auto f1 = Foo::path(s1); auto f2 = Foo::non_path(s2); return 0; }
If the two signatures are the same, it is not possible. So, the first solution: add one more tag in parameter list, like
Of course, you can also create two different Classes.
The two solutions above will be subtle if you have more constructors. Best practice is
Named Constructor Idiom
: