#include <iostream>
#include <string>

void f(std::string) { std::cout << "string\n"; }
struct bar;
struct foo {
    friend void f(const bar&) {std::cout << "bar\n"; }
    struct baz { operator bar&(); };
};
struct bar : foo {};
foo::baz::operator bar&() { static bar x; return x; }

template <typename T> struct foobar { operator bar() { return {}; }; };
int main() {
    f(bar{});
    f(foo::baz{});
    f(foobar<bar>{});
}