<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.12: http://docutils.sourceforge.net/" />
<title>P0334r0 : Immutable Persistent Containers</title>
<meta name="date" content="2016-04-24" />
<meta name="author" content="Bryce Adelstein Lelbach" />
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 7614 2013-02-21 15:55:51Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0 }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 ! important }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 ! important }

.last, .with-subtitle {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dl.docutils dd {
  margin-bottom: 0.5em }

object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
  overflow: hidden;
}

/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
  font-weight: bold }
*/

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title, .code .error {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

/* Uncomment (and remove this text!) to get reduced vertical space in
   compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
  margin-bottom: 0.5em }

div.compound .compound-last, div.compound .compound-middle {
  margin-top: 0.5em }
*/

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em ;
  margin-right: 2em }

div.footer, div.header {
  clear: both;
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin: 0 0 0.5em 1em ;
  border: medium outset ;
  padding: 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  margin-top: 0.4em }

h1.title {
  text-align: center }

h2.subtitle {
  text-align: center }

hr.docutils {
  width: 75% }

img.align-left, .figure.align-left, object.align-left {
  clear: left ;
  float: left ;
  margin-right: 1em }

img.align-right, .figure.align-right, object.align-right {
  clear: right ;
  float: right ;
  margin-left: 1em }

img.align-center, .figure.align-center, object.align-center {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.align-left {
  text-align: left }

.align-center {
  clear: both ;
  text-align: center }

.align-right {
  text-align: right }

/* reset inner alignment in figures */
div.align-right {
  text-align: inherit }

/* div.align-center * { */
/*   text-align: left } */

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font: inherit }

