This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This code implements ML like pattern matching in C++17 using constexpr and the template system. | |
Like in ML, a standalone function evaluates the expression. However, with C++ templates and | |
constexpr, the evaluation function for the expression can be embedded within the type. Where | |
every node type has a static member function eval that performs its step of the expression. | |
See the link below for SQL WHERE predicate nodes implementing this pattern: | |
https://github.com/mkitzan/metaprogramming-optimization/blob/master/include/sql/predicate.hpp | |
https://godbolt.org/z/PQnBXf | |
clang -std=c++17 -lstdc++ -o pm pattern_matching.cpp |