GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add a note on usage scope of AliasedBuffer · nodejs/node@3d1853b

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • CPP_STYLE_GUIDE.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎CPP_STYLE_GUIDE.md‎

Copy file name to clipboardExpand all lines: CPP_STYLE_GUIDE.md
+17Lines changed: 17 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* [Use explicit pointer comparisons](#use-explicit-pointer-comparisons)
2222
* [Ownership and Smart Pointers](#ownership-and-smart-pointers)
2323
* [Avoid non-const references](#avoid-non-const-references)
24+
* [Use AliasedBuffers to manipulate TypedArrays](#use-aliasedbuffers-to-manipulate-typedarrays)
2425
* [Others](#others)
2526
* [Type casting](#type-casting)
2627
* [Using `auto`](#using-auto)
@@ -257,6 +258,21 @@ class ExampleClass {
257258
};
258259
```
259260

261+
### Use AliasedBuffers to manipulate TypedArrays
262+
263+
When working with typed arrays that involve direct data modification
264+
from C++, use an `AliasedBuffer` when possible. The API abstraction and
265+
the usage scope of `AliasedBuffer` are 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+
260276
## Others
261277

262278
### Type casting
@@ -382,3 +398,4 @@ even `try` and `catch` **will** break.
382398
[Run Time Type Information]: https://en.wikipedia.org/wiki/Run-time_type_information
383399
[cppref_auto_ptr]: https://en.cppreference.com/w/cpp/memory/auto_ptr
384400
[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

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.