views:

68

answers:

5
A: 

I see no problem here. Perhaps an updated GCC (Glibc) would solve the problem?

    shade@vostro:~$ ls /usr/include/c++/
    4.4  4.4.3
    shade@vostro:~$ cd ~/Desktop
    shade@vostro:~/Desktop$ g++ test.cpp 
    shade@vostro:~/Desktop$ ./a.out 
    shade@vostro:~/Desktop$ 
Shade
I won't downvote, but there is a problem with the code. Namely that arrays are not copyable/assignable which are requirements for `std::vector`.
Evan Teran
I can't see any compiler compiling this; certainly not GCC
Michael Mrozek
At one time, before I had a clue, I used to put references in std::vector and GCC ate them up just fine. I think the implementation simply doesn't stop you until it actually has to use whatever part of the concept is required that you don't supply.
Noah Roberts
@Noah: yea, many errors can only be caught during template instantiation.
Evan Teran
+3  A: 

The only way you can solve this is to stop trying to do what you're trying to do. Arrays are not copyable or assignable.

In all honesty I didn't even know you could try to do something like this. It seems that the compiler is basically freaking the hell out. That doesn't surprise me. I don't know exactly why but I do know this will simply never work.

You should be able to, on the other hand, contain a boost::array without difficulty.

typedef boost::array<double,2> point;

You should look in the documentation to be sure I'm correct but I'm pretty sure this type is assignable and copy-constructable.

Noah Roberts
A: 

Use a struct or static array class like boost::array to contain the doubles.

DeadMG
+7  A: 

You can't do that. As mentioned, arrays are not copyable or assignable which are requirements for std::vector. I would recommend this:

#include <vector>
struct point {
    double x;
    double y;
};

int main() {
     std::vector<point> v;
}

It will read better anyway since you can do things like:

put(v[0].x, v[0].y, value);

which makes it more obvious this the vector contains points (coordinates?)

Evan Teran
+2  A: 

Just to give an alternative solution, you can also use a pair of double:

#include <vector>
#include <utility>

typedef std::pair<double, double> point;

int main()
{
    std::vector<point> x;
    x.push_back(std::make_pair(3.0, 4.0));
}

But a struct or class named point is probably the best solution.

FredOverflow