<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 - The conversion is not fully fixed?"
href="https://bugs.llvm.org/show_bug.cgi?id=37722">37722</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The conversion is not fully fixed?
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>zhonghao@pku.org.cn
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The code is as follow:
template<typename T>
class Thing { };
template<typename T>
class Wrapper {
Thing<T> value;
public:
// If you remove 'explicit', type deduction is performed correctly
explicit operator auto() const {
return value;
}
};
int main() {
Wrapper<int> a;
auto a_view = static_cast<Thing<int>>(a);
return 0;
}
clang++ produces the following messages:
error:
no matching conversion for static_cast from 'Wrapper<int>' to
'Thing<int>'
auto a_view = static_cast<Thing<int>>(a);
^~~~~~~~~~~~~~~~~~~~~~~~~~
1Exampleoftemplatedclasswithexplicitconversiontoanothertemplatedclass.cpp:2:7:
note:
candidate constructor (the implicit copy constructor) not viable: no
known
conversion from 'Wrapper<int>' to 'const Thing<int>' for 1st argument
class Thing { };
^
1Exampleoftemplatedclasswithexplicitconversiontoanothertemplatedclass.cpp:2:7:
note:
candidate constructor (the implicit move constructor) not viable: no
known
conversion from 'Wrapper<int>' to 'Thing<int>' for 1st argument
class Thing { };
^
1Exampleoftemplatedclasswithexplicitconversiontoanothertemplatedclass.cpp:2:7:
note:
candidate constructor (the implicit default constructor) not viable:
requires 0 arguments, but 1 was provided
1 error generated.
The above code compiles fine with g++. The code sample comes from
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - Type deduction failure for explicit conversion operator with auto type"
href="show_bug.cgi?id=35466">https://bugs.llvm.org/show_bug.cgi?id=35466</a>. It reports similar problems.
Perhaps, the reported bug is not fully fixed?</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>