[llvm-bugs] [Bug 43944] New: Clang (front end) errors on variadic template operator=
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 8 08:55:02 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=43944
Bug ID: 43944
Summary: Clang (front end) errors on variadic template
operator=
Product: new-bugs
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: davidfink314 at gmail.com
CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org
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:
https://godbolt.org/z/cqqnCb
<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()};
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191108/ca4e99d2/attachment-0001.html>
More information about the llvm-bugs
mailing list