First
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "tl/detail/prologue.h"
|
||||
#include "tl/algorithm/find.h"
|
||||
#include <iterator>
|
||||
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename C, typename T>
|
||||
bool contains(C& c, T&& value) noexcept
|
||||
{
|
||||
return tl::find(c, std::forward<T>(value)) != tl::end(c);
|
||||
}
|
||||
|
||||
template <typename C, typename T>
|
||||
bool contains(const C& c, T&& value) noexcept
|
||||
{
|
||||
return tl::cfind(c, std::forward<T>(value)) != tl::end(c);
|
||||
}
|
||||
|
||||
template <typename C, typename UnaryPredicate>
|
||||
bool contains_if(C& c, UnaryPredicate&& p) noexcept
|
||||
{
|
||||
return tl::find_if(c, std::forward<UnaryPredicate>(p)) != tl::end(c);
|
||||
}
|
||||
|
||||
template <typename C, typename UnaryPredicate>
|
||||
bool contains_if(const C& c, UnaryPredicate&& p) noexcept
|
||||
{
|
||||
return tl::cfind_if(c, std::forward<UnaryPredicate>(p)) != tl::end(c);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user