摘要: 是什么: 包含< variant > std::variant 允许列出变量所有的可能的类型,然后决定它是什么类型 代码示例: int main() { std::variant<std::string,int> value; value="Hello"; value=4; value.index( 阅读全文
posted @ 2024-07-16 10:33 Wzline 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 作用: 用来包装一个可能存在也可能不存在的值 当存在时我们可以选择返回其中内容,不存在时返回空; 代码示例: #include<iostream> #include<optional> #include<string> #include<fstream> std::optional<std::str 阅读全文
posted @ 2024-07-16 09:38 Wzline 阅读(1) 评论(0) 推荐(0) 编辑