Date: Tue, 16 Aug 2022 12:53:00 +0100
Every C++ compiler suite I'm aware of supports the preprocessor macro
__COUNTER__.
So if I do the following:
#include <iostream>
auto main(void) -> int
{
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
}
Then it prints:
0
1
2
3
I see that in C++20 we have "std::source_location" which can probably
take the place of __FILE__, __LINE__, and maybe also __COUNTER__ in
some scenarios, but I still think __COUNTER__ should be standard C++.
__COUNTER__.
So if I do the following:
#include <iostream>
auto main(void) -> int
{
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
std::cout << __COUNTER__ << std::endl;
}
Then it prints:
0
1
2
3
I see that in C++20 we have "std::source_location" which can probably
take the place of __FILE__, __LINE__, and maybe also __COUNTER__ in
some scenarios, but I still think __COUNTER__ should be standard C++.
Received on 2022-08-16 11:53:11