File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 5353
5454#define NAN_HAS_CPLUSPLUS_17 (__cplusplus >= 201703L )
5555
56+ #ifndef NAN_ENABLE_STRING_VIEW
57+ # define NAN_ENABLE_STRING_VIEW NAN_HAS_CPLUSPLUS_17
58+ #endif
59+
5660#include < uv.h>
5761#include < node.h>
5862#include < node_buffer.h>
7478# include < string>
7579# include < vector>
7680#endif
81+ #if NAN_ENABLE_STRING_VIEW
82+ # include < string_view>
83+ #endif
7784
7885// uv helpers
7986#ifdef UV_VERSION_MAJOR
Original file line number Diff line number Diff line change @@ -161,6 +161,9 @@ struct Factory<v8::String> : MaybeFactoryBase<v8::String> {
161161 static inline return_t New (const char *value, int length = -1 );
162162 static inline return_t New (const uint16_t *value, int length = -1 );
163163 static inline return_t New (std::string const & value);
164+ #if NAN_ENABLE_STRING_VIEW
165+ static inline return_t New (std::string_view value);
166+ #endif
164167
165168 static inline return_t New (v8::String::ExternalStringResource * value);
166169 static inline return_t New (ExternalOneByteStringResource * value);
@@ -289,6 +292,14 @@ New(double value) {
289292 return New<v8::Number>(value);
290293}
291294
295+ #if NAN_ENABLE_STRING_VIEW
296+ inline
297+ imp::Factory<v8::String>::return_t
298+ New (std::string_view value) {
299+ return New<v8::String>(value.data (), value.length ());
300+ }
301+ #endif
302+
292303inline
293304imp::Factory<v8::String>::return_t
294305New (std::string const & value) { // NOLINT(build/include_what_you_use)
You can’t perform that action at this time.
0 commit comments