Compile time expressions are good because you can use them to specialize templates. So for example, tuples can be accessed by using a compile time expression with the std::get
method.
std::cout << std::get<0>(my_tuple) << std::endl;
Now, the above expression is pretty ugly. I am trying to develop some sort of tuples myself (hoping to make it to turn them into compile time dictionaries), so that, say, they expose a method in the form:
my_dict.get<0>();
Now, what I would like to do is to substitute that with a [] operator. I was wondering if that was even possible at all. First of all, I wouldn't know how to select only constant, compile time known expressions as parameters for my operator. Moreover, the return type would depend on the value of the constant expression.
With a define, however, I can get closer to what I want with something like
#define item(x) get<x>()
so that I can then use
my_dict.item(0)
Is there a way to get something better than this?