Реализация:
Код: Выделить всё
template
requires std::equality_comparable
size_t count_primes(Iterator first, Iterator last)
{
std::vector results;
// skiped for brevity
return std::accumulate(results.begin(), results.end(), 0);
}
Код: Выделить всё
println("num primes in v is: {}",
count_primes(v.begin(), v.end()));
Код: Выделить всё
FAILED: main
: && /usr/bin/clang++ -g src/CMakeFiles/main.dir/main.cpp.o -o main src/libmultithreading.a && :
/usr/bin/ld: src/CMakeFiles/main.dir/main.cpp.o: in function `main':
/home/mikhail/programming/c++/exercises/cpp_multithreading/src/main.cpp:43:(.text+0x217): undefined reference to `unsigned long Chapter2::count_primes(__gnu_cxx::__normal_iterator, __gnu_cxx::__normal_iterator) requires std::equality_comparable'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make: *** [Makefile:2: compile] Error 1
Этот код можно преобразовать в простые функции, но я пытаюсь получить некоторые дополнительные знания о C++ в ходе изучения параллельного программирования, поэтому мне хотелось бы узнать, что Я сделал неправильно.
Подробнее здесь: https://stackoverflow.com/questions/792 ... rtiterator
Мобильная версия