How to integrate metaprogramming techniques into a custom class