我有一个函数可以接收一个字符串,然后将它传递给我的 c++ 函数add_node()
Handle<Value> Graph::add_node(const v8::Arguments& args)
{
HandleScope scope;
Graph* graph = ObjectWrap::Unwrap<Graph>(args.This());
graph->add_node( args[0]->ToString() );
std::cout << "In add node \n";
}
但是我遇到了麻烦,因为我所有的论点都是某种 v8 模板,我不知道如何在两者之间切换。文档_也没有明确说明
编译器给了我这个错误
../graph/binding.cc:52:10: error: no matching member function for call to
'add_node'
graph->add_node( args[0]->ToString() );
~~~~~~~^~~~~~~~
../graph/directed_graph.h:27:7: note: candidate function not viable: no known
conversion from 'Local<v8::String>' to 'std::string &' (aka
'basic_string<char> &') for 1st argument;
void add_node( std::string & currency );
如何在Local<v8::String>
和之间切换std::string &
?