[Boost-bugs] [Boost C++ Libraries] #6396: Implicit instanciation of boost::rv for non-cass types generates an error

Subject: [Boost-bugs] [Boost C++ Libraries] #6396: Implicit instanciation of boost::rv for non-cass types generates an error
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-01-12 19:00:05


#6396: Implicit instanciation of boost::rv for non-cass types generates an error
-----------------------------------+----------------------------------------
 Reporter: danivy.mail@… | Owner: igaztanaga
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: move
  Version: Boost 1.48.0 | Severity: Problem
 Keywords: |
-----------------------------------+----------------------------------------
 boost::rv<T> 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.

 For example:

 {{{
 #include <boost/move/move.hpp>

 template <typename T>
 struct vector {
         void push_back(const T&) {}
         void push_back(BOOST_RV_REF(T)) {}
 };

 int main()
 {
         vector<int> v;
         v.push_back(123);
 }
 }}}

 Fails on Sun 5.12 with:

 {{{
 "/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<int>".
 "main.cpp", line 12: Where: Specialized in non-template code.
 }}}

 And

 {{{
 #include <boost/move/move.hpp>

 template <typename T>
 class wrapper {
         BOOST_COPYABLE_AND_MOVABLE_ALT(wrapper)

 public:
         wrapper(const T&) {}
         wrapper(BOOST_RV_REF(T)) {}
         wrapper(const wrapper&) {}
         wrapper(BOOST_RV_REF(wrapper)) {}
 };

 int main()
 {
         wrapper<int> w1(123);
         wrapper<int> w2(boost::move(w1));
 }
 }}}

 fails on GCC 4.4.3 with:

 {{{
 /usr/include/boost/move/move.hpp: In instantiation of ‘boost::rv<int>’:
 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
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6396>
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:08 UTC