<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/70162>70162</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            ambiguous deduction for template arguments  with std::monostate
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          makotokato
      </td>
    </tr>
</table>

<pre>
    ```c++
#include <utility>
#include <variant>

template <class T> struct Ok {
  T inner;
  Ok(T &&i) : inner(std::move(i)) {}
  template <typename X = T, typename = typename std::enable_if<
 std::is_trivially_copyable<X>::value>::type>
  Ok(T i) : inner(i) {}
 Ok() = default;
};

int main() {
  auto a = Ok(std::monostate());
  return 0;
}
```

When building this C++ source, clang throws the following error.  I test on "Debian clang version 16.0.6 (15)" and "17.0.1" on godbolt.org. gcc 13.2 works well.

```
main.cpp:14:12: error: ambiguous deduction for template arguments of 'Ok'
  auto a = Ok(std::monostate());
 ^
main.cpp:6:3: note: candidate function [with T = std::monostate]
 Ok(T &&i) : inner(std::move(i)) {}
  ^
main.cpp:9:3: note: candidate function [with T = std::monostate, X = std::monostate, $2 = void]
  Ok(T i) : inner(i) {}
  ^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE2P4jgQ_TXFpTRRUiYJHHKgoZH2NBeknVvLcQx4cWzkDxD_fmVDh57tvox6JctxXK-qXj2Xzb1XByNlB_UL1JsZj-FoXTfykw32xIOd9Xa4ddCU9yGAXtIoN1CugJgyQsdBIrB1DEqrcAP2-pX1wp3iJjyteQ5yPGseMkJo7j3ugL2iDy6KgD9PCO0jF-IOlTHSAZt2fp6AFjsEaoAaBbREYKsHihY-DMBWwFajvUigRQJkTPsC7eY9xkcG4XaWho8SfyGwDe6A1jjtpZ3pZ4otDe-1fFN7YOtHyMmm_Ftw6qK41rc3Yc-3BAW2_pVEyIgL11FOfyn6pM9U3ae61KciMvIO2-Ag9zzqMMmUYNM6z8oEHLky705PiXkMFnkOk2N-kNBYH3iQd580nsfgZIjOYPlbyvvivW0-pv_7KA32UelBmQOGo_K4vncVehudkEl2oXk2Onv1GI4S91Zre00e0jnrCsS_MEgf0BoEoo3sFTcPt4t0XlmDVVOURYNAi6rOrAm5GRK8aouyqNKGNXiwQ291KKw7FHgQAitWEF6tO3m8Sq2Lj-z_U1LSsRDnM7BVNU8TpaPKFNOCj706RBs9DnKIIiRWe-ueXcfdIY7SBI92j0Btkr391nFA_fqJWgNsxRIfY4NMX8HNoIZEYB_NnRbUL1cVjrjL-b5IVf_Wbt-8dl-xXP4fLGn9uL1f24DmlM0Xq4ZnSX9w2Z7Up1aYDR0blmzJZ7KrmuWCymVb0ezYSS7b-WJeclo0lah5JalvyrKpmdj3S1bPVEclsaqkupzXdUWFIGqqiteCGj6weQvzUo5c6ULry5g6dKa8j7Jry6qhmea91D6_3URGXjEbgSg95a5LPj_6ePAwL7XywT-jBBW07P6gPTHL_lnUWXS6O4Zw9slAW6DtQYVj7AthR6Btyvj4_Dg7-48UAWibeXqgba7j3wAAAP__1dziDQ">