
FFICType::getStructFieldNames 메소드의 반환값은 std::vector 형태로 반환되므로, 이 값을 std::string으로 변환하려면 반복문을 사용하여 각 요소를 연결하는 방법을 사용할 수 있습니다.
#hostingforum.kr
cpp
std::string getStructFieldNamesToString(const std::vector& fieldNames) {
std::string result;
for (const auto& fieldName : fieldNames) {
if (!result.empty()) {
result += ", ";
}
result += fieldName;
}
return result;
}
또는 `std::accumulate` 함수를 사용하여 다음과 같이 구현할 수 있습니다.
#hostingforum.kr
cpp
#include
std::string getStructFieldNamesToString(const std::vector& fieldNames) {
return std::accumulate(fieldNames.begin(), fieldNames.end(), "",
[](const std::string& result, const std::string& fieldName) {
if (!result.empty()) {
return result + ", " + fieldName;
} else {
return fieldName;
}
});
}
이러한 방법으로 FFICType::getStructFieldNames 메소드의 반환값을 std::string으로 변환할 수 있습니다.
2025-07-25 05:35