Boost C++ Libraries: Ticket #6981: Can't use boost::ptr_vector<T>::auto_type as data member in GCC 4.6 https://svn.boost.org/trac10/ticket/6981 <p> The following code failed to compile with g++ 4.6.3 on Ubuntu Linux 12.04 LTS. </p> <pre class="wiki">#include &lt;boost/noncopyable.hpp&gt; #include &lt;boost/ptr_container/ptr_vector.hpp&gt; class Test : boost::noncopyable { }; class Pool : boost::noncopyable { public: Pool(); private: boost::ptr_vector&lt;Test&gt;::auto_type p_; }; Pool::Pool() { } </pre><p> the error is </p> <pre class="wiki">In file included from /usr/include/boost/ptr_container/detail/reversible_ptr_container.hpp:22:0, from /usr/include/boost/ptr_container/ptr_sequence_adapter.hpp:20, from /usr/include/boost/ptr_container/ptr_vector.hpp:20, from ptr_vec.cc:2: /usr/include/boost/ptr_container/detail/static_move_ptr.hpp: In instantiation of 'boost::ptr_container_detail::static_move_ptr&lt;Test, boost::ptr_container_detail::clone_deleter&lt;...&gt; &gt; ::cant_move_from_const&lt;const boost::ptr_container_detail::static_move_ptr&lt;Test, boost::ptr_container_detail::clone_deleter&lt;...&gt; &gt; &gt;': ptr_vec.cc:17:12: instantiated from here /usr/include/boost/ptr_container/detail/static_move_ptr.hpp:168:57: error: no type named 'error' in 'class boost::ptr_container_detail::static_move_ptr&lt;Test, boost::ptr_container_detail::clone_deleter&lt;boost::ptr_container_detail::reversible_ptr_container&lt;boost::ptr_container_detail::sequence_config&lt;Test, std::vector&lt;void*, std::allocator&lt;void*&gt; &gt; &gt;, boost::heap_clone_allocator&gt;::null_clone_allocator&lt;false&gt; &gt; &gt;' </pre><p> However, if I inline the constructor, it compiles fine. </p> <pre class="wiki">class PoolOkay : boost::noncopyable { public: PoolOkay() { // okay to inline constructor } private: boost::ptr_vector&lt;Test&gt;::auto_type p_; }; </pre><p> Note: there is no error when compiling with g++ 4.4.3 </p> <p> I am not sure if it's a bug of ptr_container or gcc itself. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6981 Trac 1.4.3 Shuo Chen <giantchen@…> Tue, 12 Jun 2012 04:03:40 GMT <link>https://svn.boost.org/trac10/ticket/6981#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6981#comment:1</guid> <description> <p> update: the inline constructor is irrelevant, when I create an object of <a class="missing wiki">PoolOkay</a>, the same error appears. </p> </description> <category>Ticket</category> </item> <item> <author>Shuo Chen <giantchen@…></author> <pubDate>Tue, 12 Jun 2012 04:57:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6981#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6981#comment:2</guid> <description> <p> Workaround by declaring but not defining assignment operator and copy constructor. </p> <pre class="wiki">class Pool { // ... private: void operator=(const Pool&amp;); Pool(const Pool&amp;); }; </pre><p> Looks like the error was trigger by compiler-generated copy ctor and/or assignment operator. </p> <p> Worth mention that in the doc and put auto_type in regression tests, IMO. </p> </description> <category>Ticket</category> </item> </channel> </rss>