I know C++ doesn't get well macro-functions, but I found this.
#define show(array) \
for (auto& x : (array)) \
std::cout << x << std::endl; \
We can't have inline function alternative to this macro, because array is sent to function as a pointer, so it's impossible. With this, even if we try to apply something indecent, it will just result in compile-time error (if object isn't iterable), and it's obvious one:
'begin' was not declared in this scope: show(5);
Then my question - is this absolutely safe? Can it result in creating a "bad situation"?
Aucun commentaire:
Enregistrer un commentaire