Templates und Enums



  • Hallo,

    warum ist das folgende nicht möglich?

    #include <iostream>
    #include <array>
    
    enum Bar {
    	A,B,C
    };
    
    template <Bar b>
    using Foo = std::array<int, b>;
    
    template <Bar b>
    void test(Foo<b> const& f) {
    }
    
    int main() {
    	test(Foo<A>());
    }
    

    Compiler:

    ./test.cpp:16:2: error: no matching function for call to 'test'
            test(Foo<A>());
            ^~~~
    ./test.cpp:12:6: note: candidate template ignored: substitution failure
    void test(Foo<b> const& f) {
         ^
    1 error generated.
    

Anmelden zum Antworten