[llvm] r342588 - Workaround a limitation of llvm::Any when used with types that have
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 19 13:45:09 PDT 2018
Author: chandlerc
Date: Wed Sep 19 13:45:09 2018
New Revision: 342588
URL: http://llvm.org/viewvc/llvm-project?rev=342588&view=rev
Log:
Workaround a limitation of llvm::Any when used with types that have
a converting constructor from llvm::Any like gmock matchers. This issue
has come up elsewhere as well and the workaround here is being
considered for use in the standard long-term, but we can pretty cheaply
experiment with it to see if anything ends up going wrong.
Modified:
llvm/trunk/include/llvm/ADT/Any.h
Modified: llvm/trunk/include/llvm/ADT/Any.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Any.h?rev=342588&r1=342587&r2=342588&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Any.h (original)
+++ llvm/trunk/include/llvm/ADT/Any.h Wed Sep 19 13:45:09 2018
@@ -65,6 +65,16 @@ public:
typename std::enable_if<
llvm::conjunction<
llvm::negation<std::is_same<typename std::decay<T>::type, Any>>,
+ // We also disable this overload when an `Any` object can be
+ // converted to the parameter type because in that case, this
+ // constructor may combine with that conversion during overload
+ // resolution for determining copy constructibility, and then
+ // when we try to determine copy constructibility below we may
+ // infinitely recurse. This is being evaluated by the standards
+ // committee as a potential DR in `std::any` as well, but we're
+ // going ahead and adopting it to work-around usage of `Any` with
+ // types that need to be implicitly convertible from an `Any`.
+ llvm::negation<std::is_convertible<Any, typename std::decay<T>::type>>,
std::is_copy_constructible<typename std::decay<T>::type>>::value,
int>::type = 0>
Any(T &&Value) {
More information about the llvm-commits
mailing list