<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 - Candidate template shouldn't have been ignored"
href="https://bugs.llvm.org/show_bug.cgi?id=45048">45048</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Candidate template shouldn't have been ignored
</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>Windows NT
</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>szilardszaloki@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Hi there,
I was writing a pop_back metafunction and for demonstration purposes, I wanted
to trick the compiler into deducing the result. For the sake of simplicity, I
specialized the implementation to use only std::tuple<>s.
Here's how it goes:
#include <tuple>
#include <type_traits>
#include <utility>
template <typename, std::size_t>
struct wrapper;
template <typename, typename>
struct pop_back_impl;
template <typename... T1s, std::size_t... indices1>
class pop_back_impl<std::tuple<T1s...>, std::index_sequence<indices1...>> {
template <typename>
struct helper;
template <std::size_t... indices2>
struct helper<std::index_sequence<indices2...>> {
template <typename... T2s>
static std::tuple<T2s...> help(wrapper<T2s, indices2> const* const...,
void const* const);
//template <typename T1, typename T2>
//static std::tuple<T1, T2> help(wrapper<T1, 0> const* const,
wrapper<T2, 1> const* const, void const* const);
};
static_assert(sizeof...(T1s));
public:
using type =
decltype(
helper<
std::make_index_sequence<sizeof...(T1s) - 1>
>::help(
static_cast<wrapper<T1s, indices1> const*>(nullptr)...
)
)
;
};
template <typename Tuple>
using pop_back =
typename pop_back_impl<
Tuple,
std::make_index_sequence<std::tuple_size_v<Tuple>>
>::type
;
int main(int const, char const* const []) {
static_assert(std::is_same_v<pop_back<std::tuple<int, char, double>>,
std::tuple<int, char>>);
return 0;
}
I suspect that this should compile, since by the time help<>() gets called,
helper<> has already been instantiated, therefore help<>()'s parameter list
should already be bound by indices2. Also, the two help<>()s are equivalent in
this particular scenario, aren't they, or am I missing something? :)
Thanks,
Szilard</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>