包装std::忽略
Wrapping std::ignore
我正在开发一个自定义库。到目前为止,我已经将std::tuple和std::tie打包到我自己的myOwn::tuple和myOwn::tie中。它们的作用与std::tuple和std::tie相同。我想对std::ignore做一些类似的事情。
到目前为止,我已经写了以下内容:
namespace myOwn
{
auto
tilde()
-> decltype(std::ignore)
{
return std::ignore;
}
}
我唯一的问题是,我现在必须使用带括号的myOwn::tilde()。我希望能够将其用作myOwn::波浪号。到目前为止,我在std::ignore上读到的只是如何使用它,
这里:std::ignore 的可能实现
此处:std的要求::忽略
这里:C++:返回std::tie与std::ignore 的类型
我试过使用
typedef std::ignore tilde
但这并不成功。如有任何帮助,我们将不胜感激。这个问题可能对其他试图包装对象的人有用。
如果您不需要修改std::ignore
,只想重命名它,那么
decltype(std::ignore) &tilde = std::ignore;
在命名空间范围应该做您需要的事情。
std::ignore
不能保证是DefaultConstructible
或CopyAssignable
,所以它不能被可移植地构建或复制,但我们可以保存对它的引用。这个tilde
的类型是decltype(std::ignore) &
,但由于std::tie
接受引用,所以它的功能应该与std::ignore
相同。
相关文章:
- 警告:忽略模板参数上的属性..在 std::unique_ptr (-wignore 属性)的声明中
- 为什么 std::optional 的强制转换运算符被忽略了
- std::stod 忽略小数位后的非数值
- 如何对忽略某些数字的 std::vector 进行排序?
- 为什么std :: istream ::忽略丢弃字符
- STD :: Ostream忽略了通过setf()在基础上设置的十六进制标志
- std::wistringstream在解析时可以忽略字符串中的空格吗
- 为什么在空流上呼叫时,std :: istream ::忽略不返回
- C 构建器忽略了STD ::修复了大数字
- C++候选模板 将 lambda 作为 std::function 的参数传递时忽略错误
- std::忽略编译器错误的解释
- 忽略模板特殊化并显式使用未特定化模板 (std::vector<bool>)
- 为什么 std::istream_iterator 忽略换行符?
- swig 对基类 'std::string' 一无所知,被忽略
- 尝试通过CGAL_CXX_FLAGS设置 --std=c++0x 或 -std=gnu++0x 会忽略值
- 忽略了 NULL 之后的 std::cout 中的参数
- 如何忽略std::cin中的非字母
- 包装std::忽略
- 忽略std::的需求
- Std::locale按特定字符分割字符串而不忽略它