Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

template <size_t size, typename ...Params>
void doStuff(Params...) {
}

template <>
void doStuff<size_t(1), int, bool>(int, bool) {

}

int main(int, char**) {
    doStuff<1,int,bool>(1, false);
    return 0;
}

This doesn't compile, the second doStuff declaration gives me error: template-id ‘doStuff<1u, int, bool>’ for ‘void doStuff(int, bool)’ does not match any template declaration but it clearly matches the first declaration with variadic template arguments.

How to specialize variadic templates?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
603 views
Welcome To Ask or Share your Answers For Others

1 Answer

The syntax is correct (afaik, and clang++ accepts it), but your compiler is probably just not up2date yet.

If you use gcc, its variadic template support is quite incomplete, and even very recent svn versions don't support specialization yet (That is just how it is when you use bleeding edge technology, and sadly gcc implemented only a very early incomplete variadic template proposal and since then didn't keep up much, while clang started pretty late, but got pretty complete)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...