c++ - what does one sacrifice with this pimpl alternative? -
i have, unfortunately, used qt lot (it purports many things not) , since qt uses pimpl idiom extensively, i've gotten lot of experience pimpl pattern , learned don't it. 1 alternative utilize is:
// .hpp file struct { private: struct b; int a{}; }; // .cpp file struct a::b { // replaces private fellow member function static void f(a& a) { ++a.a; } }; but sacrificed using approach instead of using private function members or pimpl? performance, binary compatibility? pimpl, know performance, because of 1 level of added indirection.
well, 1 - won't work if struct b needs class template takes arbitrary type parameters.
c++
No comments:
Post a Comment