pre.literal-block, pre.doctest-block, pre.math, pre.code {
  margin-left: 2em ;
  margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
pre.code .literal.string, code .literal.string { color: #0C5404 }
pre.code .name.builtin, code .name.builtin { color: #352B84 }
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80% }

table.citation {
  border-left: solid 1px gray;
  margin-left: 1px }

table.docinfo {
  margin: 2em 4em }

table.docutils {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.footnote {
  border-left: solid 1px black;
  margin-left: 1px }

table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

table.docutils th.field-name, table.docinfo th.docinfo-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap ;
  padding-left: 0 }

/* "booktabs" style (no vertical lines) */
table.docutils.booktabs {
  border: 0px;
  border-top: 2px solid;
  border-bottom: 2px solid;
  border-collapse: collapse;
}
table.docutils.booktabs * {
  border: 0px;
}
table.docutils.booktabs th {
  border-bottom: thin solid;
  text-align: left;
}

h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  font-size: 100% }

ul.auto-toc {
  list-style-type: none }

</style>
</head>
<body>
<div class="document" id="p0334r0-immutable-persistent-containers">
<h1 class="title">P0334r0 : Immutable Persistent Containers</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr class="field"><th class="docinfo-name">Project:</th><td class="field-body">ISO JTC1/SC22/WG21: Programming Language C++</td>
</tr>
<tr class="field"><th class="docinfo-name">Number:</th><td class="field-body">P0334r0</td>
</tr>
<tr><th class="docinfo-name">Date:</th>
<td>2016-04-24</td></tr>
<tr class="field"><th class="docinfo-name">Reply-to:</th><td class="field-body"><a class="reference external" href="mailto:balelbach&#64;lbl.gov">balelbach&#64;lbl.gov</a></td>
</tr>
<tr><th class="docinfo-name">Author:</th>
<td>Bryce Adelstein Lelbach</td></tr>
<tr><th class="docinfo-name">Contact:</th>
<td><a class="first last reference external" href="mailto:balelbach&#64;lbl.gov">balelbach&#64;lbl.gov</a></td></tr>
<tr class="field"><th class="docinfo-name">Audience:</th><td class="field-body">Library Evolution Working Group (LEWG)</td>
</tr>
<tr class="field"><th class="docinfo-name">URL:</th><td class="field-body"><a class="reference external" href="https://git.io/vr7qi">https://git.io/vr7qi</a></td>
</tr>
</tbody>
</table>
<div class="section" id="motivation">
<h1>1&nbsp;&nbsp;&nbsp;Motivation</h1>
<p>While discussing a more general-purpose <tt class="docutils literal">exception_list</tt> (see P0322), my co-authors
and I began to explore the broader design space of immutable, persistent containers.
These data structures, prevalent in functional programming languages, such as Haskell
or Lisp, are useful in parallel programming contexts as they are inherently
safe to access concurrently (because they cannot be modified).</p>
</div>
<div class="section" id="design">
<h1>2&nbsp;&nbsp;&nbsp;Design</h1>
<p>The basic properties of an immutable container are the following:</p>
<ul class="simple">
<li>Cheap to &quot;copy&quot;, &quot;concatenate&quot; and &quot;split&quot;. Typically a &quot;copy&quot; operation is merely a copy of a reference-counted pointer (in languages like Haskell, garbage collection is used).</li>
<li>When &quot;modifying&quot; the container, older versions of the container stay around (e.g. persistent). No operation is truly mutating.</li>
</ul>
<p>From these properties, it is straightforward to see where immutable containers might be useful:</p>
<ul class="simple">
<li>When we want containers provide efficient concatenation and splitting
operations - for example, <a class="reference external" href="https://www.sgi.com/tech/stl/Rope.html">the rope&lt;&gt; string class from SGI's STL library</a>. Such a data structure can very
useful when implementing a text editor or parser.</li>
<li>When we want containers which are safe to use in parallel contexts - for
example, <tt class="docutils literal">exception_list</tt> could be an immutable list. Immutable data
structures do not rely on synchronization primitives such as mutexes or
atomics. Concurrent access is safe because all concurrent accesses are reads.
However, using immutable data structures for concurrency places restricts the
form of the parallel algorithms operating on the immutable data structures.
Other concurrent data structures (such as a theoretical <tt class="docutils literal">atomic_list&lt;&gt;</tt>)
would arguably be more flexible, at the cost of being forced to use
synchronization primitives to protect the data structure. However, immutable
data structures are a powerful tool for parallel programmers to have in their
pocket, and we should consider adding them to the language to support this
use case.</li>
</ul>
<p>In Haskell, immutable sequences are implemented using <a class="reference external" href="http://www.staff.city.ac.uk/~ross/papers/FingerTree.html">2-3 finger trees</a>.  These trees
allow for constant time access to and insertion at the ends of the sequence and
logarithmic time splitting and concatenation. A non-lazy, reference-counted
implementation of 2-3 finger trees would be one possible way of efficiently
implementing <tt class="docutils literal">rope&lt;&gt;</tt> and <tt class="docutils literal">exception_list</tt> in C++. Other algorithms allow
for constant time concatenation at the cost of linear time splitting.</p>
<p>As far as interface design, for <tt class="docutils literal">exception_list</tt> we decided to provide the
traditional <tt class="docutils literal">Container</tt> interfaces for accessing elements and properties of
the container. We created a set of constructors which allow for splitting and
concatenation. Alternatively, a set of free function interfaces serve as the
interface for this functionality. This design could be extended from
<tt class="docutils literal">exception_list</tt> (a sequence of <tt class="docutils literal">exception_ptrs</tt>) to <tt class="docutils literal">immutable_list&lt;T&gt;</tt>
(a sequence of <tt class="docutils literal">Ts</tt>) and other possible immutable types (such as a
<tt class="docutils literal">rope&lt;&gt;</tt>-like type).</p>
<p>A draft specification for an <tt class="docutils literal">immutable_list&lt;&gt;</tt> is provided below. It is
intended to be implemented with a referenced-counted tree structure such as
a 2-3 finger tree; complexity guarantees reflect this. The move constructor and
move assignment operator have been deleted, as they are modifying operations
and <tt class="docutils literal">immutable_list&lt;&gt;</tt> is an immutable type.</p>
</div>
<div class="section" id="specification">
<h1>3&nbsp;&nbsp;&nbsp;Specification</h1>
<pre class="code c++ literal-block">
<span class="keyword">namespace</span> <span class="name">std</span> <span class="punctuation">{</span>

<span class="keyword">template</span> <span class="operator">&lt;</span><span class="keyword">class</span> <span class="name class">T</span><span class="punctuation">,</span> <span class="keyword">class</span> <span class="name class">Allocator</span> <span class="operator">=</span> <span class="name">std</span><span class="operator">::</span><span class="name">allocator</span><span class="operator">&lt;</span><span class="name">T</span><span class="operator">&gt;</span> <span class="operator">&gt;</span>
<span class="keyword">class</span> <span class="name class">immutable_list</span>
<span class="punctuation">{</span>
  <span class="keyword">public</span><span class="operator">:</span>
    <span class="keyword">typedef</span> <span class="name">T</span> <span class="name">value_type</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="name">Allocator</span> <span class="name">allocator_type</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="comment multiline">/*** unspecified ***/</span> <span class="name">size_type</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="comment multiline">/*** unspecified ***/</span> <span class="name">difference_type</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="name">value_type</span><span class="operator">&amp;</span> <span class="name">reference</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="name">value_type</span> <span class="keyword">const</span><span class="operator">&amp;</span> <span class="name">const_reference</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="name">allocator_traits</span><span class="operator">&lt;</span><span class="name">Allocator</span><span class="operator">&gt;::</span><span class="name">pointer</span> <span class="name">pointer</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="keyword">typename</span> <span class="name">allocator_traits</span><span class="operator">&lt;</span><span class="name">Allocator</span><span class="operator">&gt;::</span><span class="name">const_pointer</span> <span class="name">const_pointer</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="comment multiline">/*** unspecified ***/</span> <span class="name">iterator</span><span class="punctuation">;</span>
    <span class="keyword">typedef</span> <span class="comment multiline">/*** unspecified ***/</span> <span class="name">const_iterator</span><span class="punctuation">;</span>

    <span class="comment single">/////////////////////////////////////////////////////////////////////////
</span>    <span class="comment single">// CONSTRUCTORS
</span>
    <span class="keyword">constexpr</span> <span class="name function">immutable_list</span><span class="punctuation">()</span> <span class="keyword">noexcept</span> <span class="operator">=</span> <span class="keyword">default</span><span class="punctuation">;</span>

    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other</span><span class="punctuation">);</span>
    <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="keyword">operator</span><span class="operator">=</span><span class="punctuation">(</span><span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other</span><span class="punctuation">);</span>

    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="name">immutable_list</span><span class="operator">&amp;&amp;</span><span class="punctuation">)</span> <span class="operator">=</span> <span class="keyword">delete</span>
    <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="keyword">operator</span><span class="operator">=</span><span class="punctuation">(</span><span class="name">immutable_list</span><span class="operator">&amp;&amp;</span><span class="punctuation">)</span> <span class="operator">=</span> <span class="keyword">delete</span><span class="punctuation">;</span>

    <span class="comment single">// &quot;push_back&quot; and &quot;emplace_back&quot; constructors
</span>    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="name">T</span> <span class="keyword">const</span><span class="operator">&amp;</span> <span class="name">v</span><span class="punctuation">);</span>
    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="name">T</span><span class="operator">&amp;&amp;</span> <span class="name">v</span><span class="punctuation">);</span>
    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other</span><span class="punctuation">,</span> <span class="name">T</span> <span class="keyword">const</span><span class="operator">&amp;</span> <span class="name">v</span><span class="punctuation">);</span>
    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other</span><span class="punctuation">,</span> <span class="name">T</span><span class="operator">&amp;&amp;</span> <span class="name">v</span><span class="punctuation">);</span>

    <span class="comment single">// iterator-pair &quot;insert&quot; constructors
