zxs 1 hete
szülő
commit
cccdc2ee9d
1 módosított fájl, 19 hozzáadás és 0 törlés
  1. 19 0
      robot/robotics/linq.hpp

+ 19 - 0
robot/robotics/linq.hpp

@@ -1951,6 +1951,25 @@ namespace robotics {
                 }
                 return result;
             }
+            /**
+             * @brief 获取一个值
+             * @return
+             */
+            template<bool _Unlock = true>
+            std::shared_ptr<_Type> first(_Type const&def_value) {
+                std::shared_ptr<_Type> result = std::make_shared<_Type>(def_value);
+                for (size_t i = 0; i < source_ok_.size(); ++i) {
+                    if (!source_ok_[i]) {
+                        continue;
+                    }
+                    result = *(source_.begin() + i);
+                    break;
+                }
+                if constexpr (_Unlock) {
+                    unlock();
+                }
+                return result;
+            }
             /**
              * @brief 获取值
              */