c++ - 2d STL vector typeid -
i have various 2d vectors , want query differing types @ runtime.
it appears possible on "empty" vector, e.g.:
vector<vector<float> > myvec; cout << (typeid(myvec[0][0]).name() << endl;
the above returns "float" although expecting exception i've not pushed elements.
is luck when accessing memory @ [0][0]
without bounds checking or iterator succeeds? or vector allocate baseline storage when declared?
since float
not have virtual methods, compiler can evaluate typeid(some_float_object)
statically without looking @ actual expression, static type. according section 5.2.8 of c++ standard (current c++0x draft), compiler not allowed evaluate expression.
Comments
Post a Comment