@@ -40,25 +40,23 @@ device_filter::device_filter(const std::string &FilterString) {
40
40
Cursor = Found;
41
41
return true ;
42
42
};
43
- auto selectElement = [&](auto It, auto Map, auto EltIfNotFound) {
44
- if (It == Map.end ())
45
- return EltIfNotFound;
46
- ColonPos = FilterString.find (" :" , Cursor);
47
- if (ColonPos != std::string::npos)
48
- Cursor = ColonPos + 1 ;
49
- else
50
- Cursor = Cursor + It->first .size ();
51
- return It->second ;
52
- };
53
43
54
44
// Handle the optional 1st field of the filter, backend
55
45
// Check if the first entry matches with a known backend type
56
46
auto It =
57
47
std::find_if (std::begin (SyclBeMap), std::end (SyclBeMap), findElement);
58
48
// If no match is found, set the backend type backend::all
59
49
// which actually means 'any backend' will be a match.
60
- Backend = selectElement (It, SyclBeMap, backend::all);
61
-
50
+ if (It == SyclBeMap.end ())
51
+ Backend = backend::all;
52
+ else {
53
+ Backend = It->second ;
54
+ ColonPos = FilterString.find (" :" , Cursor);
55
+ if (ColonPos != std::string::npos)
56
+ Cursor = ColonPos + 1 ;
57
+ else
58
+ Cursor = Cursor + It->first .size ();
59
+ }
62
60
// Handle the optional 2nd field of the filter - device type.
63
61
// Check if the 2nd entry matches with any known device type.
64
62
if (Cursor >= FilterString.size ()) {
@@ -68,15 +66,24 @@ device_filter::device_filter(const std::string &FilterString) {
68
66
std::end (SyclDeviceTypeMap), findElement);
69
67
// If no match is found, set device_type 'all',
70
68
// which actually means 'any device_type' will be a match.
71
- DeviceType = selectElement (Iter, SyclDeviceTypeMap, info::device_type::all);
69
+ if (Iter == SyclDeviceTypeMap.end ())
70
+ DeviceType = info::device_type::all;
71
+ else {
72
+ DeviceType = Iter->second ;
73
+ ColonPos = FilterString.find (" :" , Cursor);
74
+ if (ColonPos != std::string::npos)
75
+ Cursor = ColonPos + 1 ;
76
+ else
77
+ Cursor = Cursor + Iter->first .size ();
78
+ }
72
79
}
73
80
74
81
// Handle the optional 3rd field of the filter, device number
75
82
// Try to convert the remaining string to an integer.
76
83
// If succeessful, the converted integer is the desired device num.
77
84
if (Cursor < FilterString.size ()) {
78
85
try {
79
- DeviceNum = stoi (FilterString.substr (ColonPos + 1 ));
86
+ DeviceNum = stoi (FilterString.substr (Cursor ));
80
87
HasDeviceNum = true ;
81
88
} catch (...) {
82
89
std::string Message =
0 commit comments