Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comparing arrays of different size

I am implementing my own boost::array variant for fun and education, and I was just wondering: should comparing two arrays of different size yield false, or should it be a type error?

array<int, 3> a = {1, 2, 3};
array<int, 5> b = {1, 2, 3, 4, 5};

a == b   // <--- false or type error?
like image 714
fredoverflow Avatar asked Jan 31 '11 16:01

fredoverflow


1 Answers

It should be a type-error. People that use boost::array choose it over std::vector because they want evaluation (and failure) at compile-time rather than run-time.

like image 95
Björn Pollex Avatar answered Sep 21 '22 14:09

Björn Pollex