[llvm-bugs] [Bug 42879] New: Candidate template ignored: invalid explicitly-specified argument for template parameter
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Aug 3 07:30:33 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42879
Bug ID: 42879
Summary: Candidate template ignored: invalid
explicitly-specified argument for template parameter
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: m at mikaelsimonsson.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
The following code fails to compile with Clang but compiles with GCC (since
7.1). Clang wants a value for the defaulted template parameter Capacity.
#include <cstddef>
template <typename T, size_t Capacity = 10>
class smallvector {
public:
smallvector(const T*, size_t);
};
template <typename T>
class span {
public:
span(const T*, size_t);
};
class str {
public:
str(const char* data, size_t size) : data_{data}, size_{size} {}
template <template <typename> typename Container>
Container<const char> to_container() {
return {data_, size_};
}
private:
const char* data_;
size_t size_;
};
void to_span(str& s) {
s.to_container<span>(); // This works.
}
void to_smallvector(str& s) {
s.to_container<smallvector>(); // This doesn't work.
}
<source>:34:7: error: no matching member function for call to 'to_container'
s.to_container<smallvector>();
~~^~~~~~~~~~~~~~~~~~~~~~~~~
<source>:20:27: note: candidate template ignored: invalid explicitly-specified
argument for template parameter 'Container'
Container<const char> to_container() {
^
1 error generated.
Tested with clang version 10.0.0 (trunk 367740) and -std=c++17.
--
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/20190803/511afde1/attachment.html>
More information about the llvm-bugs
mailing list