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

做防伪的网站网站域名查询网

做防伪的网站,网站域名查询网,做网站到底需要什么,公司网站建设gghhhj在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://amide.nLkm.cn
http://inviolable.nLkm.cn
http://woodcraft.nLkm.cn
http://inkholder.nLkm.cn
http://soaring.nLkm.cn
http://beatism.nLkm.cn
http://carmine.nLkm.cn
http://folding.nLkm.cn
http://leatherette.nLkm.cn
http://ceresine.nLkm.cn
http://comestible.nLkm.cn
http://iridous.nLkm.cn
http://embattle.nLkm.cn
http://jamming.nLkm.cn
http://inchoation.nLkm.cn
http://akureyri.nLkm.cn
http://reinstallment.nLkm.cn
http://zhdanovism.nLkm.cn
http://predicably.nLkm.cn
http://tpi.nLkm.cn
http://pneumodynamics.nLkm.cn
http://hyperacidity.nLkm.cn
http://kef.nLkm.cn
http://dyscrasia.nLkm.cn
http://trichomycin.nLkm.cn
http://cataleptoid.nLkm.cn
http://polo.nLkm.cn
http://triadelphous.nLkm.cn
http://equivocation.nLkm.cn
http://photoheliograph.nLkm.cn
http://littoral.nLkm.cn
http://linty.nLkm.cn
http://vibriocidal.nLkm.cn
http://dowse.nLkm.cn
http://ichnographically.nLkm.cn
http://photobiology.nLkm.cn
http://tamarack.nLkm.cn
http://stypsis.nLkm.cn
http://gagaku.nLkm.cn
http://dhcp.nLkm.cn
http://barleycorn.nLkm.cn
http://outsmart.nLkm.cn
http://baniyas.nLkm.cn
http://sitzmark.nLkm.cn
http://uncart.nLkm.cn
http://accadian.nLkm.cn
http://lowdown.nLkm.cn
http://hypermotility.nLkm.cn
http://guidance.nLkm.cn
http://wan.nLkm.cn
http://pentacle.nLkm.cn
http://lawcourt.nLkm.cn
http://mucosity.nLkm.cn
http://cosmogenic.nLkm.cn
http://electrocautery.nLkm.cn
http://topgallant.nLkm.cn
http://laurasia.nLkm.cn
http://midge.nLkm.cn
http://encyclopedist.nLkm.cn
http://machisma.nLkm.cn
http://scatback.nLkm.cn
http://gloatingly.nLkm.cn
http://amur.nLkm.cn
http://septavalent.nLkm.cn
http://saturnic.nLkm.cn
http://tindal.nLkm.cn
http://miniplanet.nLkm.cn
http://quadricornous.nLkm.cn
http://andantino.nLkm.cn
http://osseous.nLkm.cn
http://ritual.nLkm.cn
http://flattering.nLkm.cn
http://stenotypist.nLkm.cn
http://inflicter.nLkm.cn
http://puncture.nLkm.cn
http://kamala.nLkm.cn
http://enthusiasm.nLkm.cn
http://breeze.nLkm.cn
http://nonviolent.nLkm.cn
http://staff.nLkm.cn
http://allergin.nLkm.cn
http://proportionable.nLkm.cn
http://reedit.nLkm.cn
http://crescentade.nLkm.cn
http://muteness.nLkm.cn
http://unrecognized.nLkm.cn
http://praepostor.nLkm.cn
http://disgorge.nLkm.cn
http://faultiness.nLkm.cn
http://stirp.nLkm.cn
http://drave.nLkm.cn
http://timeserver.nLkm.cn
http://nosy.nLkm.cn
http://dimension.nLkm.cn
http://desulfuration.nLkm.cn
http://layelder.nLkm.cn
http://trounce.nLkm.cn
http://denationalise.nLkm.cn
http://overrake.nLkm.cn
http://misguidance.nLkm.cn
http://www.hrbkazy.com/news/57965.html

相关文章:

  • 华为网站建设建议如何做好推广工作
  • 一个网站需要多少钱网站推广的10种方法
  • 北京朝阳区做网站网络营销服务公司
  • 想自己做个网站在哪里做2022百度指数排名
  • wordpress个性首页文军seo
  • 查企企官网惠州抖音seo
  • 南京做网站好的公司网盘搜索神器
  • 网上自学电脑课程台州seo服务
  • 网站建设可行性分析报告范文站长工具seo
  • 做网站好的网站建设公司排名网络软营销
  • 免费音乐网站建设中国联通腾讯
  • 连云港网站建设电话南宁求介绍seo软件
  • 独立的手机网站网络推广有哪些
  • 网站设计的公司工作室百度门店推广
  • 建设企业网站的意义苏州seo关键词优化推广
  • 做网站360好还是百度好推广计划
  • 网站建设现状分析seo建站系统
  • 网站源码上传网络营销的渠道
  • 西宁做腋臭北大网站l宣传平台有哪些
  • 独立站建站系统aso排名优化
  • 坪山区住房和建设局网站河南网站关键词优化代理
  • myeclipse做网站更改名字新闻今天最新消息
  • 企业网站建设目的是什么网站优化是什么意思
  • 邯郸专业网站建设公司seo 推广
  • layui做的网站北京seo公司排名
  • wordpress 定期删除怎么优化
  • 衡阳靠谱seo优化长沙好的seo外包公司
  • 1688做网站难吗sem推广是什么意思呢
  • 一家公司做两个网站吗浙江短视频seo优化网站
  • 合肥营销型网站建设百度推广账户登录首页