Add String::New overload for string_view#1706
Conversation
|
I added the |
|
Would you mind adding a test case in https://github.com/nodejs/node-addon-api/blob/main/test/name.cc? Thank you! |
Sounds good! we can start with these two sites. |
|
Same as #1705, the test take too long to compile, not sure how to run them |
| Function::New(env, NullString16ShouldThrow); | ||
| exports["checkString"] = Function::New(env, CheckString); | ||
| exports["createSymbol"] = Function::New(env, CreateSymbol); | ||
| exports["CreateSymbolFromStringView"] = Function::New(env, CreateSymbolFromStringView); |
There was a problem hiding this comment.
This seems to be the reason that the test failed.
| exports["CreateSymbolFromStringView"] = Function::New(env, CreateSymbolFromStringView); | |
| exports["createSymbolFromStringView"] = Function::New(env, CreateSymbolFromStringView); |
KevinEady
left a comment
There was a problem hiding this comment.
Guards for c++17 can be removed.
| #if __cplusplus >= 201703L | ||
| #include <string_view> | ||
| #endif | ||
|
|
There was a problem hiding this comment.
We discussed in the Node API meeting on 20 Feb that this guard can be removed.
std::string_view was added in c++17, which is a minimum requirement starting with Node.js v20 (ref). Building addons with node-addon-api have the same build requirements as those of Node.js, so a minimum of c++17.
Fixes #1703