When compiling, an error occurs. It is required to make a sort function with a " universal " argument.
Undefined symbols for architecture x86_64:
"void selection_sort<float>(float*, unsigned long)", referenced from:_main in main.o
ld: symbol (s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see> invocation)
selectionsort.hpp
#ifndef selectionsort_hpp #define selectionsort_hpp #include <stddef.h> #include "swap.hpp" template<typename T> void selection_sort(T[], size_t); #endif /* selectionsort_hpp */ selectionsort.cpp
#include "selectionsort.hpp" template<typename T> void selection_sort(T array[], size_t size) { for (size_t i = 0; i < size - 1; i++) { size_t minimal = i; for (size_t j = i + 1; j < size; j++) { if (array[minimal] > array[j]) { minimal = j; } } swap(array[minimal], array[i]); } }