Fehler C2752: Mehr als eine Teilspezialisierung stimmt mit der Vorlagenargumentliste mit Konzepten übereinC++

Programme in C++. Entwicklerforum
Anonymous
 Fehler C2752: Mehr als eine Teilspezialisierung stimmt mit der Vorlagenargumentliste mit Konzepten überein

Post by Anonymous »

Ist es ein Fehler in MSVC, wenn es mit dem folgenden Fehler fehlschlägt?

Code: Select all

(35): error C2752: 'Power_t': more than one partial specialization matches the template argument list
(18): note: could be 'Power_t'
(30): note: or       'Power_t'
(35): note: the template instantiation context (the oldest one first) is
(37): note: see reference to variable template 'const auto Power_v' being compiled
auf dem folgenden Code:

Code: Select all

#include 
#include  // size_t

template 
concept Multipliable = requires (T a, const T b) {
{ a *= b } -> std::same_as;
{ a * b } -> std::same_as;
};

/// Primary class template declaration (and definition) for odd powers (inductive step)
template 
struct Power_t {
static constexpr auto value = Power_t::value * base;
};

/// Partial specialization for even powers (inductive step)
template 
struct Power_t {
static constexpr auto value = Power_t::value;
};

/// Partial specialization (base case)
template 
struct Power_t {
static constexpr auto value = base;
};

/// Partial specialization (base case)
template 
struct Power_t {
static constexpr auto value = decltype(base){1};
};

template 
constexpr auto Power_v = Power_t::value;

static_assert(Power_v == 1);
static_assert(Power_v == 3);
static_assert(Power_v == 3 * 3);
static_assert(Power_v == 3 * 3 * 3);
static_assert(Power_v == 3 * 3 * 3 * 3);
static_assert(Power_v == 3 * 3 * 3 * 3 * 3);

int main() {
return Power_v;
}
GCC-11 und Clang-11 sind in Ordnung, hier ist der Fehler im Compler Explorer: https://godbolt.org/z/MxobE8Yve
Interessanterweise sind alle Compiler erfolgreich, wenn die Konzeptbeschränkungen entfernt werden:
https://godbolt.org/z/MzYG9n5bP

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post