2
是否有可能做到便携如下:C++友元类的std :: vector的
struct structure {
structure() {}
private:
// only allow container copy construct
structure(const structure&) {}
// in general, does not work because allocator (not vector) calls copy construct
friend class std::vector<structure>;
};
例如消息尝试上述编译:
In member function void __gnu_cxx::new_allocator<_Tp>::construct(_Tp*, const _Tp&)
[with _Tp = kernel_data<const double*>::block]:
...
/usr/include/c++/4.3/ext/new_allocator.h:108: error: within this context
感谢
我有解决办法,但我很好奇这是怎么可能的
不,我的解决方法是放弃完全复制构造函数。 谢谢 – Anycorn 2010-05-25 19:03:35
@aaa:如何在不使用复制构造函数的情况下使用容器内的类?更有可能你正在使用隐式拷贝构造函数。 – Potatoswatter 2010-05-25 19:09:23