This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/80841] New: Fails to match template specialization with polymorphic non-type template argument
- From: "cipherjason at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 20 May 2017 14:21:04 +0000
- Subject: [Bug c++/80841] New: Fails to match template specialization with polymorphic non-type template argument
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80841
Bug ID: 80841
Summary: Fails to match template specialization with
polymorphic non-type template argument
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: cipherjason at hotmail dot com
Target Milestone: ---
This code fails to match the specialization of MaybeDestruct:
#include <iostream>
template <class T, T X>
struct Just;
template <class T, template <T> class Fjust, class Maybe>
struct MaybeDestruct;
template <class T, template <T> class Fjust, T X>
struct MaybeDestruct<T, Fjust, Just<T, X>> {
using result = typename Fjust<X>::result;
};
template <const double& X>
struct Number {
using result = Just<const double&, X>;
};
static constexpr double input = 2.0;
int main() {
using result = typename MaybeDestruct<const double&, Number, Just<const
double&, input>>::result;
}
If the use of template parameter T is stripped out then it seems to work:
#include <iostream>
template <const double& X>
struct Just;
template <template <const double&> class Fjust, class Maybe>
struct MaybeDestruct;
template <template <const double&> class Fjust, const double& X>
struct MaybeDestruct<Fjust, Just<X>> {
using result = typename Fjust<X>::result;
};
template <const double& X>
struct Number {
using result = Just<X>;
};
static constexpr double input = 2.0;
int main() {
using result = typename MaybeDestruct<Number, Just<input>>::result;
}