title might be confusing, but lets say I have a template:
template <typename T, size_t offset>
struct offsetedIdxArray
{
//...
}
And after I create an instance:
static const size_t offset(1701);
offsetedIdxArray<zmq::socket_t, offset> oia;
Is there a way to get offset variable from oia. I know I can just use offset but from code style perspective i prefer to get it from oia if possible.
EDIT: I’m looking for a way to get offset without helper variable inside struct…
If you want to obtain the information from an
offsetedIdxArray<T,N>object without adding any members to the class template, you can use a template function:Otherwise you can add a static constant or enum data member, as suggested in other posts.