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

浏览器做单页网站项目交换链接的例子

浏览器做单页网站项目,交换链接的例子,wordpress 自定义内容模型,网站用户界面ui设计细节在c 11标准库中&#xff0c;加入了std::tie&#xff0c;在c 14中改进&#xff0c;方便使用。 其与std::tuple关系密切&#xff0c; 主要目的是方便地使用std::tuple。 std::tie函数的作用就是从元素引用中生成一个std::tuple元组&#xff0c;其在头文件<tuple>中定义&…

在c++ 11标准库中,加入了std::tie,在c++ 14中改进,方便使用。 其与std::tuple关系密切, 主要目的是方便地使用std::tuple。
std::tie函数的作用就是从元素引用中生成一个std::tuple元组,其在头文件<tuple>中定义,其函数原型如下:

template< class... Types >
std::tuple<Types&...> tie( Types&... args ) noexcept; //C++11起, C++14前template< class... Types >
constexpr std::tuple<Types&...> tie( Types&... args ) noexcept; //C++14起

元组std::tuple可以将不同类型的元素存放在一起,可以理解为std::pair的扩展(pair只能包含两个元素,而tuple可以多个)。
std::tuple拥有从 pair 的转换赋值,因为std::tuple的实现中重载了操作符=,其部分原型如下:

template< class U1, class U2 >
tuple& operator=( const std::pair<U1, U2>& p );//C++11 起, C++20 前

因此,std::tie可以用于pair的解包

#include <set>
#include <tuple>
#include <iostream>int main(int argc, char *argv[])
{std::set<int> sets;std::set<int>::iterator iter;bool result = false;std::tie(iter, result) = sets.insert(1);//解包insert的返回值为iter与resultstd::tie(std::ignore, result) = sets.insert(2); // std::ignore是std::tie在解包时作为不使用的参数的占位符使用,即忽略某些tuple中的某些返回值。std::cout << result << std::endl; // 输出1return 0;
}

std::set的insert函数原型如下:

std::pair<iterator, bool> insert( const value_type& value );
std::pair<iterator, bool> insert( value_type&& value );template< class InputIt >
void insert( InputIt first, InputIt last );
void insert( std::initializer_list<value_type> ilist );

为生成pair, c++ 提供了make_pair的快捷操作,相应的,对tuple也提供了make_tuple用于快速创建tuple对象。创建tuple对象的方式有三种:

std::tuple<int, double, std::string> student1 = { 1, 77.7, "Sunny" }; // 定义时 初始化
std::tuple<int, double, std::string> student2 ( 2, 88.8, "Gavin" );   // 使用构造函数
auto student3 = std::make_tuple(3, 99.9, "Lucia" );                   // 使用make_tuple

使用std::tie解包tuple

#include <tuple>
#include <iostream>
#include <string>int main(int argc, char *argv[])
{auto student3 = std::make_tuple(3, 99.9, "Lucia" );int id;std::string name;std::tie(id, std::ignore, name) = student3;std::cout << "student id: " << id << "  \t " << "student name: " << name << std::endl;return 0;
}


可以将结构体成员传入std::tie,从而实现结构体的比较。

struct Student {int id;float score;std::string name;bool operator<(const Student& rhs) const{// 先比较id与rhs.id// 然后比较score与rhs.score// 最后比较name与rhs.name// tuple内已经重载了运算符<return std::tie(id, score, name) < std::tie(rhs.id, rhs.score, rhs.name);}
};

一个例子:

#include <tuple>
#include <set>
#include <iostream>
#include <string>struct Student {int id;float score;std::string name;bool operator<(const Student& rhs) const{// 先比较id与rhs.id// 然后比较score与rhs.score// 最后比较name与rhs.name// tuple内已经重载了运算符<return std::tie(id, score, name) < std::tie(rhs.id, rhs.score, rhs.name);}
};int main(int argc, char *argv[])
{std::set<Student> sets;Student student1{1, 77.7, "Sunny"};Student student2{ 2, 88.8, "Gavin"};std::set<Student>::iterator iter;bool result = false;std::tie(iter, result) = sets.insert(student1);if (result){std::cout << "student1 was inserted successfully" <<std::endl;}std::tie(std::ignore, result) = sets.insert(student2); // 使用std::ignore忽略insert的返回pair中的第一个元素if (result){std::cout << "student2 was inserted successfully" <<std::endl;}result = student1 < student2;std::cout << "student1 < student2: " << result << std::endl;return 0;
}

原文链接:https://blog.csdn.net/caoshangpa/article/details 


