pw_minimal_cpp_stdlib: More iterator support
Update pw_minimal_cpp_stdlib to include the following:
- climits header
- std::begin() and std::end()
- std::find()
- std::copy()
Change-Id: Iac5818e897daf79ff0a4c882a5a730da8e84a3f8
diff --git a/pw_minimal_cpp_stdlib/public/internal/algorithm.h b/pw_minimal_cpp_stdlib/public/internal/algorithm.h
index f905e11..6ad7179 100644
--- a/pw_minimal_cpp_stdlib/public/internal/algorithm.h
+++ b/pw_minimal_cpp_stdlib/public/internal/algorithm.h
@@ -17,6 +17,16 @@
namespace std {
+template <class InputIterator, class OutputIterator>
+constexpr OutputIterator copy(InputIterator first,
+ InputIterator last,
+ OutputIterator dest) {
+ while (first != last) {
+ *dest++ = *first++;
+ }
+ return dest;
+}
+
template <typename T>
constexpr const T& min(const T& lhs, const T& rhs) {
return (rhs < lhs) ? rhs : lhs;
@@ -27,6 +37,18 @@
return (lhs < rhs) ? rhs : lhs;
}
+template <class InputIterator, typename T>
+constexpr InputIterator find(InputIterator first,
+ InputIterator last,
+ const T& value) {
+ for (; first != last; ++first) {
+ if (*first == value) {
+ return first;
+ }
+ }
+ return last;
+}
+
template <typename T>
constexpr T&& forward(remove_reference_t<T>& value) {
return static_cast<T&&>(value);