Boost C++ Libraries: Ticket #6396: Implicit instanciation of boost::rv for non-cass types generates an error https://svn.boost.org/trac10/ticket/6396 <p> boost::rv&lt;T&gt; unconditionally inherits from T. During overload-resolution, the compiler is allowed to instanciate parameter types even if not strictly necessary, which can lead to instanciation of rv for non-class types, causing an error. </p> <p> For example: </p> <pre class="wiki">#include &lt;boost/move/move.hpp&gt; template &lt;typename T&gt; struct vector { void push_back(const T&amp;) {} void push_back(BOOST_RV_REF(T)) {} }; int main() { vector&lt;int&gt; v; v.push_back(123); } </pre><p> Fails on Sun 5.12 with: </p> <pre class="wiki">"/usr/include/boost/move/move.hpp", line 231: Error: The base "boost::T" must be a previously defined class or struct. "main.cpp", line 12: Where: While specializing "boost::rv&lt;int&gt;". "main.cpp", line 12: Where: Specialized in non-template code. </pre><p> And </p> <pre class="wiki">#include &lt;boost/move/move.hpp&gt; template &lt;typename T&gt; class wrapper { BOOST_COPYABLE_AND_MOVABLE_ALT(wrapper) public: wrapper(const T&amp;) {} wrapper(BOOST_RV_REF(T)) {} wrapper(const wrapper&amp;) {} wrapper(BOOST_RV_REF(wrapper)) {} }; int main() { wrapper&lt;int&gt; w1(123); wrapper&lt;int&gt; w2(boost::move(w1)); } </pre><p> fails on GCC 4.4.3 with: </p> <pre class="wiki">/usr/include/boost/move/move.hpp: In instantiation of ‘boost::rv&lt;int&gt;’: main.cpp:17: instantiated from here /usr/include/boost/move/move.hpp:231: error: base type ‘int’ fails to be a struct or class type </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6396 Trac 1.4.3 danivy.gmail@… Thu, 12 Jan 2012 19:03:36 GMT <link>https://svn.boost.org/trac10/ticket/6396#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6396#comment:1</guid> <description> <p> The fix would be to specialize boost::rv for non-class types, avoiding inheritance. This specialization will never be used, but it will shush the compilers. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Sun, 15 Jan 2012 12:26:33 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6396#comment:2 https://svn.boost.org/trac10/ticket/6396#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Avoided inheritance from T when type is not a class or union. Revision: 76509 </p> Ticket