Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What about Expression:invalid comarator?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you what to do with Expression:invalid comarator. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Scene

The functions are defined as follows:

Template struct greaterkey {/ / is used to specify sorting and decreasing in map, and increment by default in map

Bool operator () (const T & x, const T & y) const

{

Return x > y

}

}

Template struct lesskey {

Bool operator () (const T & x, const T & y) const

{

Return x < y

}

}

Solve

After vs2010, there is a strict comparison. If the two elements are equal, be sure to return false. You can see the source code of STL:

[cpp]

Template inline

Bool _ Debug_lt_pred (_ Pr _ Pred

_ Ty1& _ Left, _ Ty2& _ Right

_ Dbfile_t _ File, _ Dbline_t _ Line)

{/ / test if _ Pred (_ Left, _ Right) and _ Pred is strict weak ordering

If (! _ Pred (_ Left, _ Right))

Return (false)

Else if (_ Pred (_ Right, _ Left))

_ DEBUG_ERROR2 ("invalid operator

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report