Tag dispatch for enqueue/dequeue implementation
authorChao Yang <chaoyc@fb.com>
Thu, 30 Apr 2015 18:26:23 +0000 (11:26 -0700)
committerPraveen Kumar Ramakrishnan <praveenr@fb.com>
Tue, 12 May 2015 00:01:29 +0000 (17:01 -0700)
commit5623085aabacd5ded93e98f06ba0779133457ad6
treeadc5ec18eb33ea90d02458ab5b1192de88d5d060
parentc7138e7ca18e6cfcc833e26ac3910fab44c80694
Tag dispatch for enqueue/dequeue implementation

Summary:
clang (>=3.6?) reports potential object slicing bug when MPMCQueue is used for
polymorphic class as the queue item, e.g. as in P19814469. This can be false
positive however, since the choice is based on the type trait already.  This
diff uses tag dispatch to selectively compile the overload that will be
executed, therefore if there is no-throw move ctor supplied clang will not
examine the simulated relocation code.

This doesn't avoid object slicing bug however if the client insists to use
MPMCQueue to hold base class while enqueue and dequeue with subclassed item.

Test Plan: compile with --clang

Reviewed By: tudorb@fb.com

Subscribers: folly-diffs@, yfeldblum, chalfant

FB internal diff: D2029949

Signature: t1:2029949:1430264357:af479117adf90bc1915c071e7376a30aacb72f46
folly/MPMCQueue.h