I have tried providing getters of class A
for my non-member serialize()
function` since accessing from members is private.
template
Supplementary Information to sehe's first solution:
The solution requires two-phase lookup and or argument dependent lookup. Unfortunately, MSVC does not yet support this to its full extent.
Compiling this in VS Community 2019 16.1.6 with boost 1.70 results in an obscure error:
Error C2063 'boost::serialization::serialize': not a function
Even though conformance mode is enabled through the /permissive- flag and the latest language standard /std::c++latest is selected, as described in this MSVC Blog Post.
Adding the typename qualifier to the friend declaration solves the problem:
template friend void boost::serialization::serialize(typename Ar&, A&, const unsigned);
Even more interestingly frustratingly:
if class A is not a templated class, then it doesn't work either way, same error as above... Example code: http://coliru.stacked-crooked.com/a/ecfbb39d5975d753