</span>    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="name">iterator</span> <span class="name">first</span><span class="punctuation">,</span> <span class="name">iterator</span> <span class="name">last</span><span class="punctuation">);</span>
    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other</span><span class="punctuation">,</span>
                   <span class="name">iterator</span> <span class="name">first</span><span class="punctuation">,</span> <span class="name">iterator</span> <span class="name">last</span><span class="punctuation">);</span>
    <span class="keyword">template</span> <span class="operator">&lt;</span><span class="keyword">class</span> <span class="name class">InputIterator</span><span class="operator">&gt;</span>
    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="name">InputIterator</span> <span class="name">first</span><span class="punctuation">,</span> <span class="name">InputIterator</span> <span class="name">last</span><span class="punctuation">);</span>
    <span class="keyword">template</span> <span class="operator">&lt;</span><span class="keyword">class</span> <span class="name class">InputIterator</span><span class="operator">&gt;</span>
    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other</span><span class="punctuation">,</span>
                   <span class="name">InputIterator</span> <span class="name">first</span><span class="punctuation">,</span> <span class="name">InputIterator</span> <span class="name">last</span><span class="punctuation">);</span>

    <span class="comment single">// initializer-list &quot;insert&quot; constructors
</span>    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="name">initializer_list</span><span class="operator">&lt;</span><span class="name">T</span><span class="operator">&gt;</span> <span class="name">list</span><span class="punctuation">);</span>
    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other</span><span class="punctuation">,</span>
                   <span class="name">initializer_list</span><span class="operator">&lt;</span><span class="name">T</span><span class="operator">&gt;</span> <span class="name">list</span><span class="punctuation">);</span>

    <span class="comment single">// &quot;splice&quot; constructor
