Reputation: 2083
I'm trying to use boost::circular_buffer
in my code like this:
class EventRegistry
{
public:
EventRegistry()
{
pendingEvents_.set_capacity(MAX_PENDING_EVENTS);
}
private:
boost::circular_buffer<boost::movelib::unique_ptr<EventData>> pendingEvents_;
}
However, I'm getting a build failure (excerpted):
...
boost/build/binaries/include/boost/circular_buffer/details.hpp:470:12: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept_impl<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
return uninitialized_move_if_noexcept_impl(first, last, dest, a, tag_t());
^
boost/build/binaries/include/boost/circular_buffer/base.hpp:955:37: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
reset(buff, cb_details::uninitialized_move_if_noexcept(e - (std::min)(new_capacity, size()),
^
events/event_registry.cc:22:18: note: in instantiation of member function 'boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >::rset_capacity' requested here
pendingEvents_.rset_capacity(MAX_PENDING_EVENTS);
...
However, if I use an initializer in the constructor:
EventRegistry()
: pendingEvents_(MAX_PENDING_EVENTS)
Then it compiles fine. Any clues?
UPDATE: Here's the full output (sorry for the length)
boost/build/binaries/include/boost/container/allocator_traits.hpp:408:51: error: no matching constructor for initialization of 'boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >'
{ ::new((void*)p, boost_container_new_t()) T(::boost::forward<Args>(args)...); }
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
boost/build/binaries/include/boost/container/allocator_traits.hpp:353:28: note: in instantiation of function template specialization 'boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >::priv_construct<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > >' requested here
allocator_traits::priv_construct(flag, a, p, ::boost::forward<Args>(args)...);
^
boost/build/binaries/include/boost/circular_buffer/details.hpp:439:56: note: in instantiation of function template specialization 'boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >::construct<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > >' requested here
boost::container::allocator_traits<Alloc>::construct(a, boost::addressof(*dest), *first);
^
boost/build/binaries/include/boost/circular_buffer/details.hpp:460:12: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_copy<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
return uninitialized_copy(first, last, dest, a);
^
boost/build/binaries/include/boost/circular_buffer/details.hpp:470:12: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept_impl<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
return uninitialized_move_if_noexcept_impl(first, last, dest, a, tag_t());
^
boost/build/binaries/include/boost/circular_buffer/base.hpp:880:29: note: in instantiation of function template specialization 'boost::cb_details::uninitialized_move_if_noexcept<boost::cb_details::iterator<boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >, boost::cb_details::nonconst_traits<boost::container::allocator_traits<std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > > > >, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > *, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >' requested here
cb_details::uninitialized_move_if_noexcept(b, b + (std::min)(new_capacity, size()), buff, m_alloc),
^
.../events/event_registry.cc:22:18: note: in instantiation of member function 'boost::circular_buffer<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, std::allocator<boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> > > >::set_capacity' requested here
pendingEvents_.set_capacity(MAX_EVENTS_PER_TIMEWINDOW);
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:360:35: note: candidate constructor not viable: 1st argument ('const boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >') would lose const qualifier
BOOST_MOVABLE_BUT_NOT_COPYABLE(unique_ptr)
^
boost/build/binaries/include/boost/move/core.hpp:242:46: note: expanded from macro 'BOOST_MOVABLE_BUT_NOT_COPYABLE'
BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN(TYPE)\
^
boost/build/binaries/include/boost/move/core.hpp:35:7: note: expanded from macro 'BOOST_MOVE_IMPL_NO_COPY_CTOR_OR_ASSIGN'
TYPE(TYPE &);\
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:401:20: note: candidate constructor not viable: no known conversion from 'const boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >' to 'bmupd::nullptr_type' (aka 'int (boost::move_upd::bool_conversion::*)()') for 1st argument
BOOST_CONSTEXPR unique_ptr(BOOST_MOVE_DOC0PTR(bmupd::nullptr_type)) BOOST_NOEXCEPT
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:527:4: note: candidate constructor not viable: no known conversion from 'const boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >' to '::boost::rv<unique_ptr<EventData, default_delete<EventData> > > &' for 1st argument
unique_ptr(BOOST_RV_REF(unique_ptr) u) BOOST_NOEXCEPT
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:424:13: note: candidate template ignored: substitution failure [with Pointer = boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >]: no type named 'type' in 'boost::move_upd::enable_up_ptr<appd::agent::EventData, boost::movelib::unique_ptr<appd::agent::EventData, boost::movelib::default_delete<appd::agent::EventData> >, appd::agent::EventData *, boost::move_upmu::nat>'
explicit unique_ptr(Pointer p
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:462:4: note: candidate constructor template not viable: requires at least 2 arguments, but 1 was provided
unique_ptr(Pointer p, BOOST_MOVE_SEEDOC(deleter_arg_type1) d1
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:500:4: note: candidate constructor template not viable: requires at least 2 arguments, but 1 was provided
unique_ptr(Pointer p, BOOST_MOVE_SEEDOC(deleter_arg_type2) d2
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:547:4: note: candidate template ignored: instantiation would take its own class type by value
unique_ptr( BOOST_RV_REF_BEG_IF_CXX11 unique_ptr<U, E> BOOST_RV_REF_END_IF_CXX11 u
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:390:20: note: candidate constructor not viable: requires 0 arguments, but 1 was provided
BOOST_CONSTEXPR unique_ptr() BOOST_NOEXCEPT
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:475:4: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
unique_ptr(BOOST_MOVE_DOC0PTR(bmupd::nullptr_type), BOOST_MOVE_SEEDOC(deleter_arg_type1) d1) BOOST_NOEXCEPT
^
boost/build/binaries/include/boost/move/unique_ptr.hpp:513:4: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
unique_ptr(BOOST_MOVE_DOC0PTR(bmupd::nullptr_type), BOOST_MOVE_SEEDOC(deleter_arg_type2) d2) BOOST_NOEXCEPT
^
1 error generated.
Upvotes: 1
Views: 1044
Reputation: 472
The following compiles just fine...
#include <boost/circular_buffer.hpp>
#include <boost/move/unique_ptr.hpp>
class EventRegistry
{
public:
EventRegistry()
{
pendingEvents_.set_capacity(10);
}
private:
boost::circular_buffer<boost::movelib::unique_ptr<int>> pendingEvents_;
};
int main()
{
return 0;
}
Note that I've placed an int
where you have EventData
.
You're problem is probably related to EventData
.
(I don't have enough points, to comment...)
Edit: Oh and check what kind of constructors EventData
has! Do you have a default constructor??
Upvotes: 2