I don\'t know if it\'s possible but I want to do stuff like
int someval = 1;
if({1,2,3,4}_v.contains(someval ))
but when I try to define l
you'd expect syntax to be
if value in (value1, value2 ...)or something similar.
If you're willing to add one extra character, try this syntax:
#include
#include
#include
template
bool operator *(const T0& lhs, const std::array& rhs) {
return std::find(begin(rhs), end(rhs), lhs) != end(rhs);
}
template std::array in(T0 arg0, T...args) {
return {{arg0, args...}};
}
int main () {
if( 2 *in(1,2,3) ) { std::cout << "Hello\n"; }
if( 4 *in(5,6,7,8) ) { std::cout << "Goodbye\n"; }
}