[llvm-bugs] [Bug 45048] New: Candidate template shouldn't have been ignored
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Feb 27 09:16:07 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=45048
Bug ID: 45048
Summary: Candidate template shouldn't have been ignored
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: szilardszaloki at gmail.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
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
--
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/20200227/55fe2342/attachment-0001.html>
More information about the llvm-bugs
mailing list