template friend declaration
class Foo
    {
        template <typename T> friend void T::persist(void);
        int test;
    };
   
    class Bar
    {
        Foo foo;
        void persist(void) { foo.test = 42; }
    }

With this, I hope that persist() member method of every class which defines it will be a friend of foo. The strange friend line compiles, but seems to do nothing.

Thank you in advance.
template friend declaration
===

class Foo
    {
        template <typename T> friend void T::persist(void);
        int test;
    };
   
    class Bar
    {
        Foo foo;
        void persist(void) { foo.test = 42; }
    }

With this, I hope that persist() member method of every class which defines it will be a friend of foo. The strange friend line compiles, but seems to do nothing.

Thank you in advance.