Suppose we have this code:
class test_t { void* data; public: template <typename T> T operator [](int index) { return reinterpret_cast<T*>(data)[index]; } }; int main() { test_t test; int t = test.operator []<int>(5); return 0; }
Is there a way to convert it to compiled idiomatic C ++?
It should look like
int main() { test_t test; int t = test[5]; double f = test[7]; return 0; }
those. polymorphic operator [].
c ++
berkus
source share