我正在嘗試使用v3驅動程序生成mongodb文檔。我使用「char *」指針數組中的字符串,但是我一直收到一個錯誤,說明運算符不明確。確切的錯誤是:在Mongodb C++驅動程序文檔生成器中模糊<<運算符
item.cpp:105: error: ambiguous overload for ‘operator<<’ (operand types are
‘std::enable_if<true, bsoncxx::v_noabi::builder::stream::key_context<> >::type {aka bsoncxx::v_noabi::builder::stream::key_context<>}’ and ‘const char*’)
<< dbTypeString[dbType::IT_TYPE]
dbTypeString就像是一個字符串數組:
const char * dbTypeString[] = {"string a", "string b"}
蒙戈代碼的簡化版本,看起來像
bsoncxx::builder::stream::document doc{};
doc << dbTypeString[0] << "value string";
奇怪的是即:doc < <「string1」< <「string2」起作用精細。
有什麼建議嗎?