</span>    <span class="name">immutable_list</span><span class="punctuation">(</span><span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other0</span><span class="punctuation">,</span>
                   <span class="keyword">const</span> <span class="name">immutable_list</span><span class="operator">&amp;</span> <span class="name">other1</span><span class="punctuation">)</span> <span class="keyword">noexcept</span><span class="punctuation">;</span>

    <span class="comment single">/////////////////////////////////////////////////////////////////////////
</span>    <span class="comment single">// QUERY INTERFACE
</span>
    <span class="name">size_type</span> <span class="name function">size</span><span class="punctuation">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="punctuation">;</span>

    <span class="name">iterator</span> <span class="name function">begin</span><span class="punctuation">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="punctuation">;</span>
    <span class="name">iterator</span> <span class="name function">cbegin</span><span class="punctuation">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="punctuation">;</span>

    <span class="name">iterator</span> <span class="name function">end</span><span class="punctuation">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="punctuation">;</span>
    <span class="name">iterator</span> <span class="name function">cend</span><span class="punctuation">()</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="punctuation">;</span>

<span class="punctuation">};</span>

<span class="punctuation">}</span>
</pre>
<!--  -->
<p>The class <tt class="docutils literal">immutable_list&lt;T&gt;</tt> owns a sequence of <tt class="docutils literal">T</tt> objects.</p>
<p>The type <tt class="docutils literal"><span class="pre">immutable_list&lt;T&gt;::iterator</span></tt> shall fulfill the requirements of
<tt class="docutils literal">ForwardIterator</tt>.</p>
<p>The type <tt class="docutils literal"><span class="pre">immutable_list&lt;T&gt;::size_type</span></tt> shall be an unsigned integral type
large enough to represent the size of the sequence.</p>
<p>The type <tt class="docutils literal"><span class="pre">immutable_list&lt;T&gt;::difference_type</span></tt> shall be an unsigned integral type
large enough to represent distances between iterators to the sequence.</p>
<p><tt class="docutils literal">constexpr immutable_list() noexcept = default;</tt></p>
<blockquote>
<em>Effect</em>: Construct an empty <tt class="docutils literal">immutable_list</tt>.</blockquote>
<p><tt class="docutils literal">immutable_list(const immutable_list&amp; other);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which is a copy of <tt class="docutils literal">other</tt>.</p>
<p><em>Complexity</em>: Linear time in the size of <tt class="docutils literal">other</tt>.</p>
<p><em>Complexity</em>: Constant time.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list&amp; <span class="pre">operator=(const</span> immutable_list&amp; other);</tt></p>
<blockquote>
<p><em>Effect</em>: Copy the contents of <tt class="docutils literal">other</tt> into this <tt class="docutils literal">immutable_list</tt>.</p>
<p><em>Complexity</em>: Linear time in the size of <tt class="docutils literal">other</tt>.</p>
<p><em>Complexity</em>: Constant time.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(T const&amp; v);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which contains a single element
which is a copy of <tt class="docutils literal">v</tt>.</p>
<p><em>Complexity</em>: Constant time.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(T&amp;&amp; v);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which contains a single element
which has been moved from <tt class="docutils literal">v</tt>..</p>
<p><em>Complexity</em>: Constant time.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(const immutable_list&amp; other, T const&amp; v);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which is a copy of <tt class="docutils literal">other</tt>,
and append a new element which is a copy of <tt class="docutils literal">v</tt> to the end of the owned
sequence.</p>
<p><em>Complexity</em>: Linear in the size of <tt class="docutils literal">other</tt> + 1.</p>
<p><em>Complexity</em>: Constant time.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(const immutable_list&amp; other, T&amp;&amp; v);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which is a copy of <tt class="docutils literal">other</tt>,
and append a new element which is moved from <tt class="docutils literal">v</tt> to the end of the owned
sequence.</p>
<p><em>Complexity</em>: Linear in the size of <tt class="docutils literal">other</tt> + 1.</p>
<p><em>Complexity</em>: Constant time.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(iterator first, iterator last);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which contains
<tt class="docutils literal">distance(first, last)</tt> elements from the range <tt class="docutils literal">[first, last)</tt>.</p>
<p><em>Complexity</em>: Logarthmic in <tt class="docutils literal">distance(first, last)</tt>.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(const immutable_list&amp; other, iterator first, iterator last);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which is a copy of <tt class="docutils literal">other</tt>,
and append the range <tt class="docutils literal">[first, last)</tt> to the end of the owned sequence.</p>
<p><em>Complexity</em>: Logarthmic in <tt class="docutils literal"><span class="pre">min(other.size(),</span> distance(first, last))</tt>.</p>
</blockquote>
<p><tt class="docutils literal">template &lt;class InputIterator&gt;</tt></p>
<p><tt class="docutils literal">immutable_list(InputIterator first, InputIterator last);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which contains
<tt class="docutils literal">distance(first, last)</tt> elements from the range <tt class="docutils literal">[first, last)</tt>.</p>
<p><em>Complexity</em>: Linear in <tt class="docutils literal">distance(first, last)</tt>.</p>
<p><em>Remarks</em>: This constructor shall not participate in overload resolution if
<tt class="docutils literal">is_convertible_v&lt;typename <span class="pre">InputIterator::value_type,</span> T&gt; == false</tt>.</p>
</blockquote>
<p><tt class="docutils literal">template &lt;class InputIterator&gt;</tt></p>
<p><tt class="docutils literal">immutable_list(const immutable_list&amp; other, InputIterator first, InputIterator last);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which is a copy of <tt class="docutils literal">other</tt>,
and append the range <tt class="docutils literal">[first, last)</tt> to the end of the owned sequence.</p>
<p><em>Complexity</em>: Linear in <tt class="docutils literal">distance(first, last)</tt>.</p>
<p><em>Remarks</em>: This constructor shall not participate in overload resolution if
<tt class="docutils literal">is_convertible_v&lt;typename <span class="pre">InputIterator::value_type,</span> T&gt; == false</tt>.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(initializer_list&lt;T&gt; list);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which contains <tt class="docutils literal">list.size()</tt>
elements from <tt class="docutils literal">list</tt>.</p>
<p><em>Complexity</em>: Linear in the size of <tt class="docutils literal">list</tt>.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(const immutable_list&amp; other, initializer_list&lt;T&gt; list);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which is a copy of <tt class="docutils literal">other</tt>,
and append <tt class="docutils literal">list</tt> to the end of the owned sequence.</p>
<p><em>Complexity</em>: Linear in the size of <tt class="docutils literal">list</tt>.</p>
</blockquote>
<p><tt class="docutils literal">immutable_list(const immutable_list&amp; other0, const immutable_list&amp; other1);</tt></p>
<blockquote>
<p><em>Effect</em>: Construct a new <tt class="docutils literal">immutable_list</tt> which contains all the elements
of <tt class="docutils literal">other0</tt> followed by all the elements of <tt class="docutils literal">other1</tt>.</p>
<p><em>Complexity</em>: Logarthmic in the <tt class="docutils literal"><span class="pre">min(other0.size(),</span> <span class="pre">other1.size())</span></tt>.</p>
</blockquote>
<p><tt class="docutils literal">size_type size() const noexcept;</tt></p>
<blockquote>
<p><em>Returns</em>: The number of <tt class="docutils literal">T</tt> objects contained within the
<tt class="docutils literal">immutable_list</tt>.</p>
<p><em>Complexity</em>: Constant time.</p>
</blockquote>
<p><tt class="docutils literal">iterator begin() const noexcept;</tt></p>
<p><tt class="docutils literal">iterator cbegin() const noexcept;</tt></p>
<blockquote>
<em>Returns</em>: An iterator referring to the first <tt class="docutils literal">T</tt> object
contained within the <tt class="docutils literal">immutable_list</tt>.</blockquote>
<p><tt class="docutils literal">iterator end() const noexcept;</tt></p>
<p><tt class="docutils literal">iterator cend() const noexcept;</tt></p>
<blockquote>
<em>Returns</em>: An iterator that is past the end of the owned sequence.</blockquote>
</div>
</div>
</body>
</html>
