X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fstdalgo.h;h=3e00a4cdcd93030cdb2d3c56e1b48dac24599261;hb=b4f82cff9b2efdc05e29bfe9db3f0bbb40d9ce2b;hp=cb01a250aac37e2dffc30cd0d069afeae6a9befa;hpb=fbc73e20784b055485f676096e758d6aeed62e0c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/stdalgo.h b/include/stdalgo.h index cb01a250a..3e00a4cdc 100644 --- a/include/stdalgo.h +++ b/include/stdalgo.h @@ -112,4 +112,16 @@ namespace stdalgo } return false; } + + /** + * Check if an element with the given value is in a container. Equivalent to (std::find(cont.begin(), cont.end(), val) != cont.end()). + * @param cont Container to find the element in + * @param val Value of the element to look for + * @return True if the element was found in the container, false otherwise + */ + template class Cont, typename T, typename Alloc> + inline bool isin(const Cont& cont, const T& val) + { + return (std::find(cont.begin(), cont.end(), val) != cont.end()); + } }