Lines Matching full:container
27 // `container.contains(value)` if this is a valid expression. This is the
29 template <typename Container, typename Value>
30 constexpr auto ContainsImpl(const Container& container,
33 -> decltype(container.contains(value)) {
34 return container.contains(value);
38 // can be compared with `container.end()`. Intended for STL style maps and sets
40 template <typename Container, typename Value>
41 constexpr auto ContainsImpl(const Container& container,
44 -> decltype(container.find(value) != container.end()) {
45 return container.find(value) != container.end();
49 // can be compared with `Container::npos`. Intended for STL style strings that
51 template <typename Container, typename Value>
52 constexpr auto ContainsImpl(const Container& container,
55 -> decltype(container.find(value) != Container::npos) {
56 return container.find(value) != Container::npos;
59 // Generic fallback option, using a linear search over `container` to find
62 template <typename Container, typename Value>
63 constexpr bool ContainsImpl(const Container& container,
67 !HasKeyType<Container>::value,
68 "Error: About to perform linear search on an associative container. "
71 return ranges::find(container, value) != ranges::end(container);
76 // A general purpose utility to check whether `container` contains `value`. This
77 // will probe whether a `contains` or `find` member function on `container`
78 // exists, and fall back to a generic linear search over `container`.
79 template <typename Container, typename Value>
80 constexpr bool Contains(const Container& container, const Value& value) {
81 return internal::ContainsImpl(container, value, internal::priority_tag<2>());
85 // projection will be applied to every element in `container` before comparing
87 template <typename Container, typename Value, typename Proj>
88 constexpr bool Contains(const Container& container,
91 return ranges::find(container, value, std::move(proj)) !=
92 ranges::end(container);