A class:
class foo{ public: int data; };
Now I want to add a method to this class, to do some comparison, to see if its data is equal to on
set is a good option, but if you really want to roll your own, initializer_list is convienient:
set
bool is_in( int val, initializer_list lst ) { for( auto i : lst ) if( i == val ) return true; return false; }
use is trivial:
is_in( x, { 3, 5, 7 } ) ;
it's O(n) thou, set / unordered is faster