FIND YOUR NEXT FEW LINES

Results for “owner”

Small, practical examples. Search by task or narrow things down below.

36 snippets foundClear filters
RustGetting Started

Borrow text without transferring ownership

Borrow text without transferring ownership in a complete Rust program using the standard library.

Rust✓ Tested
Linux CommandsFiles & permissions

Make a script executable by its owner

Linux Commands: Add the owner execute bit without replacing all permission bits.

Linux Commands✓ Tested
C++Ownership & optional values

Observe shared ownership without extending its lifetime

C++: A weak_ptr can be locked while an owner exists and becomes expired after the last owner is released.

C++✓ Tested
Docker / ComposeDockerfile patterns

Set copied files’ numeric ownership

Docker / Compose: COPY --chown sets ownership while adding the file.

Docker / Compose✓ Tested
Linux CommandsFiles & permissions

Set owner-only file permissions

Linux Commands: Use chmod 600 to allow only the owner to read and write a file.

Linux Commands✓ Tested
C++Filesystem operations

Set owner-only read and write permissions

C++: Replace ordinary permission bits with the requested owner permissions.

C++✓ Tested
C++Ownership & optional values

Share ownership with a counted smart pointer

C++: Copies of shared_ptr keep the owned value alive until the last owner is released.

C++✓ Tested
C++Ownership & optional values

Transfer unique ownership with move

C++: Moving a unique_ptr leaves the source empty and gives ownership to the destination.

C++✓ Tested
CDynamic memory & ownership

Allocate an independent copy of a C string

C: Include one extra byte for the terminating null character.

C✓ Tested
CDynamic memory & ownership

Allocate and free a typed array

C: Use sizeof on the pointed-to type and check allocation success before writing.

C✓ Tested
CDynamic memory & ownership

Allocate and initialize a structure

C: Use a compound literal assignment to initialize all ordinary structure fields.

C✓ Tested
C++Ownership & optional values

Apply an operation to a variant’s active value

C++: A generic visitor lets the compiler check behavior for every possible alternative.

C++✓ Tested