
Providing alpha-numeric operator with "less less" or "star star" syntax. Hello, I'm new here, You surely know that is possible to use operator redefinition to obtain a syntax like a -in- b ( or a *in* b) where -in- is a constant that is used as a alpha-numeric operator. on the bottom of the mail there is a code that is a simple proof of concept on how obtain this syntax I don't know if you have never thought that is possible to use this syntax to make lot's of much more interesting stuff ( the 'in' keyword is a simple example...) For example we can use this solution to implement a compile time checker for SQL code, admitting syntax like Table t=....; Query q=SELECT-t["name"],t["telephone"]-WHERE-t["surname"]="Smith"-AND-t["age"]>50; The choose from less less and star star (and other less polish symbols like &in& or |in| is about operator precedence and must be very careful) Another idea could be using it on the bind function to obtain a syntax like myFun-Call(par1,par2,par3,...) Of course that is only a very little example of what is possible to do whit this type of syntax. I have think about this only few days before, and I'm not still convinced if it is good or no, but you surely can help me to decide about it. By Marco. -------------------------------------------------- NOTE: this code is only a proof of concept, lot of optimization can be added to, like using In::Binded<T&> when is opportune, and providing ways to generate other binary operator without redundancy in the code.... ---------------------------------------------- #import<iostream> #import<vector> #import<algorithm> using std::vector; namespace inKeyword{ class In{ private: template<typename T> class Binded{ public: T binded; inline explicit Binded(T binded_):binded(binded_){} }; }; template<typename T> inline In::Binded<T> operator-( T elem,In in){ return In::Binded<T>(elem); }; template<typename T,typename C> inline bool operator-(In::Binded<T> binded, C & v){ return std::find(v.begin(), v.end(), binded.binded)!=v.end(); }; const In in=In(); } using inKeyword::in; int main(){ vector<int> v; v.push_back(3); v.push_back(4); v.push_back(5); bool ris=3-in-v; std::cout<<4-in-v<<std::endl; std::cout<<7-in-v<<std::endl; return 0; }