Why is this default template parameter not allowed?

谁说我不能喝 提交于 2019-12-04 05:16:28

I think that you need to write:

AlignedMemory<> blah(512, 512);

See 14.3 [temp.arg] / 4:

When default template-arguments are used, a template-argument list can be empty. In that case the empty <> brackets shall still be used as the template-argument-list.

Your syntax is wrong:

AlignedMemory blah(512, 512); //wrong syntax

Correct syntax is this:

AlignedMemory<> blah(512, 512); //this uses "void" as default type!

The error message itself gives this hint. Look at it again:

src/cpfs/entry.cpp:438: error: missing template arguments before ‘buf’

PS: I'm sure 'buf' is a typo. You wanted to write 'blah' - the name of your variable!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!