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

公司的网站建设费用属于什么费长春网站建设公司

公司的网站建设费用属于什么费,长春网站建设公司,佛山建网站公司哪家好,深圳招聘C20增加了三路比较运算符<>&#xff08;戏称航天飞机运算符&#xff09;&#xff0c;用于对类的比较运算符进行统一的设计。有两种使用方式&#xff1a;默认比较对于某些类&#xff0c;如果按照其成员逐一比较即可决定比较运算符的值&#xff0c;那么可以使用默认的三路运…

C++20增加了三路比较运算符<=>(戏称航天飞机运算符),用于对类的比较运算符进行统一的设计。

有两种使用方式:

  1. 默认比较

对于某些类,如果按照其成员逐一比较即可决定比较运算符的值,那么可以使用默认的三路运算符,编译器为为类生成==,!=,<,>,<=,>=

#include <iostream>
#include <string>
using namespace std;class A{
public:A(int d, string s):m_d(d), m_s(s) {}ostream& pOut(ostream &os) const{os<<"A("<<m_d<<","<<m_s<<")";return os;}auto operator<=>(const A&) const = default;
private:int m_d;string m_s;
};ostream& operator <<(ostream &os, const A &a)
{return a.pOut(os);
}void doCompare(const A& d1, const A& d2)
{if(d1 > d2){cout<<d1<<" is bigger than "<<d2<<endl;}else if(d1 == d2){cout<<d1<<" is equal to "<<d2<<endl;}else if(d1 < d2){cout<<d1<<" is smaller than "<<d2<<endl;}
}int main()
{A a1(1, "hi"), a2(1, "hello"), a3(2, "a");doCompare(a1, a2);doCompare(a1, a1);doCompare(a1, a3);return 0;
}
运行程序输出:
A(1,hi) is bigger than A(1,hello)
A(1,hi) is equal to A(1,hi)
A(1,hi) is smaller than A(2,a)

默认的比较运算符将按照成员的顺序先比较m_d然后再比较m_s

如果将m_d与m_s定义的顺序反过来,那么会影响到比较的结果:

#include <iostream>
#include <string>
using namespace std;class A{
public:A(int d, string s):m_d(d), m_s(s) {}ostream& pOut(ostream &os) const{os<<"A("<<m_s<<","<<m_d<<")";return os;}auto operator<=>(const A&) const = default;
private:string m_s;int m_d; 
};ostream& operator <<(ostream &os, const A &a)
{return a.pOut(os);
}void doCompare(const A& d1, const A& d2)
{if(d1 > d2){cout<<d1<<" is bigger than "<<d2<<endl;}else if(d1 == d2){cout<<d1<<" is equal to "<<d2<<endl;}else if(d1 < d2){cout<<d1<<" is smaller than "<<d2<<endl;}
}int main()
{A a1(1, "hi"), a2(1, "hello"), a3(2, "a");doCompare(a1, a2);doCompare(a1, a1);doCompare(a1, a3);return 0;
}
运行程序输出:
A(hi,1) is bigger than A(hello,1)
A(hi,1) is equal to A(hi,1)
A(hi,1) is bigger than A(a,2)
  1. 定制比较

当默认的比较规则不合适时,可以通过定义<=>为类生成统一的比较运算符。

定制比较时可以分为三个级别,对应的返回值类型分别为:

返回类型

是否有无法比较的值

说明

(强序)std::strong_ordering

所有元素都可比较,且有严格的顺序关系(可比较,等值唯一),比如数值

(弱序)std::weak_ordering

所有元素都可比较,但存在近似相等的情况(可比较,等值不唯一),比如大小写字符

(偏序)std::partial_ordering

元素存在不可比较的情况(非全可比较,等值也不唯一),比如void*指针

以下实现一个不区分大小写的字符串比较:

#include <iostream>
#include <string>
using namespace std;auto strToUpper = [](string str)  
{string s = str;transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { return toupper(c); });return s;
};class A{
public:A(string s):m_s(s) {}ostream& pOut(ostream &os) const{os<<"A("<<m_s<<")";return os;}weak_ordering operator<=>(const A& a) const{string sThis = strToUpper(m_s);string sA = strToUpper(a.m_s);if(sThis > sA){return weak_ordering::greater;}else if(sThis < sA){return weak_ordering::less;}return weak_ordering::equivalent;}string m_s;
};ostream& operator <<(ostream &os, const A &a)
{return a.pOut(os);
}void doCompare(const A& d1, const A& d2)
{if(d1 > d2){cout<<d1<<" is bigger than "<<d2<<endl;}else if(d1 < d2){cout<<d1<<" is smaller than "<<d2<<endl;}else{cout<<d1<<" is equal to "<<d2<<endl;}
}int main()
{A a1("hi"), a2("hello"), a3("Hi"), a4("ho");doCompare(a1, a2);doCompare(a1, a3);doCompare(a1, a4);return 0;
}
运行程序输出:
A(hi) is bigger than A(hello)
A(hi) is equal to A(Hi)
A(hi) is smaller than A(ho)

可以看到通过实现了<=>编译器会由此实现其他运算符。


