<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 fails to deduce the most specialized template definition when it's partialy specialized with multiple template template parameters"
href="https://bugs.llvm.org/show_bug.cgi?id=38044">38044</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang fails to deduce the most specialized template definition when it's partialy specialized with multiple template template parameters
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>michaelroynard@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>I was doing simple metaprogramming recently and wanted to code the "front"
helper: get the first type of a type list.
So I experimented on wandbox this code :
#include <type_traits>
template <typename... Ts>
struct type_list {
static constexpr std::size_t size = sizeof...(Ts);
};
template <typename List, typename = void>
struct front {};
template <template <typename, typename...> class List, typename T, typename...
Ts>
struct front<List<T, Ts...>, std::enable_if_t<(List<T, Ts...>::size > 0)>> {
using type = T;
};
template <typename List>
using front_t = typename front<List>::type;
There's nothing fancy (Please let me know if the code above is not legal C++).
Usage is :
static_assert(std::is_same_v<int, front_t<type_list<int, double>>>);
The problem is when I'm specializing with a template template like this :
template <typename, typename...> class List
Then clang throws it away and doesn't find anything.
However, if I specialize only with :
template <typename...> class List
Then it's fine and clang doesn't throw it away (but it's not ok because I can't
do what I want to do this way).
I think clang is wrong here and should consider this specialization.
It consistently fails since clang 4.0 haven't tested the version before) up
until trunk.
FWIW, both gcc and msvc compile it just fine.
Here's a godbolt repro : <a href="https://godbolt.org/g/M5fgbj">https://godbolt.org/g/M5fgbj</a>
Please let me know if what I'm writing is not legal C++.</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>