( , ec.), impl::data <string> , - :
class FooUtil;
class Foo
{
friend class FooUtil;
private :
struct impl ;
impl * pimpl ;
};
#include <string>
class FooUtil
{
public:
static std::string data_of(const Foo&);
};
struct impl { std::string data; }
std::string FooUtil::data_of(const Foo& foo)
{
return foo.impl->data;
}
Foo A;
Foo B;
hack-ish work-around std::string Foo::data() const. , <string> , .
Disclaimer . I really don't like this approach. This is very inelegant and is unlikely to really increase compilation time. Some compilers cache (or precompile) standard library headers to help people avoid this kind of mess.
source
share