Are clang++ and libc++ compatible?

Zhihao Yuan lichray at gmail.com
Wed Nov 13 14:52:36 UTC 2013


On Wed, Nov 13, 2013 at 2:29 AM, Shane Ambler <FreeBSD at shaneware.biz> wrote:
> A possible solution I found looking into this is to wrap the Entry
> reference in a std::unique_ptr - so changing -
> std::deque<Entry> messages;
> to -
> std::deque<std::unique_ptr<Entry>> messages;

This "fix" is wrong.  (Smart) pointers of T have comparison behaviors
different from T itself, so this may silently change a program's runtime
behavior.

A better fix is to use `std::deque<std::vector<Entry>>`.  Both
libstdc++ and libc++ support vector<Incomplete Type>, and
vector<T>'s comparison behavior is as same as T.  And of
course,they both have value semantics.

-- 
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://4bsd.biz/


More information about the freebsd-current mailing list