Composer

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <string> using namespace std; // *** // Types are according to: https://dev.mysql.com/doc/refman/8.0/en/select.html // *** // // Other documentation: // https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10002.htm#SQLRF01702 struct select_expr {}; struct table_references {}; struct where_condition {}; namespace dbo { struct ALL { static inline const char* field() { return "*"; } }; struct rp_Clienti { static inline const char* table() { return "rp_Clienti"; } struct ID { static inline const char* field() { return "ID"; } }; }; } template <typename S, typename T, typename W> class Select {}; template <> class Select<select_expr, table_references, where_condition> { public: template<typename S, typename T, typename W> void bind() { mExpr = S::field(); mRef = T::table(); mWhere = W::field(); } std::string toString() { return std::string(" SELECT ") + mExpr + " FROM " + mRef + " WHERE " + mWhere; } private: std::string mExpr; std::string mRef; std::string mWhere; }; int main() { Select<select_expr, table_references, where_condition> query; query.bind<dbo::ALL, dbo::rp_Clienti, dbo::rp_Clienti::ID>(); cout << query.toString(); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines