Xin chào Tôi đã nâng cấp Xcode của tôi lên phiên bản 4.2 và kêu vang ++ lên phiên bản:kêu vang ++ thông báo lỗi khi sử dụng C++ 0x: gọi constructor xóa của
Apple clang version 3.0 (tags/Apple/clang-211.10.1) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
Khi cố gắng để biên dịch đoạn mã sau với kêu vang -std = C++ 0x
#include <memory>
#include <limits>
#include <boost/shared_ptr.hpp>
class ilpConstraintImpl {
public:
virtual ~ilpConstraintImpl() {}
};
class ilpConstraint {
public:
ilpConstraint(ilpConstraintImpl* implptr):impl(implptr) { }
public:
boost::shared_ptr<ilpConstraintImpl> impl;
};
class ilpExprImpl {
public:
virtual ilpConstraint operator<= (const double rs)=0;
virtual ~ilpExprImpl() {}
};
class ilpExpr {
public:
virtual ~ilpExpr() {};
ilpConstraint operator<= (const double rs) { return impl->operator<=(rs); }
ilpExpr(ilpExprImpl* implptr):impl(implptr) { }
boost::shared_ptr<ilpExprImpl> impl;
};
tôi nhận được lỗi sau:
./test.h:46:54: error: call to deleted constructor of 'ilpConstraint'
ilpConstraint operator<= (const double rs) { return impl->operator<=(rs); }
^~~~~~~~~~~~~~~~~~~~
./test.h:28:7: note: function has been explicitly marked deleted here
class ilpConstraint {
^
1 error generated.
Biên soạn không -std = C++ 0x công trình.
Đó là loại công trình .... thêm một constructor sao chép như: \t ilpConstraint (const ilpConstraint & impcon): impl (impcon.impl) {} di chuyển các vấn đề để đến shared_ptr với thông báo lỗi tương tự:) – plaisthos
Xin lỗi. Bạn có thể thử 'std :: shared_ptr' từ libC++. Bạn phải chọn libC++ trong cài đặt "C++ Standard Library" (nó không phải là mặc định). –
Tôi dường như nhớ rằng đã có một vấn đề với việc tăng shared_ptr có một bản sao đã bị xóa, dựa trên một mẫu hàm tạo để thực hiện sao chép và được ưa chuộng. Các phiên bản sau này đã khắc phục được sự cố đó. –