Hi I am reading through the implementation of std::optional
here and I found the following lines in its unit testing files.
struct caller {
template <class T> caller(T fun) { fun(); }
};
# define CAT2(X, Y) X ## Y
# define CAT(X, Y) CAT2(X, Y)
# define TEST(NAME) caller CAT(__VAR, __LINE__) = []
I don't really understand what do these lines do. caller
seems to be a template to invoke functions, but how can it be used as caller CAT ...
? What does X ## Y
mean here? Later in the file, the user define unit tests using TEST
, but they do not appear in any executable code (I mean they are not called in main
function at least), so I am not even sure if the compiled binary actually run the tests. Could you explain what is going on here? Thanks!
Aucun commentaire:
Enregistrer un commentaire