|
Boost Users : |
Subject: [Boost-users] [Move] unique_ptr with boost vector container (C++98)
From: Gene Kang (gene.kang_at_[hidden])
Date: 2017-05-27 19:43:12
Iâm using boost::movelib::unique_ptr with a polymorphic container of type boost::container::vector and getting a compiler error that I canât seem to figure out (see code sample and attached compiler output). Note, this error occurs when compiling without C++11 support w/ x86-64 gcc 4.9.3. When compiling w/ C++11 support (e.g. -std=c++11) the code compiles fine. Any ideas ? Thanks in advance for any help on this.
----------------------------------------------------
#include <boost/move/unique_ptr.hpp>
#include <boost/container/vector.hpp>
class FooA
{
public:
FooA() {}
virtual ~FooA() {}
virtual void execute() {}
};
class FooB : public FooA
{
public:
FooB() {}
virtual void execute() {}
};
int main()
{
typedef boost::movelib::unique_ptr<FooA> FooAPtr;
typedef boost::movelib::unique_ptr<FooB> FooBPtr;
boost::container::vector<FooAPtr> fooVector;
FooBPtr fooBPtr(new FooB);
fooVector.push_back(boost::move(fooBPtr));
return 0;
}
<source>: In function 'int main()':
<source>:54:45: error: no matching function for call to 'boost::container::vector<boost::movelib::unique_ptr<FooA> >::push_back(boost::rv<boost::movelib::unique_ptr<FooB> >&)'
fooVector.push_back(boost::move(fooBPtr));
^
<source>:54:45: note: candidates are:
In file included from /opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:56:0,
from <source>:9:
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: void boost::container::vector<T, Allocator>::push_back(typename boost::move_detail::if_<boost::move_detail::is_class<T>, const boost::rv<T>&, const T&>::type) [with T = boost::movelib::unique_ptr<FooA>; Allocator = boost::container::new_allocator<boost::movelib::unique_ptr<FooA> >; typename boost::move_detail::if_<boost::move_detail::is_class<T>, const boost::rv<T>&, const T&>::type = const boost::rv<boost::movelib::unique_ptr<FooA> >&]
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:72:43: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON'
BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:4: note: in expansion of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: no known conversion for argument 1 from 'boost::rv<boost::movelib::unique_ptr<FooB> >' to 'boost::move_detail::if_c<true, const boost::rv<boost::movelib::unique_ptr<FooA> >&, const boost::movelib::unique_ptr<FooA>&>::type {aka const boost::rv<boost::movelib::unique_ptr<FooA> >&}'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:72:43: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON'
BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_CONST(TYPE) x)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:4: note: in expansion of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: void boost::container::vector<T, Allocator>::push_back(typename boost::move_detail::if_<boost::move_detail::is_class<T>, boost::rv<T>&, boost::move_detail::nat>::type) [with T = boost::movelib::unique_ptr<FooA>; Allocator = boost::container::new_allocator<boost::movelib::unique_ptr<FooA> >; typename boost::move_detail::if_<boost::move_detail::is_class<T>, boost::rv<T>&, boost::move_detail::nat>::type = boost::rv<boost::movelib::unique_ptr<FooA> >&]
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:75:43: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON'
BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:4: note: in expansion of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: no known conversion for argument 1 from 'boost::rv<boost::movelib::unique_ptr<FooB> >' to 'boost::move_detail::if_c<true, boost::rv<boost::movelib::unique_ptr<FooA> >&, boost::move_detail::nat>::type {aka boost::rv<boost::movelib::unique_ptr<FooA> >&}'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:75:43: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON'
BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(BOOST_MOVE_CATCH_RVALUE(TYPE) x) \
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:4: note: in expansion of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: void boost::container::vector<T, Allocator>::push_back(T&) [with T = boost::movelib::unique_ptr<FooA>; Allocator = boost::container::new_allocator<boost::movelib::unique_ptr<FooA> >]
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:78:43: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON'
BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(TYPE &x)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:4: note: in expansion of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: no known conversion for argument 1 from 'boost::rv<boost::movelib::unique_ptr<FooB> >' to 'boost::movelib::unique_ptr<FooA>&'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:78:43: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH_COMMON'
BOOST_MOVE_FORCEINLINE RETURN_VALUE PUB_FUNCTION(TYPE &x)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:4: note: in expansion of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: template<class BOOST_MOVE_TEMPL_PARAM> typename boost_move_conversion_aware_catch_1<void, BOOST_MOVE_TEMPL_PARAM, T>::type boost::container::vector<T, Allocator>::push_back(const BOOST_MOVE_TEMPL_PARAM&) [with BOOST_MOVE_TEMPL_PARAM = BOOST_MOVE_TEMPL_PARAM; T = boost::movelib::unique_ptr<FooA>; Allocator = boost::container::new_allocator<boost::movelib::unique_ptr<FooA> >]
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:104:13: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: template argument deduction/substitution failed:
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:104:13: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp: In substitution of 'template<class BOOST_MOVE_TEMPL_PARAM> typename boost_move_conversion_aware_catch_1<void, BOOST_MOVE_TEMPL_PARAM, T>::type boost::container::vector<T, Allocator>::push_back(const BOOST_MOVE_TEMPL_PARAM&) [with BOOST_MOVE_TEMPL_PARAM = boost::rv<boost::movelib::unique_ptr<FooB> >]':
<source>:54:45: required from here
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: error: no type named 'type' in 'struct boost_move_conversion_aware_catch_1<void, boost::rv<boost::movelib::unique_ptr<FooB> >, boost::movelib::unique_ptr<FooA> >'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:104:13: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: template<class BOOST_MOVE_TEMPL_PARAM> typename boost_move_conversion_aware_catch_2<void, BOOST_MOVE_TEMPL_PARAM, T>::type boost::container::vector<T, Allocator>::push_back(const BOOST_MOVE_TEMPL_PARAM&) [with BOOST_MOVE_TEMPL_PARAM = BOOST_MOVE_TEMPL_PARAM; T = boost::movelib::unique_ptr<FooA>; Allocator = boost::container::new_allocator<boost::movelib::unique_ptr<FooA> >]
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:109:13: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: note: template argument deduction/substitution failed:
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:109:13: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp: In substitution of 'template<class BOOST_MOVE_TEMPL_PARAM> typename boost_move_conversion_aware_catch_2<void, BOOST_MOVE_TEMPL_PARAM, T>::type boost::container::vector<T, Allocator>::push_back(const BOOST_MOVE_TEMPL_PARAM&) [with BOOST_MOVE_TEMPL_PARAM = boost::rv<boost::movelib::unique_ptr<FooB> >]':
<source>:54:45: required from here
/opt/compiler-explorer/libs/boost_1_64_0/boost/container/vector.hpp:1853:38: error: no type named 'type' in 'struct boost_move_conversion_aware_catch_2<void, boost::rv<boost::movelib::unique_ptr<FooB> >, boost::movelib::unique_ptr<FooA> >'
BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
^
/opt/compiler-explorer/libs/boost_1_64_0/boost/move/detail/move_helpers.hpp:109:13: note: in definition of macro 'BOOST_MOVE_CONVERSION_AWARE_CATCH'
PUB_FUNCTION(const BOOST_MOVE_TEMPL_PARAM &u)\
^
Compiler exited with result code 1
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net