% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/altrep.R
\name{as_shared}
\alias{as_shared}
\title{Create a shared vector from an existing R vector}
\usage{
as_shared(x, readonly = TRUE, backing = "auto", cow = NULL)
}
\arguments{
\item{x}{An atomic vector (integer, double, logical, or raw)}

\item{readonly}{If TRUE, prevent write access (default: TRUE)}

\item{backing}{Backing type for the segment: "auto", "mmap", or "shm"}

\item{cow}{Copy-on-write policy for the resulting shared vector. One of
\code{"deny"}, \code{"audit"}, or \code{"allow"}. If NULL, defaults based on \code{readonly}.}
}
\value{
An ALTREP vector backed by shared memory
}
\description{
Convenience function that creates a segment, writes the data,
and returns an ALTREP view.
}
\examples{
\donttest{
x <- as_shared(1:100)
is_shared_vector(x)

y <- x[1:10]
is_shared_vector(y)
}
}
