```
int min_unused(const vector& v)
{
for (int i = 1;; i++)
{
if (rng::find(v, i) == v.end())
return i;
}
}
```

Advantages: const vector, duplicates allowed

]]>```
-- counting sort (courtesy of https://stackoverflow.com/questions/39809527/explain-and-clarify-haskell-counting-sort)
--
countingSort :: Ix a => [a] -> a -> a -> [a]
countingSort l lo hi = concat [replicate times n | (n, times) < - counts]
where counts = assocs (accumArray (+) 0 (lo, hi) [(i, 1) | i xs!!i + 1 (if v mx then v else mx)) (head ys, head ys) ys
l = length ys
```

]]>You are right that it is consistent to apply inline also to function templates, but it’s not used in any of the STL implementations or other template heavy code that I know of. So it’s perhaps not idiomatic and surprising/distracting for readers of your code.

]]>I’m still going to prefer and recommend explicit inline usage to be consistent with regular function usage, and function template specializations (17.7.3/12 [temp.expl.spec]).

]]>