Import std::begin/std::end so that container utils work correctly with non std containers
This commit is contained in:
parent
b43f0fb853
commit
1bd2260fa5
|
@ -196,16 +196,6 @@ inline StringView String::substr(CharCount pos, CharCount length) const
|
||||||
return StringView{*this}.substr(pos, length);
|
return StringView{*this}.substr(pos, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const char* begin(StringView str)
|
|
||||||
{
|
|
||||||
return str.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char* end(StringView str)
|
|
||||||
{
|
|
||||||
return str.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline String operator+(const char* lhs, const String& rhs)
|
inline String operator+(const char* lhs, const String& rhs)
|
||||||
{
|
{
|
||||||
return String(lhs) + rhs;
|
return String(lhs) + rhs;
|
||||||
|
|
|
@ -90,6 +90,10 @@ ReversedContainer<Container> reversed(Container&& container)
|
||||||
return ReversedContainer<Container>(container);
|
return ReversedContainer<Container>(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Todo: move that into the following functions once we can remove the decltype
|
||||||
|
// return type.
|
||||||
|
using std::begin;
|
||||||
|
using std::end;
|
||||||
|
|
||||||
template<typename Container, typename T>
|
template<typename Container, typename T>
|
||||||
auto find(Container&& container, const T& value) -> decltype(begin(container))
|
auto find(Container&& container, const T& value) -> decltype(begin(container))
|
||||||
|
@ -103,7 +107,6 @@ auto find_if(Container&& container, T op) -> decltype(begin(container))
|
||||||
return std::find_if(begin(container), end(container), op);
|
return std::find_if(begin(container), end(container), op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename Container, typename T>
|
template<typename Container, typename T>
|
||||||
bool contains(Container&& container, const T& value)
|
bool contains(Container&& container, const T& value)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user