According to Can a using statement appear in a constructor initialization list? one work around is to use a private static function like so:
struct bar2
{
bar2(a::b& ab);
int i;
private:
static int wrapper(a::b& f)
{
using std::foo;
return foo(f);
}
};
bar2::bar2(a::b& ab)
: i{wrapper(ab)} // want a::foo if available, else std::foo
{ }
In this case, you can preserve the benefits of the initialization list without having to move the initialization to the body of the constructor. The OP in the question linked above claims that it doesn't provide ADL, but it seems to work for me. To test, simply remove:
int bar(foo f)
{
std::cout << "custom.\n";
return 0;
}