Description
A little bit of a silly issue possibly and I may be incorrect and sorry if I am, but I think the NEOGPUDeviceSelector example is perhaps wrong, the following line is using the find function of std::string:
return Device.is_gpu() && DeviceName.find("HD Graphics NEO") ? 1 : -1;
But I think it's assuming the result is a bool that will return true if its found and false otherwise or at least it reads that way at a glance. In that case the result of the overall expression would be true and return 1 if it was a GPU and the correct device.
But I believe find returns a size_t (size_type) and if the string is found its returns the start index of the string, otherwise it returns the maximum value size_type can contain.
So I think in this case the ternary operator is going to do the opposite of what the intent is (or at least at glance value its the opposite) which is return -1 if the value is found (as find returns a 0). Whereas in every other case the ternary will return -1 (as find returns a positive value the maximum of size_type).
So because of this I think the whole statements doing the opposite of what it looks like is intended and return -1 whenever the device is found and 1 every other time it's invoked.
I think changing it to the below will give the correct result:
return Device.is_gpu() && (DeviceName.find("HD Graphics NEO") != std::string::npos) ? 1 : -1;
Got a little bit carried away and could have written this a lot more concisely, sorry!