c – 标准库中的空类型

c – 标准库中的空类型,第1张

概述有时需要将空类型传递给某个模板.例如: template <typename X, typename Y> struct BoundaryConditions { X x; Y y; BoundaryConditions(typename X::init xi, typename Y::init yi) : x(xi), y(yi) { ... }}; 我们可能希望实现不带 有时需要将空类型传递给某个模板.例如:
template <typename X,typename Y> struct BoundaryConditions {  X x; Y y;  BoundaryConditions(typename X::init xi,typename Y::init yi) : x(xi),y(yi) {    ...  }};

我们可能希望实现不带任何参数的自由边界条件.使用类型检查实现这样的事情非常容易:

struct nothing {};nothing nothing = nothing();struct Free {  typedef nothing init;  ...};BoundaryConditions<Free,Fixed> foo(nothing,100);

所以我的问题是:在标准库或者提升中是否有类似我的“nothing”类型的实现?

解决方法 你可以使用空 tuple.像std :: tuple<>(); 总结

以上是内存溢出为你收集整理的c – 标准库中的空类型全部内容,希望文章能够帮你解决c – 标准库中的空类型所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1255988.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存