Subject: [Boost-bugs] [Boost C++ Libraries] #3249: ptr_list of const items
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-07-07 15:58:38
#3249: ptr_list of const items
---------------------------------+------------------------------------------
Reporter: matcatprg@⦠| Owner: nesotto
Type: Bugs | Status: new
Milestone: Boost 1.40.0 | Component: ptr_container
Version: Boost 1.35.0 | Severity: Problem
Keywords: |
---------------------------------+------------------------------------------
My code will not compile when I have a ptr_list of const abstract classes
(i.e: boost::ptr_list<const abstract_class>). When I remove the const
keyword, the code compiles and works fine. I'm using gcc 4.3 on Ubuntu
GNU/Linux.
Does the list need to be able to manipulate its items and therefore they
can't be const? Or is it some bug? I noticed this line in the output:
invalid conversion from âconst void*â to âvoid*â
leading me to believe that it can't take consts. If it indeed can't take
consts, you should mention it in the documentation or faq for
ptr_container.
Thanks,
Matthew A. Todd
Here is the output from the compiler:
/usr/include/boost/ptr_container/ptr_sequence_adapter.hpp: In member
function âvoid boost::ptr_sequence_adapter<T, VoidPtrSeq,
CloneAllocator>::push_back(typename
boost::ptr_container_detail::reversible_ptr_container<boost::ptr_container_detail::sequence_config<T,
VoidPtrSeq>, CloneAllocator>::value_type) [with T = const BASE, VoidPtrSeq
= std::list<void*, std::allocator<void*> >, CloneAllocator =
boost::heap_clone_allocator]â:
main.cpp:42: instantiated from here
/usr/include/boost/ptr_container/ptr_sequence_adapter.hpp:183: error:
invalid conversion from âconst void*â to âvoid*â
/usr/include/boost/ptr_container/ptr_sequence_adapter.hpp:183: error:
initializing argument 1 of âvoid std::list<_Tp, _Alloc>::push_back(const
_Tp&) [with _Tp = void*, _Alloc = std::allocator<void*>]â
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/3249> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:00 UTC