Add StringToVector<std::string> overload for char*.

This overload allows `StringToVector` to accept a `char*` argument when parsing into a `std::vector<std::string>`, by converting the `char*` to `std::string` before processing.

PiperOrigin-RevId: 902611443
Change-Id: I2048918f915c1bac74522f368ea28f23ca9a6885
This commit is contained in:
Alessio Quaglino
2026-04-20 06:48:16 -07:00
committed by Copybara-Service
parent 86ad41b9c2
commit 35f7db8e91
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -1333,6 +1333,10 @@ template <typename T> std::vector<T> StringToVector(char* cs) {
return v;
}
template<> MJAPI std::vector<std::string> StringToVector(char* cs) {
return StringToVector<std::string>(std::string(cs));
}
template<> MJAPI std::vector<std::string> StringToVector(const std::string& s) {
std::vector<std::string> v;
std::stringstream ss(s);
+1
View File
@@ -264,6 +264,7 @@ template<typename T> MJAPI std::string VectorToString(const std::vector<T>& v);
// convert string to vector
template<typename T> MJAPI std::vector<T> StringToVector(char *cs);
template<typename T> MJAPI std::vector<T> StringToVector(const std::string& s);
template<> MJAPI std::vector<std::string> StringToVector(char* cs);
template<> MJAPI std::vector<std::string> StringToVector(const std::string& s);
} // namespace mujoco::user