EDIT:allocators Boost hồ bơi sẽ không biên dịch với std :: allocate_shared trong g ++
Làm rõ kết quả mong muốn của tôi bởi vì tôi đã không truyền đạt nó cũng:
Để có thể sử dụng std::allocate_shared
với boost::fast_pool_allocator
như phương pháp phân bổ sử dụng g ++ 4.8 hoặc cao hơn với boost 1.56.0. Hiện tại, nó hoạt động trên g ++ 4.6 và không thành công trên 4.7, 4.8 và 4.9.
Để rõ ràng, tôi không muốn có công việc này cho g ++ 4.7.
đang thử nghiệm để sản xuất lỗi:
#include "boost/pool/pool.hpp"
#include "boost/pool/pool_alloc.hpp"
#include <memory>
int main(int argc, char** argv)
{
auto fails = std::allocate_shared<int>(boost::fast_pool_allocator<int>());
auto works = std::allocate_shared<int>(boost::fast_pool_allocator<int>(), 5);
}
Trong cơ sở mã của chúng tôi, chúng tôi có sử dụng std :: allocate_shared kết hợp với allocators hồ bơi tăng và kết quả này trong một số lỗi biên dịch khó chịu. Tuy nhiên điều này đã biến dạng và thay đổi trên các phiên bản khác nhau của g ++:
chi tiết: 64bit, (4.7,4.8) -std = C++ 11, (4.6) -std = C++ 0x, tăng 1.56.0
4.6 - biên dịch hạnh phúc
4.7 - Crashes trình biên dịch
Internal compiler error: Error reporting routines re-entered. Please submit a full bug report, with preprocessed source if appropriate. See for instructions. Preprocessed source stored into /tmp/cca0Emq9.out file, please attach this to your bugreport.
4,8 - lỗi biên dịch Nasty
/XXXXXXXXXX/boost/boost/pool/pool_alloc.hpp:399:
error: use of deleted function ‘std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>::_Sp_counted_ptr_inplace(const std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>&)’ { new (ptr) T(t); } ^
/usr/include/c++/4.8/bits/shared_ptr_base.h:198: error: ‘std::_Sp_counted_base<_Lp>::_Sp_counted_base(const std::_Sp_counted_base<_Lp>&) [with __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’ is private _Sp_counted_base(_Sp_counted_base const&) = delete; ^ /usr/include/c++/4.8/bits/shared_ptr_base.h:379: error: within this context class _Sp_counted_ptr_inplace final : public _Sp_counted_base<_Lp> ^
/usr/include/c++/4.8/bits/shared_ptr_base.h:379: error: use of deleted function ‘std::_Sp_counted_base<_Lp>::_Sp_counted_base(const std::_Sp_counted_base<_Lp>&) [with __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/4.8/bits/shared_ptr_base.h:198: error: declared here _Sp_counted_base(_Sp_counted_base const&) = delete; ^
4,9 - lỗi Nasty biên dịch (hơi khác nhau)
/XXXXXXXXXXX/boost/boost/pool/pool_alloc.hpp:399: error: use of deleted function ‘std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>::_Sp_counted_ptr_inplace(const std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>&)’ { new (ptr) T(t); } ^
/usr/include/c++/4.9/bits/shared_ptr_base.h:203: error: ‘std::_Sp_counted_base<_Lp>::_Sp_counted_base(const std::_Sp_counted_base<_Lp>&) [with __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’ is private _Sp_counted_base(_Sp_counted_base const&) = delete; ^
/usr/include/c++/4.9/bits/shared_ptr_base.h:494: error: within this context class _Sp_counted_ptr_inplace final : public _Sp_counted_base<_Lp> ^
/usr/include/c++/4.9/bits/shared_ptr_base.h:494: error: use of deleted function ‘std::_Sp_counted_base<_Lp>::_Sp_counted_base(const std::_Sp_counted_base<_Lp>&) [with __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
Tôi đã dành một số lượng đáng kể thời gian cố gắng để đến đáy của điều này và tôi một số hỗ trợ sẽ được đánh giá cao nếu có ai quen thuộc hơn với hoạt động bên trong của các thành phần này.
Lỗi trình biên dịch nội bộ là _always_ lỗi có thể báo cáo cho nhà cung cấp, SO không thể trợ giúp điều đó. – sehe
Tôi có một linh cảm này là nhiều hơn một thay đổi thư viện chuẩn hơn là một sự thay đổi trình biên dịch. – sehe
Theo đề xuất của @Sehe, đây là một vấn đề với việc thực hiện thư viện chuẩn thay vì trình biên dịch. Tôi đã thử điều này trong (GCC) 5.0.0 20141022 (thử nghiệm) và nó biên dịch. –