Boost logo

Boost :

Subject: [boost] [Container] const boost::container::vector is mutable??
From: Eric Niebler (eniebler_at_[hidden])
Date: 2015-03-30 13:05:40


Why are the elements of a const boost::vector mutable through its
const_iterator?

#include <boost/container/vector.hpp>

int main()
{
  using C = boost::container::vector<int>;
  C c{1,2,3,4};
  C const & r = c;
  r[0] = 42; // Error, good.
  *r.begin() = 42; // Compiles! huh??
}

-- 
Eric Niebler
Boost.org
http://www.boost.org

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk