This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/80841] New: Fails to match template specialization with polymorphic non-type template argument


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;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]