M
m0shbear
I am using the following variant of std::search to simplify my code.
template <class ForwardIterable1, class ForwardIterable2>
auto search(ForwardIterable1&& _1, ForwardIterable2&& _2) ->
decltype(_1.begin()) {
return std::search(_1.begin(), _1.end(), _2.begin(),
_2.end());
}
template <class ForwardIterable1, class ForwardIterable2, class
BinaryPredicate>
auto search(ForwardIterable1&& _1, ForwardIterable2&& _2,
BinaryPredicate _p) -> decltype(_1.begin()) {
return std::search(_1.begin(), _2.begin(), _p);
}
Two immediate questions arise:
1) Is '&&' appropriate to use here or should 'const&' be used instead?
2) Are there plans for this to be in the final c++0x (yes i know this
question is better-suited to be asked on comp.std.c++) or will this
probably a compiler extension which will only be useful after posting
as a bugreport to $COMPILERVENDOR?
template <class ForwardIterable1, class ForwardIterable2>
auto search(ForwardIterable1&& _1, ForwardIterable2&& _2) ->
decltype(_1.begin()) {
return std::search(_1.begin(), _1.end(), _2.begin(),
_2.end());
}
template <class ForwardIterable1, class ForwardIterable2, class
BinaryPredicate>
auto search(ForwardIterable1&& _1, ForwardIterable2&& _2,
BinaryPredicate _p) -> decltype(_1.begin()) {
return std::search(_1.begin(), _2.begin(), _p);
}
Two immediate questions arise:
1) Is '&&' appropriate to use here or should 'const&' be used instead?
2) Are there plans for this to be in the final c++0x (yes i know this
question is better-suited to be asked on comp.std.c++) or will this
probably a compiler extension which will only be useful after posting
as a bugreport to $COMPILERVENDOR?