Is there a way to specialize a function (e.g. std::swap ) for a private class?
For example, when I check this:
I get this:
Test.cpp:20:47: error: 'Inner' is a private member of 'Outer' template<> void swap<Outer::Inner>(Outer::Inner &a, Outer::Inner &b) ^ Test.cpp:5:12: note: implicitly declared private here struct Inner ^ Test.cpp:20:64: error: 'Inner' is a private member of 'Outer' template<> void swap<Outer::Inner>(Outer::Inner &a, Outer::Inner &b) ^ Test.cpp:5:12: note: implicitly declared private here struct Inner ^ Test.cpp:20:33: error: 'Inner' is a private member of 'Outer' template<> void swap<Outer::Inner>(Outer::Inner &a, Outer::Inner &b) ^ Test.cpp:5:12: note: implicitly declared private here struct Inner
(I understand that swap friend declaration, which can be found via ADL, avoids this problem for swap , but that doesn't matter for my question. swap is just an example.)
source share