Add an enable_if to the generic IntrusiveRefCntPtr constructors so
that std::is_convertible gives an honest answer when the underlying
pointers cannot be converted.
Details
Diff Detail
Unit Tests
Event Timeline
Looks good - some optional/separate patch suggestions.
llvm/include/llvm/ADT/IntrusiveRefCntPtr.h | ||
---|---|---|
174–178 | Can we collapse this ctor with the const ref version by having just one version that accepts by value? (not 100% sure we can - genuinely asking. I think we can because IntrusiveRefCntPtr has real copy ctor/move ctor above, so we won't end up with infinite recursion where the copy ctor needs to use the copy ctor.. ) | |
llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp | ||
100–138 | Since these are static_asserts, they could just be in the namespace/global scope, rather than being inside a test function. The test function itself does no work when executed, since this is all compile-time checking. I don't mind too much either way, though. |
Thanks for the review! Pushed in 17c584551d573f1693990773e29fbe6b4b6fa4f4.
llvm/include/llvm/ADT/IntrusiveRefCntPtr.h | ||
---|---|---|
174–178 | Nice catch; I added that in. | |
llvm/unittests/ADT/IntrusiveRefCntPtrTest.cpp | ||
100–138 | Yeah, it's a bit cleaner that way. I ended up putting them at namespace scope instead. I stripped it down just to the interesting cases (rejecting) and added an actual unit test for the positive cases. |
Can we collapse this ctor with the const ref version by having just one version that accepts by value? (not 100% sure we can - genuinely asking. I think we can because IntrusiveRefCntPtr has real copy ctor/move ctor above, so we won't end up with infinite recursion where the copy ctor needs to use the copy ctor.. )