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

#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 list run by bdawes at, gregod at, cpdaniel at, john at