Is there a way to overload a function in such a way as to distinguish between the argument to be analyzed at compile time or only at run time?
Suppose I have the following function:
std::string lookup(int x) {
return table<x>::value;
}
which allows me to select a string value based on the x parameter in constant time (with spatial overhead). However, in some cases xit cannot be provided at compile time, and I need to run a version of foo that does a search with higher time complexity.
I could use functions with a different name, of course, but I would like to have a unified interface.
I accepted the answer, but I'm still wondering if this difference is possible with the same function call.
source
share