using EnableUnlessSameType =
std::enable_if_t<!std::is_same<remove_cvref_t<CallableT>, ThisT>::value>;
template <typename CallableT, typename Ret, typename... Params>
-using EnableIfCallable =
- std::enable_if_t<std::is_void<Ret>::value ||
- std::is_convertible<decltype(std::declval<CallableT>()(
- std::declval<Params>()...)),
- Ret>::value>;
+using EnableIfCallable = std::enable_if_t<llvm::disjunction<
+ std::is_void<Ret>,
+ std::is_same<decltype(std::declval<CallableT>()(std::declval<Params>()...)),
+ Ret>,
+ std::is_same<const decltype(std::declval<CallableT>()(
+ std::declval<Params>()...)),
+ Ret>,
+ std::is_convertible<decltype(std::declval<CallableT>()(
+ std::declval<Params>()...)),
+ Ret>>::value>;
template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
protected:
unique_function<Templated<Incomplete> *()> IncompleteResultPointer;
}
+// Incomplete function returning an incomplete type
+Incomplete incompleteFunction();
+const Incomplete incompleteFunctionConst();
+
+// Check that we can assign a callable to a unique_function when the
+// callable return value is incomplete.
+TEST(UniqueFunctionTest, IncompleteCallableType) {
+ unique_function<Incomplete()> IncompleteReturnInCallable{incompleteFunction};
+ unique_function<const Incomplete()> IncompleteReturnInCallableConst{
+ incompleteFunctionConst};
+ unique_function<const Incomplete()> IncompleteReturnInCallableConstConversion{
+ incompleteFunction};
+}
+
+// Define the incomplete function
+class Incomplete {};
+Incomplete incompleteFunction() { return {}; }
+const Incomplete incompleteFunctionConst() { return {}; }
+
} // anonymous namespace