
It should be intelligent enough to deal with that. mike On Thu, 2007-10-25 at 15:01 -0700, chun ping wang wrote:
hmm the thing is it compares all the array. And len might not be the actual size of the array.
Example you cna have array X. x[0] = 25 x[1] = 12 x[2] = null x[3] = null
On 10/25/07, Michael Linck
wrote: The boost documentation states that the == operator "Compares the stored pointers of the two smart pointers." The phrase "smart pointers" refers to the shared arrays themselves, because that's really all a shared array *is.* So the operation described above is actually equivalent to what you outlined in item 2. of answering your own question. mike
On Thu, 2007-10-25 at 11:22 -0700, chun ping wang wrote: > Hi I notice boost shared_array compares the pointer address not the > pointer themselves. What would be the best way to compare the actual > value of boost shared_array. > > 1.) > shared_array<T> a; > shared_array<T> b; > > > 1.) return (a.len == b.len && (memcmp(a, b, len) == 0)); > > or > > 2.) > if (a.len != b.len) > return false; > for (ptrdiff_t i = 0; i != a.len; ++i) > if(a[i] != b[i]) > return false; > > One that works ALL the times. > > _______________________________________________ > Boost-users mailing list > Boost-users@lists.boost.org > http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users