G
gnobal
Hi,
I'm using a library that has a function that looks like this:
vector<int> getData(const vector<int>& keys, int32_t limit);
(there may be more than one datum per key)
Today I'm passing numeric_limits<int32_t>::max() as the limit, but I
was wondering whether there is a way to extract the type of the limit
parameter so that my argument will always have the right max value.
For example, if the library's author decides to make the limit an
int64_t, I wouldn't know. A worse case is if the author decides to
make it an int16_t.
I realize that this might not be the best library interface design,
but it's in a library I'm using and I can't change it. Also, maybe
there are other examples where this might be needed.
Thanks.
I'm using a library that has a function that looks like this:
vector<int> getData(const vector<int>& keys, int32_t limit);
(there may be more than one datum per key)
Today I'm passing numeric_limits<int32_t>::max() as the limit, but I
was wondering whether there is a way to extract the type of the limit
parameter so that my argument will always have the right max value.
For example, if the library's author decides to make the limit an
int64_t, I wouldn't know. A worse case is if the author decides to
make it an int16_t.
I realize that this might not be the best library interface design,
but it's in a library I'm using and I can't change it. Also, maybe
there are other examples where this might be needed.
Thanks.