I have the following code snippet:
void foo(double a) {} namespace bar_space { struct Bar {}; void foo(Bar a) {} }
foo (double) is a common function from the library. I have my own bar_space namespace with my own structure, Bar. I would like to implement the foo () overload for Bar, thereby making Bar more like built-in types.
The problem occurs when I try to call the original foo (double) from the namespace:
namespace bar_space { void baz() { foo(5.0);
This does not compile on gcc on both my Fedora and Mac.
Call
foo(5.0)
from outside the namespace or using
namespace bar_space { ::foo(5.0) }
it works fine, but it does not make my new function as pleasant as I hoped (other developers also work inside bar_space).
Is bar_space a hidden source function? Is there a way to make foo (5.0) callable from bar_space without explicitly defining the scale (: :)? Any help is appreciated.
c ++ function-overloading
Christian askeland
source share