I get an odd warning for the following code I made for testing the library:
#include <iostream>
#include <cmath>
#include <cppcoro/generator.hpp>
using std::cout;
using std::endl;
cppcoro::generator<int> primes();
int main()
{
int i = 0;
for (auto p : primes())
{
cout << ++i << ": " << p << endl;
if (i >= 10000)
{
break;
}
}
return 0;
}
cppcoro::generator<int> primes()
{
// simplified prime check
// no p <= 1 check
// no checking of div 2 or any other even number
// can be simplified because we only test odd numbers >= 5 anyway
const auto pc = [](const int& val) {
for (int i = 3; i <= sqrt(val); i+=2)
if (val % i == 0)
return false;
return true;
};
co_yield 2;
int i = 3;
while (true) {
co_yield i;
do {
i+=2;
}while (!pc(i));
}
} // line 41 (warning is here)
I am not sure why that is. I do not use any switch statements at all.
The warning is always on the closing bracket of the primes() coroutine, even if I move it above main. It's not EOF related.
ps: Thank you for fixing the original cppcoro and using a sane build system!
I get an odd warning for the following code I made for testing the library:
My compiler output is the following:
I am not sure why that is. I do not use any switch statements at all. The warning is always on the closing bracket of the primes() coroutine, even if I move it above main. It's not EOF related.
ps: Thank you for fixing the original cppcoro and using a sane build system!