Monday 30 July 2012

C++0x and C++03?

Today I played the d-nets(https://sites.google.com/site/descriptornets/) codes, which applied strip as the feature descriptors to refine match accuracy comparing to patch-based feature descriptors.

There is no problem to compile under Ubuntu, while I can not compile it straightaway in Windows using visual studio 2008 due to ".data() is not the method of vector in STL".

#include <vector>
vector<T> Var;
Var.data();
In VS2008, the compiler can not compile Var.data(). After searching from Google, I realize that data() method is not implemented in STL vector in C++98/C++03, recently(precisely in 2011) SC22 WG21 announced new ISO C++ standard which is referred to as C++11 or C++0x(Bjarne Stroustrup explained that if we think "x" as hexadecimal, C++11 == C++0B, which is still consistent naming to some extend :p). data() method is available for vector container in C++11.

However, Var.data() will return the pointer to the first element in the vector, so we can use &Var.front() to substitute Var.data() in C++98 version.