What's the bug in the following code ?

Posted by Johannes on Stack Overflow See other posts from Stack Overflow or by Johannes
Published on 2010-03-29T13:12:05Z Indexed on 2010/03/29 13:13 UTC
Read the original article Hit count: 200

Filed under:
|
|
#include <iostream>
#include <algorithm>
#include <vector>
#include <boost/array.hpp>
#include <boost/bind.hpp>

int main() {
  boost::array<int, 4> a = {45, 11, 67, 23};
  std::vector<int> v(a.begin(), a.end());
  std::vector<int> v2;
  std::transform(v.begin(), v.end(), v2.begin(), 
    boost::bind(std::multiplies<int>(), _1, 2));
  std::copy(v2.begin(), v2.end(), std::ostream_iterator<int>(std::cout, " "));
}

When run, this gives a creepy segmentation fault. Please tell me where I'm going wrong.

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost