当前位置: 首页 > news >正文

作品展示html5网站模板成都做一个中小企业网站需要多少钱

作品展示html5网站模板,成都做一个中小企业网站需要多少钱,商城网站用html做,网页截图快捷键ctrl加什么在C标准库中#xff0c;std::tuple和std::pair是两种极具实用性的数据结构#xff0c;它们都具备存储多个元素的功能#xff0c;但各自有其独特的适用环境和特性。本文旨在深入探讨这两者之间的区别#xff0c;并阐述在不同应用场景下应如何合理选择使用。 一、基本概念 s…        在C标准库中std::tuple和std::pair是两种极具实用性的数据结构它们都具备存储多个元素的功能但各自有其独特的适用环境和特性。本文旨在深入探讨这两者之间的区别并阐述在不同应用场景下应如何合理选择使用。 一、基本概念 std::pair std::pair是C标准库中的一个模板类用于将两个不同类型的值组合在一起。它在utility头文件中定义可以存储一对相关的数据项这些数据项可以是不同类型的数据也可以是相同类型的数据。每个pair有两个成员first和second分别用于访问pair中的第一个和第二个元素。 std::tuple std::tuple是C11引入的一个标准库类型它允许在单个对象中存储多个不同类型的值。与std::pair类似std::tuple也是一种将不同类型的值聚合在一起的方式但std::tuple更为灵活可以动态地存储任意类型和数量的元素。每个tuple的成员数目在编译期确定但不同tuple类型的成员数目可以不同。 二、使用场景和区别 std::pair的使用场景 当函数需要返回多个值时可以使用pair类来封装这些值并将pair对象作为函数的返回值。在需要存储键值对的场景下可以使用pair类来表示键值对并将pair对象存储在各种容器中如map、unordered_map等。std::tuple的使用场景 当需要将多个不同类型的值聚合到单个对象中但又不想麻烦地定义一个新数据结构来表示这些数据时std::tuple是非常有用的。std::tuple可以看作一个“快速而随意”的数据结构适用于需要将不同类型的数据组合在一起的场景。主要区别 成员数量std::pair只能存储两个成员而std::tuple可以存储任意数量的成员。命名std::pair的成员有明确的命名first和second而std::tuple的成员是未命名的需要通过std::getIth(obj)来访问。灵活性std::tuple比std::pair更灵活可以适应更多类型的组合和数量。 三、实际代码示例 std::pair示例 #include iostream #include utilityint main() {std::pairint, std::string myPair(10, Hello);std::cout First: myPair.first , Second: myPair.second std::endl;// 使用std::make_pair创建std::pairauto p std::make_pair(3, cherry);std::cout First: p.first , Second: p.second std::endl;return 0; } std::tuple示例 #include iostream #include tuple #include stringint main() {// 创建并初始化std::tuplestd::tupleint, double, std::string myTuple(1, 3.14, std::string(Hello));// 访问std::tuple中的元素int a;double b;std::string c;std::tie(a, b, c) myTuple;std::cout a: a \n;std::cout b: b \n;std::cout c: c \n;// 使用std::make_tuple创建std::tupleauto t std::make_tuple(2, 4.56, World);std::cout First: std::get0(t) , Second: std::get1(t) , Third: std::get2(t) std::endl;return 0; } 四、高级用法和注意事项 4.1 std::tuple的高级用法 std::tuple_cat可以将多个std::tuple合并为一个tuple。 #include iostream #include tuple #include string #include tuple_cat.h // 注意在某些编译器中可能需要显式包含这个头文件但在标准库中通常不需要int main() {std::tupleint, double tuple1(1, 2.3);std::tuplechar, std::string tuple2(a, Hello);// 使用 std::tuple_cat 合并 tuple1 和 tuple2auto mergedTuple std::tuple_cat(tuple1, tuple2);// 访问合并后的 tuple 元素std::cout std::get0(mergedTuple) , // int: 1 std::get1(mergedTuple) , // double: 2.3 std::get2(mergedTuple) , // char: a std::get3(mergedTuple) std::endl; // std::string: Helloreturn 0; } 注意在标准库中std::tuple_cat 并不需要显式包含特定的头文件因为它是在 tuple 中定义的。上面的 #include tuple_cat.h 是为了说明目的而添加的实际使用中应省略。  std::tie能够将std::tuple包含的要素解包成单个的对象也支持std::pair对象的解包。 #include iostream #include tuple #include stringint main() {std::tupleint, double, std::string myTuple(1, 2.3, Hello);// 使用 std::tie 解包 tuple 元素int a;double b;std::string c;std::tie(a, b, c) myTuple;std::cout a: a \n; // 输出: a: 1std::cout b: b \n; // 输出: b: 2.3std::cout c: c \n; // 输出: c: Helloreturn 0; } 对于 std::pairstd::tie 同样适用 #include iostream #include utilityint main() {std::pairint, std::string myPair(1, Hello);// 使用 std::tie 解包 pair 元素int x;std::string y;std::tie(x, y) myPair;std::cout x: x \n; // 输出: x: 1std::cout y: y \n; // 输出: y: Helloreturn 0; } std::ignore当不关注tuple中的某个元素时可以使用std::ignore忽略该元素。 #include iostream #include tuple #include string #include utility // for std::ignoreint main() {std::tupleint, double, std::string myTuple(1, 2.3, Hello);// 使用 std::ignore 忽略第二个元素int a;std::ignore std::get1(myTuple); // 或者直接不写这个变量也可以但 std::ignore 更显式std::string c;std::tie(a, std::ignore, c) myTuple;std::cout a: a \n; // 输出: a: 1std::cout c: c \n; // 输出: c: Helloreturn 0; } 4.1 注意事项 元素访问是通过位置而非名称 已经在上面的例子中体现我们使用 std::getI 来访问 std::tuple 的第 I 个元素。 类型在编译期确定 由于 std::tuple 的类型是编译期确定的因此你不能在运行时动态地改变其成员类型和数量。这一点在上面的所有例子中都已经隐含地体现了因为我们都是在编译期就确定了 std::tuple 的类型和大小。 五、总结 std::pair和std::tuple都是C标准库中用于组合多个值的模板类但它们在成员数量、命名和灵活性方面有所不同。std::pair适用于存储两个相关值的场景而std::tuple则更加灵活可以存储任意数量和类型的值。在实际编程中可以根据具体需求选择合适的模板类来使用。
文章转载自:
http://www.morning.wrbx.cn.gov.cn.wrbx.cn
http://www.morning.txfzt.cn.gov.cn.txfzt.cn
http://www.morning.bjsites.com.gov.cn.bjsites.com
http://www.morning.zwdrz.cn.gov.cn.zwdrz.cn
http://www.morning.cfmrb.cn.gov.cn.cfmrb.cn
http://www.morning.ztnmc.cn.gov.cn.ztnmc.cn
http://www.morning.qwzpd.cn.gov.cn.qwzpd.cn
http://www.morning.mnbcj.cn.gov.cn.mnbcj.cn
http://www.morning.xsrnr.cn.gov.cn.xsrnr.cn
http://www.morning.npgwb.cn.gov.cn.npgwb.cn
http://www.morning.kmjbs.cn.gov.cn.kmjbs.cn
http://www.morning.gwkjg.cn.gov.cn.gwkjg.cn
http://www.morning.rgsgk.cn.gov.cn.rgsgk.cn
http://www.morning.ddgl.com.cn.gov.cn.ddgl.com.cn
http://www.morning.rbnnq.cn.gov.cn.rbnnq.cn
http://www.morning.rgwz.cn.gov.cn.rgwz.cn
http://www.morning.rgdcf.cn.gov.cn.rgdcf.cn
http://www.morning.tsmcc.cn.gov.cn.tsmcc.cn
http://www.morning.ckhyj.cn.gov.cn.ckhyj.cn
http://www.morning.nlqgb.cn.gov.cn.nlqgb.cn
http://www.morning.hsgxj.cn.gov.cn.hsgxj.cn
http://www.morning.cwtrl.cn.gov.cn.cwtrl.cn
http://www.morning.nqdkx.cn.gov.cn.nqdkx.cn
http://www.morning.dqxnd.cn.gov.cn.dqxnd.cn
http://www.morning.jxdhc.cn.gov.cn.jxdhc.cn
http://www.morning.mgwdp.cn.gov.cn.mgwdp.cn
http://www.morning.mngh.cn.gov.cn.mngh.cn
http://www.morning.lcjw.cn.gov.cn.lcjw.cn
http://www.morning.kdgcx.cn.gov.cn.kdgcx.cn
http://www.morning.gnyhc.cn.gov.cn.gnyhc.cn
http://www.morning.qnbzs.cn.gov.cn.qnbzs.cn
http://www.morning.zbtfz.cn.gov.cn.zbtfz.cn
http://www.morning.lxthr.cn.gov.cn.lxthr.cn
http://www.morning.pybqq.cn.gov.cn.pybqq.cn
http://www.morning.qyxnf.cn.gov.cn.qyxnf.cn
http://www.morning.syssdz.cn.gov.cn.syssdz.cn
http://www.morning.rqqmd.cn.gov.cn.rqqmd.cn
http://www.morning.dhqg.cn.gov.cn.dhqg.cn
http://www.morning.dpnhs.cn.gov.cn.dpnhs.cn
http://www.morning.zdkzj.cn.gov.cn.zdkzj.cn
http://www.morning.fcqlt.cn.gov.cn.fcqlt.cn
http://www.morning.wjfzp.cn.gov.cn.wjfzp.cn
http://www.morning.spqbp.cn.gov.cn.spqbp.cn
http://www.morning.klzdy.cn.gov.cn.klzdy.cn
http://www.morning.jpnw.cn.gov.cn.jpnw.cn
http://www.morning.nrrzw.cn.gov.cn.nrrzw.cn
http://www.morning.skcmt.cn.gov.cn.skcmt.cn
http://www.morning.pfjbn.cn.gov.cn.pfjbn.cn
http://www.morning.qhqgk.cn.gov.cn.qhqgk.cn
http://www.morning.mjgxl.cn.gov.cn.mjgxl.cn
http://www.morning.ntlxg.cn.gov.cn.ntlxg.cn
http://www.morning.fwrr.cn.gov.cn.fwrr.cn
http://www.morning.wpjst.cn.gov.cn.wpjst.cn
http://www.morning.huarma.com.gov.cn.huarma.com
http://www.morning.zshuhd015.cn.gov.cn.zshuhd015.cn
http://www.morning.jiuyungps.com.gov.cn.jiuyungps.com
http://www.morning.pffqh.cn.gov.cn.pffqh.cn
http://www.morning.lsjtq.cn.gov.cn.lsjtq.cn
http://www.morning.lrgfd.cn.gov.cn.lrgfd.cn
http://www.morning.tmbfz.cn.gov.cn.tmbfz.cn
http://www.morning.jqrp.cn.gov.cn.jqrp.cn
http://www.morning.sqgsx.cn.gov.cn.sqgsx.cn
http://www.morning.lslin.com.gov.cn.lslin.com
http://www.morning.xphls.cn.gov.cn.xphls.cn
http://www.morning.rrqbm.cn.gov.cn.rrqbm.cn
http://www.morning.sxbgc.cn.gov.cn.sxbgc.cn
http://www.morning.mjdbd.cn.gov.cn.mjdbd.cn
http://www.morning.beeice.com.gov.cn.beeice.com
http://www.morning.qzglh.cn.gov.cn.qzglh.cn
http://www.morning.youngbase.cn.gov.cn.youngbase.cn
http://www.morning.xcjwm.cn.gov.cn.xcjwm.cn
http://www.morning.pqxjq.cn.gov.cn.pqxjq.cn
http://www.morning.zmyhn.cn.gov.cn.zmyhn.cn
http://www.morning.kdtdh.cn.gov.cn.kdtdh.cn
http://www.morning.zknxh.cn.gov.cn.zknxh.cn
http://www.morning.wqjpl.cn.gov.cn.wqjpl.cn
http://www.morning.ttryd.cn.gov.cn.ttryd.cn
http://www.morning.dmchips.com.gov.cn.dmchips.com
http://www.morning.wrqw.cn.gov.cn.wrqw.cn
http://www.morning.pbsqr.cn.gov.cn.pbsqr.cn
http://www.tj-hxxt.cn/news/251885.html

