<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Clang (front end) errors on variadic template operator="
   href="https://bugs.llvm.org/show_bug.cgi?id=43944">43944</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang (front end) errors on variadic template operator=
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>davidfink314@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Clang determines a variadic template operator= as taking 0 arguments (which it
then errors on, since it requires 1), no matter what arguments are actually
passed.


See godbolt, or the same code below:
<a href="https://godbolt.org/z/cqqnCb">https://godbolt.org/z/cqqnCb</a>


<source>:21:20: error: overloaded 'operator=' must be a binary operator (has 1
parameter)
    decltype(auto) operator=(Args&&... args) {
                   ^
<source>:40:7: note: in instantiation of function template specialization
'mynamespace::vector<C, std::allocator<C> >::operator=<>' requested here
    c.operator=({getc()});





#include <vector>

namespace mynamespace {

template <class T, class Alloc = std::allocator<T>>
class vector : public std::vector<T, Alloc> {
  private:
    using Base = std::vector<T, Alloc>;

  public:
    template <class... Args>
    vector(Args&&... args)
        : Base(std::forward<Args>(args)...) {
    }

    vector(std::initializer_list<T> il)
        : Base(il) {
    }

    template<class... Args>
    decltype(auto) operator=(Args&&... args) {
        Base::operator=(std::forward<Args>(args)...);
        return *this;
    }
};

} /* namespace mynamespace */

struct C {
    int x;
};

C getc();

int main() {
    mynamespace::vector<C> c;
    // works
    c.operator=(mynamespace::vector<C>{getc()});
    //  doesn't work (= template errors on 0 params)
    c.operator=({getc()});
    // also doesn't work
    c = {getc()};
    // also doesn't work
    c = {getc(), getc()};
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>