VC++ 5.0 and STL predicates

VC++ 5.0 and STL predicates

How can I provide my own predicate for the list::sort method in Visual C++ 5.0? The method appears to require that any function object passed must be derived from greater but in stepping through the code in the debugger, I noticed that my function object is cast to a base class (std::binary_function) that has a non-virtual operator() method so my operator() never gets called. Am I missing something?

There is no such restriction for the comparison algorithm for sort in STL.As a matter of fact, there is not a single place where STL relies on virtual functions. If your compiler’s implementation casts thecomparator to the base class’ version, that is a serious bugin the implementation.

Here is the definition of list::sort as perthe draft standards:

template  >class list{  // other stuff template  void sort (Compare comp)};
Here the only restriction on the Compare type is that it must havea publically visible function call operator [operator ()()].

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several