vendredi 1 avril 2016

Partial class template specialization c++11

I am trying to compile the below code, but I am getting the error:

wrong number of template arguments

template<int start, int end, int step>
struct range{};

template<int start, int end>
struct range<start, end, 1>{};

template<int end>
struct range<0, end, 1>{};

int main() {
    auto r1 = range<0, 5, 2>{};
    auto r2 = range<5, 15>{}; //error: wrong number of template arguments
    auto r3 = range<10>{}; //error: wrong number of template arguments
}

How can I create partial template class object?

Aucun commentaire:

Enregistrer un commentaire