Temporary compilation expressions are good because you can use them to specialize templates. For example, tuples can be obtained using a compile-time expression using the std::get method.
std::cout << std::get<0>(my_tuple) << std::endl;
Now this expression is pretty ugly. I myself try to develop some kind of tuples (hoping to make them turn them into compilation dictionaries), so, say, they expose the method in the form:
my_dict.get<0>();
Now, what I would like to do is replace it with the [] operator. I was wondering if this is possible at all. First of all, I would not know how to select only constants, compile the expressions known by time as parameters for my operator. Moreover, the return type will depend on the value of the constant expression.
With the definition, however, I can get closer to what I want, with something like
#define item(x) get<x>()
so that then i can use
my_dict.item(0)
Is there a way to get something better than this?
source share