Add variant of Nan::New<v8::String> which takes a C++17 string_view#880
Add variant of Nan::New<v8::String> which takes a C++17 string_view#880robinchrist wants to merge 2 commits intonodejs:mainfrom
Conversation
bnoordhuis
left a comment
There was a problem hiding this comment.
Mostly LGTM minus two things:
-
This needs documentation and a regression test.
-
-DNAN_ENABLE_STRING_VIEW=falsewon't undefine the macro.defined(NAN_ENABLE_STRING_VIEW)is true because the macro is non-empty, it evaluates to the string"false".
I'd be okay with leaving out NAN_ENABLE_STRING_VIEW unless you feel there's a valid reason people would want to disable the overload. I can't think of one myself.
Hmm, I'm not sure whether I can follow. Without any additional Using Or should I change the meaning of EDIT: EDIT 2: |
|
Ah, I think I know where the misunderstanding comes from: |
This PR adds
Nan::New<v8::String>(std::string_view), which makes it easier to handle compile time known strings.In order to maintan backwards compatibility to C++11, a
NAN_HAS_CPLUSPLUS_17macro is added (which will also be needed for my next PRs), the code is wrapped intoNAN_ENABLE_STRING_VIEWguards. If the user wishes to disable the usage of string_view, it can be disabled via adding a define-DNAN_ENABLE_STRING_VIEW=false, otherwise it is automatically enabled if it's supported by the C++ runtime (C++17 and up)