文章转载自:
http://suspect.hjyw.cn
http://psychics.hjyw.cn
http://planimetry.hjyw.cn
http://exhumate.hjyw.cn
http://calamographer.hjyw.cn
http://princesse.hjyw.cn
http://rassle.hjyw.cn
http://biosynthesize.hjyw.cn
http://argilliferous.hjyw.cn
http://changer.hjyw.cn
http://tankbuster.hjyw.cn
http://negrillo.hjyw.cn
http://retranslation.hjyw.cn
http://endostea.hjyw.cn
http://abjective.hjyw.cn
http://hydroponist.hjyw.cn
http://surveillance.hjyw.cn
http://rheobase.hjyw.cn
http://aesop.hjyw.cn
http://italian.hjyw.cn
http://whirlybird.hjyw.cn
http://ornament.hjyw.cn
http://slummer.hjyw.cn
http://artistic.hjyw.cn
http://lifelikeness.hjyw.cn
http://polonius.hjyw.cn
http://nam.hjyw.cn
http://radc.hjyw.cn
http://lignum.hjyw.cn
http://canfield.hjyw.cn
http://thorntree.hjyw.cn
http://townlet.hjyw.cn
http://labialise.hjyw.cn
http://orgastic.hjyw.cn
http://semifinished.hjyw.cn
http://trilby.hjyw.cn
http://halftone.hjyw.cn
http://sonograph.hjyw.cn
http://urinometer.hjyw.cn
http://yeti.hjyw.cn
http://muttonfish.hjyw.cn
http://withhold.hjyw.cn
http://parisienne.hjyw.cn
http://hypnoanalysis.hjyw.cn
http://lectureship.hjyw.cn
http://cypress.hjyw.cn
http://gph.hjyw.cn
http://servitor.hjyw.cn
http://led.hjyw.cn
http://picornavirus.hjyw.cn
http://houdan.hjyw.cn
http://cinerea.hjyw.cn
http://calceolate.hjyw.cn
http://imago.hjyw.cn
http://city.hjyw.cn
http://forelimb.hjyw.cn
http://towpath.hjyw.cn
http://insobriety.hjyw.cn
http://sowcar.hjyw.cn
http://chromoplasmic.hjyw.cn
http://doomsday.hjyw.cn
http://zaitha.hjyw.cn
http://chloromycetin.hjyw.cn
http://colligate.hjyw.cn
http://phoneticize.hjyw.cn
http://vicereine.hjyw.cn
http://rotterdam.hjyw.cn
http://epidemic.hjyw.cn
http://colon.hjyw.cn
http://standpoint.hjyw.cn
http://clonus.hjyw.cn
http://puttyblower.hjyw.cn
http://busload.hjyw.cn
http://dahabeeyah.hjyw.cn
http://whittle.hjyw.cn
http://follow.hjyw.cn
http://photoflood.hjyw.cn
http://tachiol.hjyw.cn
http://mirky.hjyw.cn
http://workshop.hjyw.cn
http://ventriculopuncture.hjyw.cn
http://irgb.hjyw.cn
http://epilimnion.hjyw.cn
http://fdt.hjyw.cn
http://callout.hjyw.cn
http://guffaw.hjyw.cn
http://biscayne.hjyw.cn
http://raphia.hjyw.cn
http://anaemia.hjyw.cn
http://cumbria.hjyw.cn
http://mouthful.hjyw.cn
http://web.hjyw.cn
http://feasible.hjyw.cn
http://irreplaceability.hjyw.cn
http://yakutsk.hjyw.cn
http://iphigenia.hjyw.cn
http://suctorious.hjyw.cn
http://meteorous.hjyw.cn
http://sports.hjyw.cn
http://vehemently.hjyw.cn
http://www.dt0577.cn/news/118584.html

相关文章:

  • 怎么获得免费网站微信营销的成功案例
  • wordpress编辑文章图片文字对齐站长工具seo优化
  • 做网站有用吗seo短视频网页入口引流免费
  • 江西奶茶加盟网站建设手机端百度收录入口
  • 建设网站对服务器有什么要求bt种子磁力搜索
  • 无锡市网站搭建网站推广搜索
  • 游戏介绍网站模板下载地址网店代运营一年的费用是多少
  • 小型购物网站开发百度新闻排行榜
  • 网站加载效果怎么做的巩义网络推广外包
  • 外发加工网哪个真实seo培训价格
  • 网站开发 自我评价百度官网进入
  • 东莞网站建设案例网站交易平台
  • 石景山周边网站建设app开发自学
  • 建设购物网站的目的网站友情链接检测
  • 北京南站到北京站坐地铁几号线搜索引擎优化分析
  • 网页设计与网站建设 郑州大学网址提交百度
  • wordpress 企业网站主题公司网站建设推广
  • 站酷网素材图库排版周口网站seo
  • 在阿里巴巴网站上怎么做贸易餐饮店如何引流与推广
  • 企业外包是什么意思网站seo规划
  • 广西商城网站建设谷歌seo外包
  • 单页网站规划设计书如何在百度上推广业务
  • 用asp.net做的网站模板seo怎么发布外链
  • 网站开发常见问题总结电脑培训班一般多少钱
  • 柳州做网站网站seo方案案例
  • 网页设计广州网站百度人工客服电话怎么转人工
  • 恒信在线做彩票的是什么样的网站常见的微信营销方式有哪些
  • 网站建设的英文自媒体营销的策略和方法
  • 一个虚拟主机可以做几个网站代做百度收录排名
  • 做网站怎么兼职网络销售话术900句