File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 21
21
* [ Use explicit pointer comparisons] ( #use-explicit-pointer-comparisons )
22
22
* [ Ownership and Smart Pointers] ( #ownership-and-smart-pointers )
23
23
* [ Avoid non-const references] ( #avoid-non-const-references )
24
+ * [ Use AliasedBuffers to manipulate TypedArrays] ( #use-aliasedbuffers-to-manipulate-typedarrays )
24
25
* [ Others] ( #others )
25
26
* [ Type casting] ( #type-casting )
26
27
* [ Using ` auto ` ] ( #using-auto )
@@ -257,6 +258,21 @@ class ExampleClass {
257
258
};
258
259
```
259
260
261
+ ### Use AliasedBuffers to manipulate TypedArrays
262
+
263
+ When working with typed arrays that involves direct data modification
264
+ from C++, use an AliasedBuffer when possible. The API abstraction and
265
+ the usage scope of AliasedBuffer is documented in [ aliased_buffer.h] [ ] .
266
+
267
+ ``` c++
268
+ // Create an AliasedBuffer
269
+ AliasedBuffer<uint32_t , v8::Uint32Array> data;
270
+ ...
271
+
272
+ // Modify the data through natural operator semantics.
273
+ data[0 ] = 12345 ;
274
+ ```
275
+
260
276
## Others
261
277
262
278
### Type casting
@@ -382,3 +398,4 @@ even `try` and `catch` **will** break.
382
398
[ Run Time Type Information ] : https://en.wikipedia.org/wiki/Run-time_type_information
383
399
[ cppref_auto_ptr ] : https://en.cppreference.com/w/cpp/memory/auto_ptr
384
400
[ without C++ exception handling ] : https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html#intro.using.exception.no
401
+ [ aliased_buffer.h ] : https://github.com/nodejs/node/blob/master/src/aliased_buffer.h#L12
You can’t perform that action at this time.
0 commit comments