[Bug libstdc++/41351] std::rotate on RAI does not conform to ISO complexity requirement

potswa at mac dot com gcc-bugzilla@gcc.gnu.org
Tue Nov 3 17:21:00 GMT 2009



------- Comment #47 from potswa at mac dot com  2009-11-03 17:21 -------
What is the function of the helper class? I suppose the user could get improved
performance by specializing __is_scalar<MyClass>, but that could have
unintended consequences (resulting from the class not being scalar), not to
mention that the user is then modifying nonstandard internals. Furthermore, we
care more about whether it's POD than scalar.

Why not adapt or add a general interface to the test used by __copy_move* in
stl_algo.h?

      const bool __simple = (__is_pod(_ValueTypeI)
                             && __is_pointer<_II>::__value
                             && __is_pointer<_OI>::__value
                             && __are_same<_ValueTypeI, _ValueTypeO>::__value);

This seems to capture the requirements of memmoveÂ… although using copy/move
instead of swap should also be faster for large PODs in eg linked lists.

Anyway, __is_pod being reasonably sufficient for compliant behavior wrt
"complexity of a swap" being known, couldn't we just take patch_draft_2 and
substitute in

              if ( __is_pod(_ValueType) && __k == 1)

I favor this alternative.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41351



More information about the Gcc-bugs mailing list