no match for ‘operator=’ error with circular_buffer iterator when addressing buffer by reference?

I am trying do use a circular_buffer iterator and run into problems when I try to write a copy constructor for my class. g++ (GCC) 4.5.3 generates following error: Test.cpp: In copy constructor ‘Test::Test(const Test&)’: Test.cpp:23:18: error: no match for ‘operator=’ in ‘it2 = boost::circular_buffer<T, Alloc>::begin() const [with T = int, Alloc = std::allocator<int>, boost::circular_buffer<T, Alloc>::const_iterator = boost::cb_details::iterator<boost::circular_buffer<int>, boost::cb_details::const_traits<std::allocator<int> > >]()’ /usr/local/include/boost/circular_buffer/details.hpp:253:15: note: candidate is: boost::cb_details::iterator<Buff, Traits>& boost::cb_details::iterator<Buff, Traits>::operator=(const boost::cb_details::iterator<Buff, Traits>&) [with Buff = boost::circular_buffer<int>, Traits = boost::cb_details::nonconst_traits<std::allocator<int> >, boost::cb_details::iterator<Buff, Traits> = boost::cb_details::iterator<boost::circular_buffer<int>, boost::cb_details::nonconst_traits<std::allocator<int> > >] What do I miss. Can anybody help? Thank you, -- Bernd #include <boost/circular_buffer.hpp> class Test { public: Test(); Test(const Test&); private: boost::circular_buffer<int> b; }; Test::Test() { b.resize(10); } Test::Test(const Test &t) { b.resize(10); size_t s1 = b.size(); size_t s2 = t.b.size(); boost::circular_buffer<int>::iterator it1 = b.begin(); boost::circular_buffer<int>::iterator it2 = t.b.begin(); } int main() { Test *t = new Test(); return 0; }

On 08/01/2012 1:13, Bernd Prager wrote:
Test::Test(const Test&t) { b.resize(10);
size_t s1 = b.size(); size_t s2 = t.b.size();
boost::circular_buffer<int>::iterator it1 = b.begin(); boost::circular_buffer<int>::iterator it2 = t.b.begin(); }
Since t is a const reference, I'm guessing all you can get from t.b are const_iterators. Agustín K-ballo Bergé.- http://talesofcpp.blogspot.com

On 1/8/2012 12:07 AM, Agustín K-ballo Bergé wrote:
On 08/01/2012 1:13, Bernd Prager wrote:
Test::Test(const Test&t) { b.resize(10);
size_t s1 = b.size(); size_t s2 = t.b.size();
boost::circular_buffer<int>::iterator it1 = b.begin(); boost::circular_buffer<int>::iterator it2 = t.b.begin(); }
Since t is a const reference, I'm guessing all you can get from t.b are const_iterators.
Agustín K-ballo Bergé.- http://talesofcpp.blogspot.com
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost Thank you, you guessed completely right.
participants (2)
-
Agustín K-ballo Bergé
-
Bernd Prager