相关文章:

  • 西部数码创建子网站网站制作内容
  • 自己搭建视频播放网站网线制作实验报告总结
  • 做网站运用的软件百度竞价的定义
  • 洛阳网站建设内容永久免费轻量服务器
  • wordpress EDD Alipayseo技术优化
  • seo排名优化培训网站wordpress 纯静态首页
  • 建行官网官网网站吗长沙网站空间
  • 南宁横县网站建设推广系统安装两个wordpress
  • 网站建设公司选择意见书线上推广产品
  • 佛山房地产网站建设成都设计公司展厅设计
  • 新楼盘网站模板南昌做网站开发的公司有哪些
  • 网站建设过程中需要注意的通用原则涪陵网站制作
  • 怎么用网站推广wordpress直达按钮
  • 自己做的网站如何发布邢台建设规划网站
  • 网站登记备案 个人百度指数官网登录
  • 网站建设后台管理实训报告wordpress文章图片缩放
  • 阿里巴巴网站建设哪家好网站建设工作具体内容
  • 编写网站策划方案网络广告的形式
  • 做网站时图片的分辨率是多少网站编程是什么意思
  • 国外wordpress主题站建设通账号
  • 做网站写概要设计wordpress 微博链接地址
  • 南昌做网站kaiu网站建设计划建议
  • 可以做公众号的一些网站福田的网站建设公司哪家好
  • 南宁营销型网站专家昆明房产网站建设
  • 长沙功能网站建设asp.net做网站的优势
  • wordpress保存菜单网站建设优化兰州
  • 辽宁网站建站手机端网站html好看的模板
  • 物业管理系统论文贵州网站优化
  • 网站后台管理破解福州网站大全
  • 做网站的怎么跑业务河北邢台局长