How you considered using boost::equal() with a defined predicate. That way you could handle NULL and consider two NULL-pointers at the same position as equal (if that is the desired behavior) and compare the  objects via operator==. That would give a never segfaulting function and the overhead of checking for NULL-pointers is likely acceptable.