Are you sure that you have the hasAccess function in the same file as the myMethod function you have there?
Also, why are you doing that? It's so much more readable and simpler to do the same thing with just a static bool in the required file or a bool in your anonymous namespace.