有时需要将空类型传递给某个模板.例如:
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<>();
原文地址:https://www.jb51.cc/c/111290.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。