This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] std::tr1::array testsuite additions, first attempt


> *************** namespace tr1
> *** 161,167 ****
>    template<typename _Tp, size_t _Nm>
>      bool 
>      operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
> !    { return false; }
>   
>    template<typename _Tp, size_t _Nm>
>      bool 
> --- 164,174 ----
>    template<typename _Tp, size_t _Nm>
>      bool 
>      operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
> !    { 
> !      bool __ret = __one.size() == __two.size();
> !      __ret &= std::equal(__one.begin(), __one.end(), __two.begin());
> !      return __ret;
> !    }
>   
>    template<typename _Tp, size_t _Nm>
>      bool 

Benjamin, is the size comparison pointless here, since both arrays have
the same _Nm ?

If it is needed, then the call to std::equal will go off the end of two
if two.size() < one.size() because it's called whether or not the sizes
are the same. Could use && to short circuit, but I think this is OK:

    return std::equal(__one.begin(), __one.end(), __two.begin());

Not finished my coffee yet, so apologies if I'm missing something!

jon


-- 
"We should forget about small efficiencies, say about 97% of the time:
 premature optimization is the root of all evil."
	- Donald Knuth (paraphrasing Tony Hoare)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]