Subway
Subway

Reputation: 5726

c++: Copying a boost::array

Say I have

boost::array<std::set<std::string>, 100000> arr1, arr2;

After populating arr1 I'm doing arr2=arr1.

Does this copy all the elements from arr1 into arr2 as stl containers do or is it just changing the arr2 pointer to be pointing to the same array as arr1?

In case the first option is correct, what happens when I pass arr1 to a function by value?

Upvotes: 3

Views: 2421

Answers (1)

Jesse Good
Jesse Good

Reputation: 52385

Here is a reference:

template<typename U> array& operator=(const array<U, N>& other);

Effects:
    std::copy(rhs.begin(),rhs.end(), begin())

Note what the Effects are. Also, you should consider std::array instead of boost::array if you're implementation supports it.

Upvotes: 5

Related Questions