Same as get_ptr() but for references. If the type is incompatible it throws (get_ptr() returns null). Implemented in terms of get_ptr().