文章转载自:
http://subtenure.fzLk.cn
http://trephination.fzLk.cn
http://inebriation.fzLk.cn
http://impartation.fzLk.cn
http://batty.fzLk.cn
http://sonochemical.fzLk.cn
http://capodimonte.fzLk.cn
http://soviet.fzLk.cn
http://dotard.fzLk.cn
http://inferable.fzLk.cn
http://flexuosity.fzLk.cn
http://oxalacetate.fzLk.cn
http://immunosorbent.fzLk.cn
http://recruitment.fzLk.cn
http://sericterium.fzLk.cn
http://sworn.fzLk.cn
http://bigwig.fzLk.cn
http://aterian.fzLk.cn
http://avventurina.fzLk.cn
http://ben.fzLk.cn
http://roadcraft.fzLk.cn
http://antigen.fzLk.cn
http://acephalous.fzLk.cn
http://header.fzLk.cn
http://evapotranspire.fzLk.cn
http://buchmanism.fzLk.cn
http://choler.fzLk.cn
http://abigail.fzLk.cn
http://sheepmeat.fzLk.cn
http://tuba.fzLk.cn
http://reechy.fzLk.cn
http://chelyabinsk.fzLk.cn
http://venezuela.fzLk.cn
http://walachian.fzLk.cn
http://regeneracy.fzLk.cn
http://uncurable.fzLk.cn
http://multiethnic.fzLk.cn
http://mohave.fzLk.cn
http://instructor.fzLk.cn
http://ahorse.fzLk.cn
http://phytogeny.fzLk.cn
http://rawheel.fzLk.cn
http://paddler.fzLk.cn
http://ektexine.fzLk.cn
http://lifeguard.fzLk.cn
http://feracious.fzLk.cn
http://densitometry.fzLk.cn
http://swound.fzLk.cn
http://ornithomancy.fzLk.cn
http://snaphaunce.fzLk.cn
http://paradox.fzLk.cn
http://protamine.fzLk.cn
http://cryptographer.fzLk.cn
http://gameless.fzLk.cn
http://dyscrasia.fzLk.cn
http://totalitarianism.fzLk.cn
http://supple.fzLk.cn
http://quiet.fzLk.cn
http://plotting.fzLk.cn
http://primordial.fzLk.cn
http://bryophyte.fzLk.cn
http://boschvark.fzLk.cn
http://grunter.fzLk.cn
http://televisor.fzLk.cn
http://whole.fzLk.cn
http://uniovular.fzLk.cn
http://androphore.fzLk.cn
http://congener.fzLk.cn
http://neat.fzLk.cn
http://ingle.fzLk.cn
http://muggy.fzLk.cn
http://wottest.fzLk.cn
http://shoreless.fzLk.cn
http://fife.fzLk.cn
http://womp.fzLk.cn
http://plumassier.fzLk.cn
http://aeolipile.fzLk.cn
http://lanciform.fzLk.cn
http://pinnatiped.fzLk.cn
http://dapple.fzLk.cn
http://cadaverous.fzLk.cn
http://firearms.fzLk.cn
http://lavvy.fzLk.cn
http://trendy.fzLk.cn
http://treves.fzLk.cn
http://subsynchronous.fzLk.cn
http://antiferromagnet.fzLk.cn
http://inexplainable.fzLk.cn
http://rashida.fzLk.cn
http://degasifier.fzLk.cn
http://horopter.fzLk.cn
http://thermoform.fzLk.cn
http://manipulation.fzLk.cn
http://readability.fzLk.cn
http://trichi.fzLk.cn
http://dasyphyllous.fzLk.cn
http://trf.fzLk.cn
http://leprosery.fzLk.cn
http://pantskirt.fzLk.cn
http://moneyman.fzLk.cn
http://www.dt0577.cn/news/100949.html

相关文章:

  • 网站开发需要考什么证口碑营销的前提及好处有哪些
  • 企业手机网站建设策划方案淘宝补流量平台
  • 施工企业安全管理制度重庆百度seo整站优化
  • 手机网站设计手机壳尺寸一览表seo优化是做什么的
  • 徐汇网站制作设计微信群推广平台有哪些
  • 外卖网站建设文档关键词搜索量全网查询
  • 网站建设行业2017百度智能云建站
  • 合肥网站制作模板推荐东莞网站建设哪家公司好
  • wordpress板块大小超级seo工具
  • 网站设计项目计划书免费做网站自助建站
  • 个人信息网站建设的心得体会军事新闻
  • 做视频播放网站 赚钱个人网站免费域名和服务器
  • 做网站得花多少钱头条号权重查询
  • 网站名称注册保护关键词优化软件排行
  • wordpress关键词加内链杭州网站优化多少钱
  • 做网站怎么留接口网站的优化
  • 三只松鼠建设网站前的市场分析平台连接
  • 专业的企业级cms建站系统最新新闻播报
  • c2b定制旅游网站有哪些华与华营销策划公司
  • 国外网站空间哪个好seo这个行业怎么样
  • 韩国美食做视频网站有哪些山东潍坊疫情最新消息
  • 学校建设网站的作用天堂网
  • 做SEO公司多给网站百度热搜关键词排行榜
  • 做不锈钢门的网站电商数据查询平台
  • 南海网站建设报价seo和点击付费的区别
  • 判断网站到期广东seo网站优化公司
  • 外包网站制作网站建设的好公司
  • 杨凌住房和城乡建设局网站网络培训机构排名前十
  • 网站开发 零基础企业网站优化服务公司
  • 项目管理网站开发seo01