Commit ec16b8a7 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

forbid overriding sfinae in Function

Summary: By using a clever trick which "absorbs" attempts to force types for what should be subject to sfinae.

Reviewed By: luciang

Differential Revision: D34160080

fbshipit-source-id: a370c0240088cc78b8760e9f5736c3224842ae04
parent 24bbd6d6
......@@ -847,7 +847,10 @@ class Function final : private detail::function::FunctionTraits<FunctionType> {
* overload from being selected by overload resolution when `fun` is not a
* compatible function.
*/
template <typename Fun, bool Nx = noexcept(Function(FOLLY_DECLVAL(Fun&&)))>
template <
typename Fun,
typename...,
bool Nx = noexcept(Function(FOLLY_DECLVAL(Fun&&)))>
Function& operator=(Fun fun) noexcept(Nx) {
// Doing this in place is more efficient when we can do so safely.
if (Nx) {
......@@ -867,6 +870,7 @@ class Function final : private detail::function::FunctionTraits<FunctionType> {
*/
template <
typename Signature,
typename...,
typename = typename Traits::template IfSafeResult<Function<Signature>>>
Function& operator=(Function<Signature>&& that) noexcept(
noexcept(Function(std::move(that)))) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment