Quantcast
Channel: Can (a==1)&&(a==2)&&(a==3) evaluate to true? (and can it be useful?) - Stack Overflow
Viewing all articles
Browse latest Browse all 9

Answer by super for Can (a==1)&&(a==2)&&(a==3) evaluate to true? (and can it be useful?)

$
0
0

Could be somewhat useful.

#include <iostream>#include <algorithm>#include <vector>using namespace std;struct Foo {    std::vector<int> v = {1,2,3};};bool operator==(const Foo& foo, int i) {    return std::any_of(foo.v.begin(), foo.v.end(), [=](int v){ return v == i; });}int main() {    Foo a;    if (a==1 && a==2 && a==3)        cout << "Really??"<< endl;    return 0;}

Viewing all articles
Browse latest Browse all 9

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>