blob: a436ae2cee43b2a969ceb413edec1cb04337f079 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="AsciiDoc 8.6.9">
<title>The OpenCL C++ 1.0 Specification</title>
<style type="text/css">
/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
/* Default font. */
body {
font-family: Georgia,serif;
}
/* Title font. */
h1, h2, h3, h4, h5, h6,
div.title, caption.title,
thead, p.table.header,
#toctitle,
#author, #revnumber, #revdate, #revremark,
#footer {
font-family: Arial,Helvetica,sans-serif;
}
body {
margin: 1em 5% 1em 5%;
}
a {
color: blue;
text-decoration: underline;
}
a:visited {
color: fuchsia;
}
em {
font-style: italic;
color: navy;
}
strong {
font-weight: bold;
color: #083194;
}
h1, h2, h3, h4, h5, h6 {
color: #527bbd;
margin-top: 1.2em;
margin-bottom: 0.5em;
line-height: 1.3;
}
h1, h2, h3 {
border-bottom: 2px solid silver;
}
h2 {
padding-top: 0.5em;
}
h3 {
float: left;
}
h3 + * {
clear: left;
}
h5 {
font-size: 1.0em;
}
div.sectionbody {
margin-left: 0;
}
hr {
border: 1px solid silver;
}
p {
margin-top: 0.5em;
margin-bottom: 0.5em;
}
ul, ol, li > p {
margin-top: 0;
}
ul > li { color: #aaa; }
ul > li > * { color: black; }
.monospaced, code, pre {
font-family: "Courier New", Courier, monospace;
font-size: inherit;
color: navy;
padding: 0;
margin: 0;
}
pre {
white-space: pre-wrap;
}
#author {
color: #527bbd;
font-weight: bold;
font-size: 1.1em;
}
#email {
}
#revnumber, #revdate, #revremark {
}
#footer {
font-size: small;
border-top: 2px solid silver;
padding-top: 0.5em;
margin-top: 4.0em;
}
#footer-text {
float: left;
padding-bottom: 0.5em;
}
#footer-badges {
float: right;
padding-bottom: 0.5em;
}
#preamble {
margin-top: 1.5em;
margin-bottom: 1.5em;
}
div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
margin-top: 1.0em;
margin-bottom: 1.5em;
}
div.admonitionblock {
margin-top: 2.0em;
margin-bottom: 2.0em;
margin-right: 10%;
color: #606060;
}
div.content { /* Block element content. */
padding: 0;
}
/* Block element titles. */
div.title, caption.title {
color: #527bbd;
font-weight: bold;
text-align: left;
margin-top: 1.0em;
margin-bottom: 0.5em;
}
div.title + * {
margin-top: 0;
}
td div.title:first-child {
margin-top: 0.0em;
}
div.content div.title:first-child {
margin-top: 0.0em;
}
div.content + div.title {
margin-top: 0.0em;
}
div.sidebarblock > div.content {
background: #ffffee;
border: 1px solid #dddddd;
border-left: 4px solid #f0f0f0;
padding: 0.5em;
}
div.listingblock > div.content {
border: 1px solid #dddddd;
border-left: 5px solid #f0f0f0;
background: #f8f8f8;
padding: 0.5em;
}
div.quoteblock, div.verseblock {
padding-left: 1.0em;
margin-left: 1.0em;
margin-right: 10%;
border-left: 5px solid #f0f0f0;
color: #888;
}
div.quoteblock > div.attribution {
padding-top: 0.5em;
text-align: right;
}
div.verseblock > pre.content {
font-family: inherit;
font-size: inherit;
}
div.verseblock > div.attribution {
padding-top: 0.75em;
text-align: left;
}
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
div.verseblock + div.attribution {
text-align: left;
}
div.admonitionblock .icon {
vertical-align: top;
font-size: 1.1em;
font-weight: bold;
text-decoration: underline;
color: #527bbd;
padding-right: 0.5em;
}
div.admonitionblock td.content {
padding-left: 0.5em;
border-left: 3px solid #dddddd;
}
div.exampleblock > div.content {
border-left: 3px solid #dddddd;
padding-left: 0.5em;
}
div.imageblock div.content { padding-left: 0; }
span.image img { border-style: none; vertical-align: text-bottom; }
a.image:visited { color: white; }
dl {
margin-top: 0.8em;
margin-bottom: 0.8em;
}
dt {
margin-top: 0.5em;
margin-bottom: 0;
font-style: normal;
color: navy;
}
dd > *:first-child {
margin-top: 0.1em;
}
ul, ol {
list-style-position: outside;
}
ol.arabic {
list-style-type: decimal;
}
ol.loweralpha {
list-style-type: lower-alpha;
}
ol.upperalpha {
list-style-type: upper-alpha;
}
ol.lowerroman {
list-style-type: lower-roman;
}
ol.upperroman {
list-style-type: upper-roman;
}
div.compact ul, div.compact ol,
div.compact p, div.compact p,
div.compact div, div.compact div {
margin-top: 0.1em;
margin-bottom: 0.1em;
}
tfoot {
font-weight: bold;
}
td > div.verse {
white-space: pre;
}
div.hdlist {
margin-top: 0.8em;
margin-bottom: 0.8em;
}
div.hdlist tr {
padding-bottom: 15px;
}
dt.hdlist1.strong, td.hdlist1.strong {
font-weight: bold;
}
td.hdlist1 {
vertical-align: top;
font-style: normal;
padding-right: 0.8em;
color: navy;
}
td.hdlist2 {
vertical-align: top;
}
div.hdlist.compact tr {
margin: 0;
padding-bottom: 0;
}
.comment {
background: yellow;
}
.footnote, .footnoteref {
font-size: 0.8em;
}
span.footnote, span.footnoteref {
vertical-align: super;
}
#footnotes {
margin: 20px 0 20px 0;
padding: 7px 0 0 0;
}
#footnotes div.footnote {
margin: 0 0 5px 0;
}
#footnotes hr {
border: none;
border-top: 1px solid silver;
height: 1px;
text-align: left;
margin-left: 0;
width: 20%;
min-width: 100px;
}
div.colist td {
padding-right: 0.5em;
padding-bottom: 0.3em;
vertical-align: top;
}
div.colist td img {
margin-top: 0.3em;
}
@media print {
#footer-badges { display: none; }
}
#toc {
margin-bottom: 2.5em;
}
#toctitle {
color: #527bbd;
font-size: 1.1em;
font-weight: bold;
margin-top: 1.0em;
margin-bottom: 0.1em;
}
div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
margin-top: 0;
margin-bottom: 0;
}
div.toclevel2 {
margin-left: 2em;
font-size: 0.9em;
}
div.toclevel3 {
margin-left: 4em;
font-size: 0.9em;
}
div.toclevel4 {
margin-left: 6em;
font-size: 0.9em;
}
span.aqua { color: aqua; }
span.black { color: black; }
span.blue { color: blue; }
span.fuchsia { color: fuchsia; }
span.gray { color: gray; }
span.green { color: green; }
span.lime { color: lime; }
span.maroon { color: maroon; }
span.navy { color: navy; }
span.olive { color: olive; }
span.purple { color: purple; }
span.red { color: red; }
span.silver { color: silver; }
span.teal { color: teal; }
span.white { color: white; }
span.yellow { color: yellow; }
span.aqua-background { background: aqua; }
span.black-background { background: black; }
span.blue-background { background: blue; }
span.fuchsia-background { background: fuchsia; }
span.gray-background { background: gray; }
span.green-background { background: green; }
span.lime-background { background: lime; }
span.maroon-background { background: maroon; }
span.navy-background { background: navy; }
span.olive-background { background: olive; }
span.purple-background { background: purple; }
span.red-background { background: red; }
span.silver-background { background: silver; }
span.teal-background { background: teal; }
span.white-background { background: white; }
span.yellow-background { background: yellow; }
span.big { font-size: 2em; }
span.small { font-size: 0.6em; }
span.underline { text-decoration: underline; }
span.overline { text-decoration: overline; }
span.line-through { text-decoration: line-through; }
div.unbreakable { page-break-inside: avoid; }
/*
* xhtml11 specific
*
* */
div.tableblock {
margin-top: 1.0em;
margin-bottom: 1.5em;
}
div.tableblock > table {
border: 3px solid #527bbd;
}
thead, p.table.header {
font-weight: bold;
color: #527bbd;
}
p.table {
margin-top: 0;
}
/* Because the table frame attribute is overriden by CSS in most browsers. */
div.tableblock > table[frame="void"] {
border-style: none;
}
div.tableblock > table[frame="hsides"] {
border-left-style: none;
border-right-style: none;
}
div.tableblock > table[frame="vsides"] {
border-top-style: none;
border-bottom-style: none;
}
/*
* html5 specific
*
* */
table.tableblock {
margin-top: 1.0em;
margin-bottom: 1.5em;
}
thead, p.tableblock.header {
font-weight: bold;
color: #527bbd;
}
p.tableblock {
margin-top: 0;
}
table.tableblock {
border-width: 3px;
border-spacing: 0px;
border-style: solid;
border-color: #527bbd;
border-collapse: collapse;
}
th.tableblock, td.tableblock {
border-width: 1px;
padding: 4px;
border-style: solid;
border-color: #527bbd;
}
table.tableblock.frame-topbot {
border-left-style: hidden;
border-right-style: hidden;
}
table.tableblock.frame-sides {
border-top-style: hidden;
border-bottom-style: hidden;
}
table.tableblock.frame-none {
border-style: hidden;
}
th.tableblock.halign-left, td.tableblock.halign-left {
text-align: left;
}
th.tableblock.halign-center, td.tableblock.halign-center {
text-align: center;
}
th.tableblock.halign-right, td.tableblock.halign-right {
text-align: right;
}
th.tableblock.valign-top, td.tableblock.valign-top {
vertical-align: top;
}
th.tableblock.valign-middle, td.tableblock.valign-middle {
vertical-align: middle;
}
th.tableblock.valign-bottom, td.tableblock.valign-bottom {
vertical-align: bottom;
}
/*
* manpage specific
*
* */
body.manpage h1 {
padding-top: 0.5em;
padding-bottom: 0.5em;
border-top: 2px solid silver;
border-bottom: 2px solid silver;
}
body.manpage h2 {
border-style: none;
}
body.manpage div.sectionbody {
margin-left: 3em;
}
@media print {
body.manpage div#toc { display: none; }
}
@media screen {
body {
max-width: 50em; /* approximately 80 characters wide */
margin-left: 16em;
}
#toc {
position: fixed;
top: 0;
left: 0;
bottom: 0;
width: 13em;
padding: 0.5em;
padding-bottom: 1.5em;
margin: 0;
overflow: auto;
border-right: 3px solid #f8f8f8;
background-color: white;
}
#toc .toclevel1 {
margin-top: 0.5em;
}
#toc .toclevel2 {
margin-top: 0.25em;
display: list-item;
color: #aaaaaa;
}
#toctitle {
margin-top: 0.5em;
}
}
</style>
<script type="text/javascript">
/*<![CDATA[*/
var asciidoc = { // Namespace.
/////////////////////////////////////////////////////////////////////
// Table Of Contents generator
/////////////////////////////////////////////////////////////////////
/* Author: Mihai Bazon, September 2002
* http://students.infoiasi.ro/~mishoo
*
* Table Of Content generator
* Version: 0.4
*
* Feel free to use this script under the terms of the GNU General Public
* License, as long as you do not remove or alter this notice.
*/
/* modified by Troy D. Hanson, September 2006. License: GPL */
/* modified by Stuart Rackham, 2006, 2009. License: GPL */
// toclevels = 1..4.
toc: function (toclevels) {
function getText(el) {
var text = "";
for (var i = el.firstChild; i != null; i = i.nextSibling) {
if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
text += i.data;
else if (i.firstChild != null)
text += getText(i);
}
return text;
}
function TocEntry(el, text, toclevel) {
this.element = el;
this.text = text;
this.toclevel = toclevel;
}
function tocEntries(el, toclevels) {
var result = new Array;
var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
// Function that scans the DOM tree for header elements (the DOM2
// nodeIterator API would be a better technique but not supported by all
// browsers).
var iterate = function (el) {
for (var i = el.firstChild; i != null; i = i.nextSibling) {
if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
var mo = re.exec(i.tagName);
if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
}
iterate(i);
}
}
}
iterate(el);
return result;
}
var toc = document.getElementById("toc");
if (!toc) {
return;
}
// Delete existing TOC entries in case we're reloading the TOC.
var tocEntriesToRemove = [];
var i;
for (i = 0; i < toc.childNodes.length; i++) {
var entry = toc.childNodes[i];
if (entry.nodeName.toLowerCase() == 'div'
&& entry.getAttribute("class")
&& entry.getAttribute("class").match(/^toclevel/))
tocEntriesToRemove.push(entry);
}
for (i = 0; i < tocEntriesToRemove.length; i++) {
toc.removeChild(tocEntriesToRemove[i]);
}
// Rebuild TOC entries.
var entries = tocEntries(document.getElementById("content"), toclevels);
for (var i = 0; i < entries.length; ++i) {
var entry = entries[i];
if (entry.element.id == "")
entry.element.id = "_toc_" + i;
var a = document.createElement("a");
a.href = "#" + entry.element.id;
a.appendChild(document.createTextNode(entry.text));
var div = document.createElement("div");
div.appendChild(a);
div.className = "toclevel" + entry.toclevel;
toc.appendChild(div);
}
if (entries.length == 0)
toc.parentNode.removeChild(toc);
},
/////////////////////////////////////////////////////////////////////
// Footnotes generator
/////////////////////////////////////////////////////////////////////
/* Based on footnote generation code from:
* http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
*/
footnotes: function () {
// Delete existing footnote entries in case we're reloading the footnodes.
var i;
var noteholder = document.getElementById("footnotes");
if (!noteholder) {
return;
}
var entriesToRemove = [];
for (i = 0; i < noteholder.childNodes.length; i++) {
var entry = noteholder.childNodes[i];
if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
entriesToRemove.push(entry);
}
for (i = 0; i < entriesToRemove.length; i++) {
noteholder.removeChild(entriesToRemove[i]);
}
// Rebuild footnote entries.
var cont = document.getElementById("content");
var spans = cont.getElementsByTagName("span");
var refs = {};
var n = 0;
for (i=0; i<spans.length; i++) {
if (spans[i].className == "footnote") {
n++;
var note = spans[i].getAttribute("data-note");
if (!note) {
// Use [\s\S] in place of . so multi-line matches work.
// Because JavaScript has no s (dotall) regex flag.
note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
spans[i].innerHTML =
"[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
"' title='View footnote' class='footnote'>" + n + "</a>]";
spans[i].setAttribute("data-note", note);
}
noteholder.innerHTML +=
"<div class='footnote' id='_footnote_" + n + "'>" +
"<a href='#_footnoteref_" + n + "' title='Return to text'>" +
n + "</a>. " + note + "</div>";
var id =spans[i].getAttribute("id");
if (id != null) refs["#"+id] = n;
}
}
if (n == 0)
noteholder.parentNode.removeChild(noteholder);
else {
// Process footnoterefs.
for (i=0; i<spans.length; i++) {
if (spans[i].className == "footnoteref") {
var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
href = href.match(/#.*/)[0]; // Because IE return full URL.
n = refs[href];
spans[i].innerHTML =
"[<a href='#_footnote_" + n +
"' title='View footnote' class='footnote'>" + n + "</a>]";
}
}
}
},
install: function(toclevels) {
var timerId;
function reinstall() {
asciidoc.footnotes();
if (toclevels) {
asciidoc.toc(toclevels);
}
}
function reinstallAndRemoveTimer() {
clearInterval(timerId);
reinstall();
}
timerId = setInterval(reinstall, 500);
if (document.addEventListener)
document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
else
window.onload = reinstallAndRemoveTimer;
}
}
asciidoc.install(3);
/*]]>*/
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
MathML: { extensions: ["content-mathml.js"] },
tex2jax: { inlineMath: [['$','$'], ['\\(','\\)']] }
});
</script>
<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head>
<body class="book">
<div id="header">
<h1>The OpenCL C++ 1.0 Specification</h1>
<span id="author">Khronos OpenCL Working Group</span><br>
<div id="toc">
<div id="toctitle">Table of Contents</div>
<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</div>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph"><p>Copyright 2008-2017 The Khronos Group.</p></div>
<div class="paragraph"><p>This specification is protected by copyright laws and contains material proprietary
to the Khronos Group, Inc. Except as described by these terms, it or any components
may not be reproduced, republished, distributed, transmitted, displayed, broadcast
or otherwise exploited in any manner without the express prior written permission
of Khronos Group.</p></div>
<div class="paragraph"><p>Khronos Group grants a conditional copyright license to use and reproduce the
unmodified specification for any purpose, without fee or royalty, EXCEPT no licenses
to any patent, trademark or other intellectual property rights are granted under
these terms. Parties desiring to implement the specification and make use of
Khronos trademarks in relation to that implementation, and receive reciprocal patent
license protection under the Khronos IP Policy must become Adopters and confirm the
implementation as conformant under the process defined by Khronos for this
specification; see <a href="https://www.khronos.org/adopters">https://www.khronos.org/adopters</a>.</p></div>
<div class="paragraph"><p>Khronos Group makes no, and expressly disclaims any, representations or warranties,
express or implied, regarding this specification, including, without limitation:
merchantability, fitness for a particular purpose, non-infringement of any
intellectual property, correctness, accuracy, completeness, timeliness, and
reliability. Under no circumstances will the Khronos Group, or any of its Promoters,
Contributors or Members, or their respective partners, officers, directors,
employees, agents or representatives be liable for any damages, whether direct,
indirect, special or consequential damages for lost revenues, lost profits, or
otherwise, arising from or in connection with these materials.</p></div>
<div class="paragraph"><p>Vulkan is a registered trademark and Khronos, OpenXR, SPIR, SPIR-V, SYCL, WebGL,
WebCL, OpenVX, OpenVG, EGL, COLLADA, glTF, NNEF, OpenKODE, OpenKCAM, StreamInput,
OpenWF, OpenSL ES, OpenMAX, OpenMAX AL, OpenMAX IL, OpenMAX DL, OpenML and DevU are
trademarks of the Khronos Group Inc. ASTC is a trademark of ARM Holdings PLC,
OpenCL is a trademark of Apple Inc. and OpenGL and OpenML are registered trademarks
and the OpenGL ES and OpenGL SC logos are trademarks of Silicon Graphics
International used under license by Khronos. All other product names, trademarks,
and/or company names are used solely for identification and belong to their
respective owners.</p></div>
<div style="page-break-after:always"></div>
<h2 id="acknowledgements" class="float">Acknowledgements</h2>
<div class="paragraph"><p>The OpenCL C++ specification is the result of the contributions of many people, representing a cross section of the desktop, hand-held, and embedded computer industry.
Following is a partial list of the contributors, including the company that they represented at the time of their contribution:</p></div>
<div class="ulist"><ul>
<li>
<p>
Eric Berdahl, Adobe
</p>
</li>
<li>
<p>
Aaftab Munshi, Apple
</p>
</li>
<li>
<p>
Brian Sumner, AMD
</p>
</li>
<li>
<p>
Andrew Richards, Codeplay
</p>
</li>
<li>
<p>
Maria Rovatsou, Codeplay
</p>
</li>
<li>
<p>
Adam Stański, Intel
</p>
</li>
<li>
<p>
Alexey Bader, Intel
</p>
</li>
<li>
<p>
Allen Hux, Intel
</p>
</li>
<li>
<p>
Bartosz Sochacki, Intel
</p>
</li>
<li>
<p>
Ben Ashbaugh, Intel
</p>
</li>
<li>
<p>
Kevin Stevens, Intel
</p>
</li>
<li>
<p>
Łukasz Dudziak, Intel
</p>
</li>
<li>
<p>
Łukasz Towarek, Intel
</p>
</li>
<li>
<p>
Marcin Walkowiak, Intel
</p>
</li>
<li>
<p>
Michael Kinsner, Intel
</p>
</li>
<li>
<p>
Raun Krisch, Intel
</p>
</li>
<li>
<p>
Tomasz Fiechowski, Intel
</p>
</li>
<li>
<p>
Kedar Patil, NVIDIA
</p>
</li>
<li>
<p>
Yuan Lin, NVIDIA
</p>
</li>
<li>
<p>
Alex Bourd, Qualcomm
</p>
</li>
<li>
<p>
Lee Howes, Qualcomm
</p>
</li>
<li>
<p>
Anton Gorenko, StreamComputing
</p>
</li>
<li>
<p>
Jakub Szuppe, StreamComputing
</p>
</li>
<li>
<p>
James Price, University of Bristol
</p>
</li>
<li>
<p>
Paul Preney, University of Windsor
</p>
</li>
<li>
<p>
Ronan Keryell, Xilinx
</p>
</li>
<li>
<p>
AJ Guillon, YetiWare Inc.
</p>
</li>
</ul></div>
<div style="page-break-after:always"></div>
</div>
</div>
<div class="sect1">
<h2 id="generic-type-name-notation">1. Generic Type Name Notation</h2>
<div class="sectionbody">
<div class="paragraph"><p>The generic type names are used when some entity has multiple overloads which differ only by argument(s).
They can map to one or more built-in data types.
The tables below describe these mappings in details.</p></div>
<div class="paragraph"><p>Assuming that <span class="monospaced">gentype</span> maps to built-in types: <span class="monospaced">float</span>, <span class="monospaced">int</span> and <span class="monospaced">uint</span>, when coming across definition:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">function</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>reader should understand that such function has in fact three overloads:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">function</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<span style="color: #990000">);</span>
<span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">function</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<span style="color: #990000">);</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">function</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Note that if a function signature has multiple usages of <span class="monospaced">gentype</span> they all should map to the same type.
Following this rule such overloads are then invalid:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">function</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<span style="color: #990000">);</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">function</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// etc.</span></span></tt></pre></div></div>
<div class="paragraph"><p>If a function is meant to have such overloads, respective gentypes in its signature should be postfixed with numbers to indicate they represent different types.
Declaration like this:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>cl<span style="color: #990000">::</span><span style="color: #008080">common_type_t&lt;gentype1, gentype2&gt;</span> <span style="font-weight: bold"><span style="color: #000000">greater</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype1</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype2</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>would match following overloads:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>cl<span style="color: #990000">::</span><span style="color: #008080">common_type_t&lt;float, float&gt;</span> <span style="font-weight: bold"><span style="color: #000000">greater</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<span style="color: #990000">,</span> <span style="color: #009900">float</span> y<span style="color: #990000">);</span>
cl<span style="color: #990000">::</span><span style="color: #008080">common_type_t&lt;float, int&gt;</span> <span style="font-weight: bold"><span style="color: #000000">greater</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<span style="color: #990000">,</span> <span style="color: #009900">int</span> y<span style="color: #990000">);</span>
cl<span style="color: #990000">::</span><span style="color: #008080">common_type_t&lt;float, uint&gt;</span> <span style="font-weight: bold"><span style="color: #000000">greater</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<span style="color: #990000">,</span> <span style="color: #008080">uint</span> y<span style="color: #990000">);</span>
cl<span style="color: #990000">::</span><span style="color: #008080">common_type_t&lt;int, float&gt;</span> <span style="font-weight: bold"><span style="color: #000000">greater</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<span style="color: #990000">,</span> <span style="color: #009900">float</span> y<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// etc.</span></span></tt></pre></div></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 1. generic types</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><div class="paragraph"><p><strong>generic type</strong></p></div></th>
<th class="tableblock halign-left valign-top" ><div class="paragraph"><p><strong>corresponding built-in types</strong></p></div></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">typen</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>scalar and all vector types of type</p></div>
<div class="paragraph"><p>Example:</p></div>
<div class="paragraph"><p><span class="monospaced">floatn</span> matches: <span class="monospaced">float</span>, <span class="monospaced">float2</span>, <span class="monospaced">float3</span>, <span class="monospaced">float4</span>, <span class="monospaced">float8</span> and <span class="monospaced">float16</span></p></div>
<div class="paragraph"><p><span class="monospaced">floatn</span> doesn&#8217;t match: <span class="monospaced">half</span>, <span class="monospaced">int2</span></p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">gentype</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>unspecified in global context, should be defined whenever used</p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">sgentype</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>subset of scalar types from types matched by <span class="monospaced">gentype</span></p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">ugentype</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>subset of unsigned integer types from types matched by <span class="monospaced">gentype</span></p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">gentypeh</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">half</span>, <span class="monospaced">half2</span>, <span class="monospaced">half3</span>, <span class="monospaced">half4</span>, <span class="monospaced">half8</span> or <span class="monospaced">half16</span></p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">gentypef</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">float</span>, <span class="monospaced">float2</span>, <span class="monospaced">float3</span>, <span class="monospaced">float4</span>, <span class="monospaced">float8</span> or <span class="monospaced">float16</span></p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">gentyped</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">double</span>, <span class="monospaced">double2</span>, <span class="monospaced">double3</span>, <span class="monospaced">double4</span>, <span class="monospaced">double8</span> or <span class="monospaced">double16</span></p></div></div></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect1">
<h2 id="openclcpp-programming-language">2. OpenCL C++ Programming Language</h2>
<div class="sectionbody">
<div class="paragraph"><p>This section describes the OpenCL C++ programming language used to create kernels that are executed on OpenCL device(s).
The OpenCL C++ programming language is based on the ISO/IEC JTC1 SC22 WG21 N 3690 language specification (a.k.a. C++14 specification) with specific restrictions (<em><a href="#opencl_cxx_restrictions">OpenCL C++ restrictions</a> section</em>).
Please refer to this specification for a detailed description of the language grammar.
This section describes restrictions to the C++14 specification supported in OpenCL C++.</p></div>
<div class="sect2">
<h3 id="supported-builtin-data-types">2.1. Supported Built-in Data Types</h3>
<div class="paragraph"><p>The following data types are supported.</p></div>
<div class="sect3">
<h4 id="builtin-scalar-data-types">2.1.1. Built-in Scalar Data Types</h4>
<table class="tableblock frame-all grid-all" id="device_builtin_scalar_data_types"
style="
width:100%;
">
<caption class="title">Table 2. Device Built-in scalar data types</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">bool</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A data type which is either <span class="monospaced">true</span> or <span class="monospaced">false</span>. (<em>See [ISO/IEC 14882:2014: lex.bool, &sect;2.14.6; basic.fundamental, &sect;3.9.1].</em>)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">char</span>, <span class="monospaced">signed char</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A signed two&#8217;s complement 8-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unsigned char</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">An unsigned 8-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">short</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A signed two&#8217;s complement 16-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unsigned short</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">An unsigned 16-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">int</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A signed two&#8217;s complement 32-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unsigned int</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">An unsigned 32-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">long</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A signed two&#8217;s complement 64-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unsigned long</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">An unsigned 64-bit integer.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">float</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A 32-bit floating-point.
The float data type must conform to the IEEE 754 single precision storage format.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">double</span> <a href="#ftn2">[2</a>]</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A 64-bit floating-point.
The double data type must conform to the IEEE 754 double precision storage format.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">half</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A 16-bit floating-point.
The half data type must conform to the IEEE 754-2008 half precision storage format.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">void</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">The <span class="monospaced">void</span> type comprises an empty set of values; it is an incomplete type that cannot be completed.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>Most built-in scalar data types are also declared as appropriate types in the OpenCL API (and header files) that can be used by an application.
The following table describes the built-in scalar data type in the OpenCL C++ programming language and the corresponding data type available to the application:</p></div>
<table class="tableblock frame-all grid-all" id="host_scalar_builtin_data_types"
style="
width:100%;
">
<caption class="title">Table 3. Host Scalar Built-in Data Types</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type in OpenCL Language</strong></th>
<th class="tableblock halign-left valign-top" ><strong>API type for application</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">bool</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">n/a, i.e., there is no corresponding <span class="monospaced">cl_bool</span> type.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">char</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_char</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unsigned char</span>, <span class="monospaced">uchar</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_uchar</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">short</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_short</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unsigned short</span>, <span class="monospaced">ushort</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_ushort</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">int</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_int</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unsigned int</span>, <span class="monospaced">uint</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_uint</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">long</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_long</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unsigned long</span>, <span class="monospaced">ulong</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_ulong</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">float</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_float</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">double</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_double</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">half</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_half</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">void</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">void</span></p></td>
</tr>
</tbody>
</table>
<div class="sect4">
<h5 id="builtin-half-data-type">Built-in Half Data Type</h5>
<div class="paragraph"><p>The <span class="monospaced">half</span> data type must be IEEE 754-2008 compliant.
<span class="monospaced">half</span> numbers have 1 sign bit, 5 exponent bits, and 10 mantissa bits.
The interpretation of the sign, exponent and mantissa is analogous to IEEE 754 floating-point numbers.</p></div>
<div class="paragraph"><p>The exponent bias is 15.
The <span class="monospaced">half</span> data type must represent finite and normal numbers, denormalized numbers, infinities and NaN.
Denormalized numbers for the <span class="monospaced">half</span> data type which may be generated when converting a <span class="monospaced">float</span> to a <span class="monospaced">half</span> using <span class="monospaced">vstore_half</span> and converting a <span class="monospaced">half</span> to a <span class="monospaced">float</span> using <span class="monospaced">vload_half</span> cannot be flushed to zero.</p></div>
<div class="paragraph"><p>Conversions from <span class="monospaced">float</span> to <span class="monospaced">half</span> correctly round the mantissa to 11 bits of precision.</p></div>
<div class="paragraph"><p>Conversions from <span class="monospaced">half</span> to <span class="monospaced">float</span> are lossless; all <span class="monospaced">half</span> numbers are exactly representable as <span class="monospaced">float</span> values.</p></div>
<div class="paragraph"><p>The <span class="monospaced">half</span> data type can only be used to declare a pointer to a buffer that contains <span class="monospaced">half</span> values.
All other operations are not allowed if the <em>cl_khr_fp16</em> extension is not supported.</p></div>
<div class="paragraph"><p>A few valid examples are given below:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_def&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_memory&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_vector_load_store&gt;</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">bar</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> <span style="color: #990000">*</span>a<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">return</span></span> cl<span style="color: #990000">::</span>vload_half<span style="color: #990000">&lt;</span> <span style="color: #993399">1</span> <span style="color: #990000">&gt;(</span><span style="color: #993399">0</span><span style="color: #990000">,</span> a<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">(</span>cl<span style="color: #990000">::</span><span style="color: #008080">global_ptr&lt;half&gt;</span> pg<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">//ok: a global pointer</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// passed from the host</span></span>
<span style="color: #009900">int</span> offset <span style="color: #990000">=</span> <span style="color: #993399">1</span><span style="color: #990000">;</span>
<span style="color: #008080">half</span> <span style="color: #990000">*</span>ptr <span style="color: #990000">=</span> pg<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="color: #990000">+</span> offset<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">//ok: half pointer arithmetic</span></span>
<span style="color: #009900">float</span> b <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">bar</span></span><span style="color: #990000">(</span>ptr<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>b <span style="color: #990000">&lt;</span> <span style="color: #990000">*</span>ptr<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">//not allowed: it is only supported if cl_khr_fp16</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// extension is enabled</span></span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The <span class="monospaced">half</span> scalar data type is required to be supported as a data storage format.
Vector data load and store functions (described in <em><a href="#vector-data-load-and-store-functions">Vector Data Load and Store Functions</a> section</em>) must be supported.</p></div>
</div>
<div class="sect4">
<h5 id="cl_khr_fp16-extension">cl_khr_fp16 extension</h5>
<div class="paragraph"><p>This extension adds support for <span class="monospaced">half</span> scalar and vector types as built-in types that can be used for arithmetic operations, conversions etc.
An application that wants to use <span class="monospaced">half</span> and <span class="monospaced">halfn</span> types will need to specify <em>-cl-fp16-enable</em> compiler option (<em><a href="#fp16_and_fp64_options">Double and half-precision floating-point options</a> section</em>).</p></div>
<div class="paragraph"><p>The OpenCL compiler accepts an h and H suffix on floating point literals, indicating the literal is typed as a <span class="monospaced">half</span></p></div>
<div class="paragraph"><p>A few valid examples:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_def&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_memory&gt;</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">bar</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> a<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">half</span> b <span style="color: #990000">=</span> a<span style="color: #990000">;</span>
b <span style="color: #990000">+=</span> <span style="color: #993399">10</span><span style="color: #990000">.</span>0h<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">//ok: cl_khr_fp16 extension is enabled. All arithmetic</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// operations on half built-in type are available</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">return</span></span> b<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">(</span>cl<span style="color: #990000">::</span><span style="color: #008080">global_ptr&lt;half&gt;</span> pg<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> offset <span style="color: #990000">=</span> <span style="color: #993399">1</span><span style="color: #990000">;</span>
<span style="color: #008080">half</span> <span style="color: #990000">*</span>ptr <span style="color: #990000">=</span> pg<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="color: #990000">+</span> offset<span style="color: #990000">;</span>
<span style="color: #008080">half</span> b <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">bar</span></span><span style="color: #990000">(*</span>ptr<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>b <span style="color: #990000">&lt;</span> <span style="color: #990000">*</span>ptr<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">//ok: cl_khr_fp16 extension is enabled.</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// All comparision operations are available</span></span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="hexadecimal-floating-point-literals">Hexadecimal floating point literals</h5>
<div class="paragraph"><p>Hexadecimal floating point literals are supported in OpenCL C++.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">float</span> f <span style="color: #990000">=</span> <span style="color: #993399">0x1</span><span style="color: #990000">.</span>fffffep127f
<span style="color: #009900">double</span> d <span style="color: #990000">=</span> <span style="color: #993399">0x1</span><span style="color: #990000">.</span>fffffffffffffp1023<span style="color: #990000">;</span>
<span style="color: #008080">half</span> h <span style="color: #990000">=</span> <span style="color: #993399">0x1</span><span style="color: #990000">.</span>ffcp15h<span style="color: #990000">;</span></tt></pre></div></div>
</div>
</div>
<div class="sect3">
<h4 id="builtin-vector-data-types">2.1.2. Built-in Vector Data Types</h4>
<div class="sect4">
<h5 id="supported-vector-data-types">Supported Vector Data Types</h5>
<div class="paragraph"><p>The <span class="monospaced">bool</span>, <span class="monospaced">char</span>, <span class="monospaced">unsigned char</span>, <span class="monospaced">short</span>, <span class="monospaced">unsigned short</span>, <span class="monospaced">int</span>, <span class="monospaced">unsigned int</span>, <span class="monospaced">long</span>, <span class="monospaced">unsigned long</span>, <span class="monospaced">half</span>, <span class="monospaced">float</span> and <span class="monospaced">double</span> vector data types are supported.
The vector data type is defined with the type name i.e. <span class="monospaced">bool</span>, <span class="monospaced">char</span>, <span class="monospaced">uchar</span>, <span class="monospaced">short</span>, <span class="monospaced">ushort</span>, <span class="monospaced">int</span>, <span class="monospaced">uint</span>, <span class="monospaced">long</span>, <span class="monospaced">ulong</span>, <span class="monospaced">half</span>, <span class="monospaced">float</span> or <span class="monospaced">double</span> followed by a literal value <em>n</em> that defines the number of elements in the vector.
Supported values of <em>n</em> are 2, 3, 4, 8, and 16 for all vector data types.</p></div>
<table class="tableblock frame-all grid-all" id="device_builtin_vector_data_types"
style="
width:100%;
">
<caption class="title">Table 4. Device Built-in Vector Data Types</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">bool</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> boolean values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">char</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 8-bit signed two&#8217;s complement integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">uchar</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 8-bit unsigned integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">short</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">vector of <em>n</em> 16-bit signed two&#8217;s complement integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ushort</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 16-bit unsigned integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">int</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 32-bit signed two&#8217;s complement integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">uint</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 32-bit unsigned integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">long</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 64-bit signed two&#8217;s complement integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ulong</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 64-bit unsigned integer values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">half</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 16-bit floating-point values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">float</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 32-bit floating-point values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">double</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A vector of <em>n</em> 64-bit floating-point values.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The built-in vector data types are also declared as appropriate types in the OpenCL API (and header files) that can be used by an application.
The following table describes the built-in vector data type in the OpenCL C++ programming language and the corresponding data type available to the application:</p></div>
<table class="tableblock frame-all grid-all" id="host_builtin_vector_data_types"
style="
width:100%;
">
<caption class="title">Table 5. Host Built-in Vector Data Types</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type in OpenCL Language</strong></th>
<th class="tableblock halign-left valign-top" ><strong>API type for application</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">bool</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">n/a, i.e., there is no corresponding <span class="monospaced">cl_bool</span><em>n</em> type.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">char</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_char</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">uchar</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_uchar</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">short</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_short</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ushort</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_ushort</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">int</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_int</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">uint</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_uint</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">long</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_long</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ulong</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_ulong</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">half</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_half</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">float</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_float</span><em>n</em></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">double</span><em>n</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_double</span><em>n</em></p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The <span class="monospaced">half</span><em>n</em> vector data type is required to be supported as a data storage format.
Vector data load and store functions (described in <em><a href="#vector-data-load-and-store-functions">Vector Data Load and Store Functions</a> section</em>) must be supported.</p></div>
<div class="paragraph"><p>Support for the <span class="monospaced">double</span><em>n</em> vector data type is optional.</p></div>
</div>
<div class="sect4">
<h5 id="vector-changes-to-cpp14-standard">Vector Changes to C++14 standard</h5>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
Vector types are classified as fundamental (<em>[ISO/IEC 14882:2014: basic.fundamental, ch. 3.9.1]</em>) and literal types
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">A vector type behave similarly to a trivially destructible class with all data members of literal type and all of its constructors defined as constexpr constructors</td>
</tr></table>
</div>
</li>
<li>
<p>
Abbreviating vector type as Tn, T is called the component type of a vector.
The numerical value n specifies number of components in a vector.
<a href="#device_builtin_vector_data_types">Device built-in vector data types</a> table specifies supported vector types.
</p>
<div class="paragraph"><p>A vector type which component type is <em>integral type</em> is called <em>integral vector type</em>.
A vector type which component is <em>floating-point type</em> is called <em>floating-point vector type</em>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">float8</span> a<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// component type: float, number of components: 8</span></span>
<span style="color: #008080">uint16</span> b<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// component type: uint, number of components: 16</span></span></tt></pre></div></div>
</li>
<li>
<p>
An <em>integral vector type</em> can be used as type of value of non-type template-parameter.
The change is introduced by following changes in C++ specification:
</p>
<div class="ulist"><ul>
<li>
<p>
<em>[ISO/IEC 14882:2014: temp.param, ch. 14.1 (4, 4.1)]</em> Template parameters: A non-type template-parameter shall have one of the following (optionally cv-qualified) types:
</p>
<div class="ulist"><ul>
<li>
<p>
integral, integral vector or enumeration type,
</p>
</li>
<li>
<p>
integral, integral vector or enumeration type,
</p>
</li>
<li>
<p>
[ &#8230; ]
</p>
</li>
</ul></div>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: temp.param, ch. 14.1 (7)]</em> Template parameters: A non-type <em>template-parameter</em> shall not be declared to have floating point, floating-point vector, class, or void type.
</p>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: temp.type, ch. 14.4 (1, 1.3)]</em> Type equivalence: Two <em>template-ids</em> refer to the same class, function, or variable if
</p>
<div class="ulist"><ul>
<li>
<p>
[ &#8230; ]
</p>
</li>
<li>
<p>
their corresponding non-type template arguments of integral, integral vector or enumeration type have identical values and
</p>
</li>
<li>
<p>
[ &#8230; ]
</p>
</li>
</ul></div>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: temp.res, ch. 14.6 (8, 8.3, 8.3.1)]</em> Name resolution: [&#8230;] If the interpretation of such a construct in the hypothetical instantiation is different from the interpretation of the corresponding construct
</p>
<div class="ulist"><ul>
<li>
<p>
integral, integral vector or enumeration type, in any actual instantiation of the template, the program is ill-formed; no diagnostic is required.
This can happen in situations including the following:
</p>
</li>
<li>
<p>
[ &#8230; ]
</p>
</li>
<li>
<p>
constant expression evaluation (5.20) within the template instantiation uses
</p>
<div class="ulist"><ul>
<li>
<p>
the value of a const object of integral, integral vector or unscoped enumeration type or
</p>
</li>
<li>
<p>
[ &#8230; ]
</p>
</li>
</ul></div>
</li>
<li>
<p>
[ &#8230; ]
</p>
</li>
</ul></div>
</li>
</ul></div>
</li>
</ol></div>
</div>
<div class="sect4">
<h5 id="vector-component-access">Vector Component Access</h5>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
The components of vector type can be accessed using swizzle expression.
The syntax of a swizzle expression is similar to syntax used in class member access expression <em>[ISO/IEC 14882:2014: expr.ref, ch. 5.2.5]</em>:
The swizzle expression is a postfix expression formed with a postfix expression followed by a dot <span class="monospaced">.</span> or an arrow <span class="monospaced">-&gt;</span> and then followed by an <em>vector-swizzle-selector</em>. The postfix expression before the dot or arrow is evaluated. The result of that evaluation, together with the <em>vector-swizzle-selector</em>, determines the result of the entire postfix expression.
</p>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">float4</span> v1 <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">3</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">4</span><span style="color: #990000">.</span>0f<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> <span style="color: #990000">*</span>pv1 <span style="color: #990000">=</span> <span style="color: #990000">&amp;</span>v1<span style="color: #990000">;</span>
<span style="color: #008080">float2</span> v2 <span style="color: #990000">=</span> v1<span style="color: #990000">.</span>xz<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// v1.xz is a swizzle expression</span></span>
<span style="color: #008080">float3</span> v3 <span style="color: #990000">=</span> pv1<span style="color: #990000">-&gt;</span>s321<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// pv1-&gt;s321 is a swizzle expression</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// equivalent to (*pv1).s321</span></span>
<span style="color: #990000">(*</span>pv1<span style="color: #990000">).</span>rgb <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">float3</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">0</span><span style="color: #990000">.</span>5f<span style="color: #990000">,</span> <span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// (*pv1).rgb is a swizzle expression</span></span>
pv1<span style="color: #990000">-&gt;</span>lo<span style="color: #990000">.</span>hi <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">.</span>0f<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// pv1-&gt;lo and pv1-&gt;lo.hi are swizzle</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// expressions</span></span></tt></pre></div></div>
</li>
<li>
<p>
For the first option (dot) the first expression shall have vector type or be a swizzle expression which results in vector-swizzle of vector type.
For the second option (arrow) the first expression shall have pointer to vector type.
The expression <span class="monospaced">E1-&gt;E2</span> is converted to the equivalent form <span class="monospaced">(*(E1)).E2</span>; the remainder of <a href="#vector-component-access">Vector Component Access</a> will address only the first option (dot).
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content"><span class="monospaced">(*(E1))</span> is lvalue. In either case, the <em>vector-swizzle-selector</em> shall name a vector component selection of a swizzle.</td>
</tr></table>
</div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">uint8</span> v1 <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">uint8</span></span><span style="color: #990000">(</span><span style="color: #993399">10</span><span style="color: #990000">,</span> <span style="color: #993399">11</span><span style="color: #990000">,</span> <span style="color: #993399">12</span><span style="color: #990000">,</span> <span style="color: #993399">13</span><span style="color: #990000">,</span> <span style="color: #993399">14</span><span style="color: #990000">,</span> <span style="color: #993399">15</span><span style="color: #990000">,</span> <span style="color: #993399">16</span><span style="color: #990000">,</span> <span style="color: #993399">17</span><span style="color: #990000">);</span>
<span style="color: #008080">uint4</span> v2 <span style="color: #990000">=</span> v1<span style="color: #990000">.</span>s7301<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct</span></span>
<span style="color: #008080">uint3</span> v3 <span style="color: #990000">=</span> <span style="color: #990000">(&amp;</span>v1<span style="color: #990000">)-&gt;</span>s246<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct</span></span>
<span style="color: #008080">uint4</span> v4 <span style="color: #990000">=</span> v1<span style="color: #990000">-&gt;</span>s0123<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: v1 is not a pointer to</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// vector type</span></span>
<span style="color: #008080">uint8</span> <span style="color: #990000">*</span>pv1 <span style="color: #990000">=</span> <span style="color: #990000">&amp;</span>v1<span style="color: #990000">;</span>
<span style="color: #008080">uint2</span> v5 <span style="color: #990000">=</span> pv1<span style="color: #990000">-&gt;</span>S13<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct</span></span>
<span style="color: #008080">uint2</span> v6 <span style="color: #990000">=</span> <span style="color: #990000">(*</span>pv1<span style="color: #990000">).</span>s0745<span style="color: #990000">.</span>even<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct</span></span>
<span style="color: #008080">uint4</span> v7 <span style="color: #990000">=</span> pv1<span style="color: #990000">.</span>odd<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: pv1 is not vector or</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// vector-swizzle</span></span></tt></pre></div></div>
</li>
<li>
<p>
Abbreviating <em>postfix-expression.vector-swizzle-selector</em> as <span class="monospaced">E1.E2</span>, <span class="monospaced">E1</span> is called the vector expression.
The type and value category of <span class="monospaced">E1.E2</span> are determined as follows.
In the remainder of <a href="#vector-component-access">Vector Component Access</a>, <em>cq</em> represents either <span class="monospaced">const</span> or the absence of <span class="monospaced">const</span> and <em>vq</em> represents either <span class="monospaced">volatile</span> or the absence of <span class="monospaced">volatile</span>.
cv represents an arbitrary set of cv-qualifiers, as defined in <em>[ISO/IEC 14882:2014: basic.type.qualifier, ch. 3.9.3]</em> .
</p>
</li>
<li>
<p>
<em>vector-swizzle-selector</em> is subset of <em>identifier</em> with following syntax:
</p>
<div class="openblock">
<div class="content">
<div class="paragraph"><p><em>vector-swizzle-selector</em>:</p></div>
<div class="ulist"><ul>
<li>
<p>
<em>vector-swizzle-xyzw-selector</em>:
</p>
<div class="ulist"><ul>
<li>
<p>
<em>vector-swizzle-xyzw-selector-value</em>
</p>
</li>
<li>
<p>
<em>vector-swizzle-xyzw-selector vector-swizzle-xyzw-selector-value</em>
</p>
</li>
</ul></div>
</li>
<li>
<p>
<em>vector-swizzle-rgba-selector</em>:
</p>
<div class="ulist"><ul>
<li>
<p>
<em>vector-swizzle-rgba-selector-value</em>
</p>
</li>
<li>
<p>
<em>vector-swizzle-rgba-selector vector-swizzle-rgba-selector-value</em>
</p>
</li>
</ul></div>
</li>
<li>
<p>
<em>vector-swizzle-special-selector</em>:
</p>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">hi</span>
</p>
</li>
<li>
<p>
<span class="monospaced">lo</span>
</p>
</li>
<li>
<p>
<span class="monospaced">even</span>
</p>
</li>
<li>
<p>
<span class="monospaced">odd</span>
</p>
</li>
</ul></div>
</li>
<li>
<p>
<em>vector-swizzle-num-selector</em>:
</p>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">s</span> <em>vector-swizzle-num-selector-values</em>
</p>
</li>
<li>
<p>
<span class="monospaced">S</span> <em>vector-swizzle-num-selector-values</em>
</p>
</li>
</ul></div>
</li>
</ul></div>
</div></div>
<div class="openblock">
<div class="content">
<div class="paragraph"><p><em>vector-swizzle-num-selector-values</em>:</p></div>
<div class="ulist"><ul>
<li>
<p>
<em>vector-swizzle-num-selector-value</em>
</p>
</li>
<li>
<p>
<em>vector-swizzle-num-selector-values vector-swizzle-num-selector-value</em>
</p>
</li>
</ul></div>
</div></div>
<div class="paragraph"><p><em>vector-swizzle-xyzw-selector-value</em>: one of <span class="monospaced">x y z w</span></p></div>
<div class="paragraph"><p><em>vector-swizzle-rgba-selector-value</em>: one of <span class="monospaced">r g b a</span></p></div>
<div class="paragraph"><p><em>vector-swizzle-num-selector-value</em>: one of <span class="monospaced">0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F</span></p></div>
<div class="openblock">
<div class="content">
<div class="paragraph"><p>with following restrictions:</p></div>
<div class="ulist"><ul>
<li>
<p>
<em>vector-swizzle-selector</em> in a form of <em>vector-swizzle-special-selector</em> shall only be used with vector expression with at least 2 components.
</p>
</li>
<li>
<p>
<em>vector-swizzle-selector</em> shall not select components beyond those available in vector expression.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content"><a href="#selector_values_and_their_corresponding_components_in_swizzle">Selector values and their corresponding components in swizzle</a> table describes relation between selector value and components.</td>
</tr></table>
</div>
</li>
<li>
<p>
<em>vector-swizzle-selector</em> shall have swizzle size of 1, 2, 3, 4, 8 or 16.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">Result from the swizzle expression shall be either of scalar or of valid vector type.</td>
</tr></table>
</div>
</li>
</ul></div>
</div></div>
<div class="paragraph"><p>If <em>vector-swizzle-selector</em> does not meet requirements, the swizzle expression is ill-formed.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">int2</span> v2<span style="color: #990000">;</span>
<span style="color: #008080">int3</span> v3<span style="color: #990000">;</span>
<span style="color: #008080">int4</span> v4<span style="color: #990000">;</span>
<span style="color: #008080">int8</span> v8<span style="color: #990000">;</span>
<span style="color: #008080">int16</span> v16<span style="color: #990000">;</span>
v4<span style="color: #990000">.</span>xyz <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">int3</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">,</span> <span style="color: #993399">3</span><span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: xyz selector</span></span>
v4<span style="color: #990000">.</span>baS01 <span style="color: #990000">=</span> v8<span style="color: #990000">.</span>lo<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: baS01 is mix of rgba</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// and numerical selectors</span></span>
v3<span style="color: #990000">.</span>rx <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">int2</span></span><span style="color: #990000">(</span><span style="color: #993399">20</span><span style="color: #990000">,</span> <span style="color: #993399">7</span><span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: mix of rgba and</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// xyzw selectors</span></span>
<span style="color: #009900">int</span> v2c1 <span style="color: #990000">=</span> v2<span style="color: #990000">.</span>z<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: xyzw selector</span></span>
<span style="color: #009900">int</span> v3c1 <span style="color: #990000">=</span> v3<span style="color: #990000">.</span>b<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: rgba selector</span></span>
<span style="color: #008080">int2</span> v4c1 <span style="color: #990000">=</span> v4<span style="color: #990000">.</span>ww<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: xyzw selector</span></span>
<span style="color: #008080">int3</span> v8c1 <span style="color: #990000">=</span> v8<span style="color: #990000">.</span>xyz<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: xyzw and rgba selectors</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// are not allowed on vector expressions</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// with more than 4 components</span></span>
<span style="color: #008080">int2</span> v8c2 <span style="color: #990000">=</span> v8<span style="color: #990000">.</span>hi<span style="color: #990000">.</span>xyz<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: xyzw selector on vector</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// expression v8.hi (vector-swizzle</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// of int4 type)</span></span>
<span style="color: #008080">int2</span> v3c2 <span style="color: #990000">=</span> v3<span style="color: #990000">.</span>odd<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: special selector</span></span>
<span style="color: #008080">int2</span> v3c2 <span style="color: #990000">=</span> v3<span style="color: #990000">.</span>x<span style="color: #990000">.</span>even<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: #1 vector expression</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// is invalid (vector swizzle of</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// scalar type)</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// #2 special selector cannot be</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// used with less than 2 components</span></span>
v3<span style="color: #990000">.</span>x <span style="color: #990000">=</span> <span style="color: #993399">1</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: xyzw selector</span></span>
v3<span style="color: #990000">.</span>w <span style="color: #990000">=</span> <span style="color: #993399">2</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: there is no "w" component in int3</span></span>
v2<span style="color: #990000">.</span>gb <span style="color: #990000">=</span> v4<span style="color: #990000">.</span>hi<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: there is no "b" component in int2</span></span>
v8<span style="color: #990000">.</span>S7890 <span style="color: #990000">=</span> v4<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: int8 allows numerical selector</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// in range 0-7</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> v16c1 <span style="color: #990000">=</span> v16<span style="color: #990000">.</span>s012<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: numerical selector</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> v16c2 <span style="color: #990000">=</span> v16<span style="color: #990000">.</span>s467899<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: swizzle expression</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// has not allowed size</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// (there is no int6 type)</span></span>
<span style="color: #008080">int16</span> vv1 <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">int16</span></span><span style="color: #990000">(</span>v16<span style="color: #990000">.</span>S98aabb01<span style="color: #990000">,</span> v2<span style="color: #990000">,</span> v2<span style="color: #990000">.</span>gr<span style="color: #990000">,</span> v3<span style="color: #990000">.</span>xxxx<span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// correct</span></span>
<span style="color: #008080">int16</span> vv2 <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">int16</span></span><span style="color: #990000">(</span>v16<span style="color: #990000">.</span>S98aabb0123<span style="color: #990000">,</span> v2<span style="color: #990000">.</span>gr<span style="color: #990000">,</span> v3<span style="color: #990000">.</span>xxxx<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// ill-formed:</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// although it sums up to 16</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// components the</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// S98aabb0123 selector has invalid</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// swizzle size (there is no int10)</span></span>
</tt></pre></div></div>
</li>
<li>
<p>
<em>vector-swizzle-selector</em>, in a form of <em>vector-swizzle-xyzw-selector</em>, <em>vector-swizzle-rgba-selector</em> or <em>vector-swizzle-num-selector</em> can specify multiple values.
Each value selects single component.
Values in a selector can be repeated and specified in any order.
A number of values in a selector including repeated values is called the swizzle size.
</p>
<table class="tableblock frame-all grid-all" id="selector_values_and_their_corresponding_components_in_swizzle"
style="
width:100%;
">
<caption class="title">Table 6. Selector values and their corresponding components in swizzle</caption>
<col style="width:25%;">
<col style="width:25%;">
<col style="width:25%;">
<col style="width:25%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Selector</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Selector value</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Selected component</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Required number of components in vector expression</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-xyzw-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">x</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1<sup>st</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2, 3 or 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-xyzw-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">y</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2<sup>nd</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2, 3 or 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-xyzw-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">z</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3<sup>rd</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3 or 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-xyzw-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">w</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-rgba-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">r</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1<sup>st</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2, 3 or 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-rgba-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">g</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2<sup>nd</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2, 3 or 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-rgba-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">b</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3<sup>rd</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3 or 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-rgba-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">a</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">0</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1<sup>st</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2, 3, 4, 8 or 16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">1</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2<sup>nd</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2, 3, 4, 8 or 16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3<sup>rd</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3, 4, 8 or 16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">3</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4, 8 or 16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">4</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">5<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8 or 16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">5</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">6<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8 or 16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">6</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">7<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8 or 16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">7</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8 or 16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">8</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">9<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">9</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">10<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">a</span> or <span class="monospaced">A</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">11<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">b</span> or <span class="monospaced">B</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">12<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">c</span> or <span class="monospaced">C</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">13<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">d</span> or <span class="monospaced">D</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">14<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">e</span> or <span class="monospaced">E</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">15<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>vector-swizzle-num-selector</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">f</span> or <span class="monospaced">F</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16<sup>th</sup></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
</tr>
</tbody>
</table>
</li>
<li>
<p>
<em>vector-swizzle-selector</em> in a form of <em>vector-swizzle-special-selector</em> shall select:
</p>
<div class="ulist"><ul>
<li>
<p>
if number of components in vector expression is 3, the same components as if number of components of the vector expression was 4 and the 4-th component was undefined.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">If 4-th component is read, the returned value is undefined; all writes to 4-th component shall be discarded.</td>
</tr></table>
</div>
</li>
<li>
<p>
otherwise, half of components of <em>vector expression</em> with
</p>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">hi</span> - highest numerical selector values in ascending order (higher half of the vector)
</p>
</li>
<li>
<p>
<span class="monospaced">lo</span> - lowest numerical selector values in ascending order (lower half of the vector)
</p>
</li>
<li>
<p>
<span class="monospaced">even</span> - even numerical selector values in ascending order
</p>
</li>
<li>
<p>
<span class="monospaced">odd</span> - odd numerical selector values in ascending order
</p>
</li>
</ul></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content"><a href="#special_selector_values">Special selector values</a> table describes special selector values and their numerical equivalents.</td>
</tr></table>
</div>
<table class="tableblock frame-all grid-all" id="special_selector_values"
style="
width:100%;
">
<caption class="title">Table 7. Special selector values</caption>
<col style="width:25%;">
<col style="width:25%;">
<col style="width:25%;">
<col style="width:25%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Number of components in vector expression</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Selector value</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Equivalent numerical selector</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Number of components in result vector swizzle (swizzle size)</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">hi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s1</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">hi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s2?</span> <a id="_ftnref3"></a> <a href="#ftn3">[3</a>]</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">hi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s23</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">hi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s4567</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">hi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s89abcdef</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">lo</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s0</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">lo</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s01</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">lo</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s01</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">lo</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s0123</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">lo</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s01234567</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">even</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s0</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">even</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s02</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">even</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s02</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">even</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s0246</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">even</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s02468ace</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">odd</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s1</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">3</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">odd</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s1?</span> <a href="#ftn3">[3</a>]</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">odd</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s13</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">odd</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s1357</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">16</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">odd</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">s13579bdf</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">8</p></td>
</tr>
</tbody>
</table>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">float8</span> v <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">float8</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">3</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">4</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">5</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">6</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">7</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">8</span><span style="color: #990000">.</span>0f<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> vv1 <span style="color: #990000">=</span> v<span style="color: #990000">.</span>hi<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// vv1 = float4(5, 6, 7, 8)</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> vv2 <span style="color: #990000">=</span> v<span style="color: #990000">.</span>lo<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// vv2 = float4(1, 2, 3, 4)</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> vv3 <span style="color: #990000">=</span> v<span style="color: #990000">.</span>even<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// equivalent of v.s0246; vv3 = float4(1, 3, 5, 7)</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> vv4 <span style="color: #990000">=</span> v<span style="color: #990000">.</span>odd<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// equivalent of v.s1357; vv4 = float4(2, 4, 6, 8)</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> vv5 <span style="color: #990000">=</span> v<span style="color: #990000">.</span>odd<span style="color: #990000">.</span>even<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// vv5 = float2(2, 6)</span></span>
<span style="color: #008080">int3</span> sv <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">int3</span></span><span style="color: #990000">(</span><span style="color: #993399">10</span><span style="color: #990000">,</span> <span style="color: #993399">20</span><span style="color: #990000">,</span> <span style="color: #993399">30</span><span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// ? means undefined value</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> svv1 <span style="color: #990000">=</span> sv<span style="color: #990000">.</span>hi<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// svv1 = int2(30, ?)</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> svv2 <span style="color: #990000">=</span> sv<span style="color: #990000">.</span>odd<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// svv2 = int2(20, ?)</span></span>
sv<span style="color: #990000">.</span>hi <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">int2</span></span><span style="color: #990000">(-</span><span style="color: #993399">123</span><span style="color: #990000">,</span> <span style="color: #993399">456</span><span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// write to 4-th channel in sv is discarded;</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// equivalent of sv.s2 = int2(-123, 456).s0</span></span></tt></pre></div></div>
</li>
</ul></div>
</li>
<li>
<p>
The value of a swizzle expression <span class="monospaced">E1.E2</span> is <em>vector-swizzle</em>.
The expression designates group of components of the object designated by expression <span class="monospaced">E1</span>.
Selector <span class="monospaced">E2</span> specifies which components are designated, how many times and in which order.
</p>
<div class="paragraph"><p>Assuming that in the type of a vector expression <span class="monospaced">E1</span> is <span class="monospaced">cv Tn</span> where <span class="monospaced">T</span> denotes type of components and <span class="monospaced">n</span> their number in vector type, the resulting <em>vector-swizzle</em> shall have:</p></div>
<div class="openblock">
<div class="content">
<div class="ulist"><ul>
<li>
<p>
scalar type <span class="monospaced">cv T</span> if it is result of a swizzle expression with swizzle size of one or
</p>
</li>
<li>
<p>
vector type <span class="monospaced">cv Tm</span> if it is result of a swizzle expression with swizzle size of two or more.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content"><span class="monospaced">m</span> is a swizzle size.</td>
</tr></table>
</div>
</li>
</ul></div>
</div></div>
<div class="paragraph"><p>If <span class="monospaced">E1</span> is an lvalue, then <span class="monospaced">E1.E2</span> is an lvalue; if <span class="monospaced">E1</span> is an xvalue, then <span class="monospaced">E1.E2</span> is an xvalue; otherwise, it is a prvalue.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">long2</span> v<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">long2</span> pv <span style="color: #990000">=</span> <span style="color: #990000">&amp;</span>v<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> vc1 <span style="color: #990000">=</span> pv<span style="color: #990000">-&gt;</span>x<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// pv-&gt;x is lvalue vector-swizzle of</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// scalar type: const long</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> vc2 <span style="color: #990000">=</span> pv<span style="color: #990000">-&gt;</span>rg<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// pv-&gt;rg is lvalue vector-swizzle of</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// vector type: const long2</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> vc3 <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">uchar4</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">).</span>xxy<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// uchar4(1).xxy is prvalue</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// vector-swizzle</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// of vector type: uchar3</span></span>
v<span style="color: #990000">.</span>x <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">long2</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: cannot assign prvalue of long2</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// to lvalue vector-swizzle of</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// scalar type: long - types do not</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// match</span></span>
</tt></pre></div></div>
</li>
<li>
<p>
A <em>vector-swizzle</em> with vector type <span class="monospaced">T</span> shall have the same number of components as number of components of <span class="monospaced">T</span>.
Each component of the vector-swizzle refers to component from <span class="monospaced">E1</span> designated by corresponding value specified in selector <span class="monospaced">E2</span>, assuming that <span class="monospaced">E1.E2</span> is swizzle expression used to create the <em>vector-swizzle</em>.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">First component refers to component from <span class="monospaced">E1</span> selected by first value in selector <span class="monospaced">E2</span>, second - by second value and so on.</td>
</tr></table>
</div>
<div class="paragraph"><p>A <em>vector-swizzle</em> with scalar type <span class="monospaced">T</span> shall behave as value of <span class="monospaced">T</span> and refer to component from <span class="monospaced">E1</span> designated by <span class="monospaced">E2</span>'s value, assuming <span class="monospaced">E1.E2</span> is swizzle expression used to create the <em>vector-swizzle</em>.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">It is similar to reference bounded to value of selected component from <span class="monospaced">E1</span>.</td>
</tr></table>
</div>
</li>
<li>
<p>
A <em>vector-swizzle</em> shall have scalar or vector type.
The address-of operator <span class="monospaced">&amp;</span> shall not be applied to <em>vector-swizzle</em>, so there are no pointers to <em>vector-swizzles</em>.
A non-const reference shall not be bound to <em>vector-swizzle</em>.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">If the initializer for a reference of type <span class="monospaced">const T&amp;</span> is lvalue that refers to vector-swizzle, the reference is bound to a temporary initialized to hold the value of the vector-swizzle; the reference is not bound to the vector-swizzle directly.</td>
</tr></table>
</div>
<div class="paragraph"><p>There is no declarator for <em>vector-swizzle</em>.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">Any variable, member or type declaration shall not involve vector-swizzle; vector-swizzle cannot be stored.</td>
</tr></table>
</div>
<div class="paragraph"><p>An <em>alignment-specifier</em> shall not be applied to <em>vector-swizzle</em>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">float4</span> v<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> pv1 <span style="color: #990000">=</span> <span style="color: #990000">&amp;</span>v<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: pv1 points to v</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> pv2 <span style="color: #990000">=</span> <span style="color: #990000">&amp;</span>v<span style="color: #990000">.</span>xy<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: address-of operator &amp; is not</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// allowed on vector-swizzle</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="color: #990000">&amp;</span>rv1 <span style="color: #990000">=</span> v<span style="color: #990000">.</span>xx<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// correct: refers to temporary value of</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// float2 type initialized with</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// value of vector-swizzle</span></span>
<span style="color: #008080">float2</span> <span style="color: #990000">&amp;</span>rv2 <span style="color: #990000">=</span> v<span style="color: #990000">.</span>xy<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: binding to non-const reference</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// is not allowed</span></span></tt></pre></div></div>
</li>
<li>
<p>
A result <em>vector-swizzle</em> from swizzle expression <span class="monospaced">E1.E2</span> is modifiable if:
</p>
<div class="openblock">
<div class="content">
<div class="ulist"><ul>
<li>
<p>
Vector expression <span class="monospaced">E1</span> is modifiable lvalue and
</p>
</li>
<li>
<p>
Each component selected by <em>vector-swizzle-selector</em> <span class="monospaced">E2</span> is selected at most once.
</p>
</li>
</ul></div>
</div></div>
<div class="paragraph"><p>Expression which modifies unmodifiable <em>vector-swizzle</em> is ill-formed.</p></div>
<div class="paragraph"><p>Changes applied to modifiable <em>vector-swizzle</em> are applied to components of <span class="monospaced">E1</span> referred by the <em>vector-swizzle</em> or by its components.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">char4</span> v<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">char4</span> cv<span style="color: #990000">;</span>
v<span style="color: #990000">.</span>yx <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">char2</span></span><span style="color: #990000">(</span><span style="color: #993399">33</span><span style="color: #990000">,</span> <span style="color: #993399">45</span><span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// correct</span></span>
v<span style="color: #990000">.</span>zzwx <span style="color: #990000">=</span> cv<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: v.zzwx is not modifiable</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// (repeated components)</span></span>
cv<span style="color: #990000">.</span>zxy <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">char3</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// ill-formed: cv.zxy is not modifiable</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// (cv is const)</span></span></tt></pre></div></div>
</li>
<li>
<p>
A prvalue for <em>vector-swizzle</em> of <span class="monospaced">T</span> type can be converted to a prvalue of <span class="monospaced">T</span> type.
</p>
<div class="paragraph"><p>This conversion is called <em>swizzle-to-vector</em> conversion.
<em>swizzle-to-vector</em> conversion shall be applied if necessary in all contexts where lvalue-to-rvalue conversions are allowed.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">swizzle-to-vector conversion shall be applied after lvalue-to-rvalue conversions and before any arithmetic conversions.</td>
</tr></table>
</div>
</li>
<li>
<p>
A glvalue <em>vector-swizzle</em> of scalar or vector type <span class="monospaced">T</span> can be used in all expressions where glvalue of type <span class="monospaced">T</span> can be used except those which do not meet requirements and restrictions for <em>vector-swizzle</em>.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">For example the address-of operator <span class="monospaced">&amp;</span> and binding to non-const reference are one of them.</td>
</tr></table>
</div>
</li>
<li>
<p>
A swizzle expression <span class="monospaced">E1.E2</span> where <span class="monospaced">E2</span> selects all components of vector expression <span class="monospaced">E1</span> in order of their numerical selector values is called identity swizzle.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">Components selected in <span class="monospaced">E2</span> are not repeated.</td>
</tr></table>
</div>
</li>
<li>
<p>
Additional changes to C++ specification:
</p>
<div class="ulist"><ul>
<li>
<p>
<em>[ISO/IEC 14882:2014: expr.static.cast, ch. 5.2.9 (3)]</em> static_cast: If value is not a bit-field or a <em>vector-swizzle</em>, [&#8230;]; if value is a <em>vector-swizzle</em>, the <em>lvalue-to-rvalue</em> conversion and <em>swizzle-to-vector</em> conversion are applied to the <em>vector-swizzle</em> and the resulting prvalue is used as the expression of the <span class="monospaced">static_cast</span> for the remainder of this section; otherwise, [&#8230;]
</p>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: expr.unary.op, ch. 5.3.1 (5)]</em> Unary operators: [&#8230;] The operand of <span class="monospaced">&amp;</span> shall not be a bit-field or a <em>vector-swizzle</em>.
</p>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: expr.pre.incr, ch. 5.3.2 (1)]</em> Increment and decrement: The result is the updated operand; it is an lvalue, and it is a bit-field or a <em>vector-swizzle</em> if the operand is respectively a bit-field or a <em>vector-swizzle</em>.
</p>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: expr.sizeof, ch. 5.3.3 (2)]</em> Sizeof: [&#8230;] When applied to a <em>vector-swizzle</em> which has type <span class="monospaced">T</span>, the result is the same as result from <span class="monospaced">sizeof(T)</span>.
</p>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: expr.cond, ch. 5.16 (2.1)]</em> Conditional operator: - [&#8230;] The conditional-expression is a bit-field or a <em>vector-swizzle</em> if that operand is respectively a bit-field or a <em>vector-swizzle</em>.
</p>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: expr.cond, ch. 5.16 (4)]</em> Conditional operator: If the second and third operands are glvalues of the same value category and have the same type, the result is of that type and value category and it is a bit-field if the second or the third operand is a bit-field, or if both are bit-fields.
The result is also a <em>vector-swizzle</em> if the second or the third operand is a <em>vector-swizzle</em>, or if both are <em>vector-swizzles</em>.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">An operand is converted to vector-swizzle if required by applying identity swizzle expression to it.</td>
</tr></table>
</div>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: expr.ass, ch. 5.18 (1)]</em> Assignment and compound assignment operators: The result in all cases is a bit-field or a <em>vector-swizzle</em> if the left operand is respectively a bit-field or a <em>vector-swizzle</em>.
</p>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: expr.comma, ch. 5.19 (1)]</em> Comma operator: The type and value of the result are the type and value of the right operand; the result is of the same value category as its right operand, and is a bit-field if its right operand is a glvalue and a bit-field, and is a <em>vector-swizzle</em> its right operand is a glvalue and a <em>vector-swizzle</em>.
</p>
</li>
<li>
<p>
<em>[ISO/IEC 14882:2014: dcl.type.simple, ch. 7.1.6.2 (4, 4.1)]</em> Simple type specifiers: For an expression e, the type denoted by decltype(e) is defined as follows:
</p>
<div class="ulist"><ul>
<li>
<p>
if e is an unparenthesized id-expression or an unparenthesized class member access (5.2.5) or unparenthesized swizzle expression, <span class="monospaced">decltype(e)</span> is the type of the entity named by e. If there is no such entity, or if e names a set of overloaded functions, the program is ill-formed.
</p>
</li>
</ul></div>
</li>
</ul></div>
</li>
</ol></div>
</div>
<div class="sect4">
<h5 id="vector-constructors">Vector Constructors</h5>
<div class="paragraph"><p>Vector constructors are defined to initialize a vector data type from a list of scalar or vectors.
The forms of the constructors that are available is the set of possible argument lists for which all arguments have the same element type as the result vector, and the total number of elements is equal to the number of elements in the result vector.
In addition, a form with a single scalar of the same type as the element type of the vector is available.</p></div>
<div class="paragraph"><p>For example, the following forms are available for <span class="monospaced">float4</span>:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span> <span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span> float2<span style="color: #990000">,</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span> <span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> float2<span style="color: #990000">,</span> <span style="color: #009900">float</span> <span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> float2 <span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span> float2<span style="color: #990000">,</span> float2 <span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span> float3<span style="color: #990000">,</span> <span style="color: #009900">float</span> <span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> float3 <span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span> <span style="color: #009900">float</span> <span style="color: #990000">)</span>
float4<span style="color: #FF0000">{</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span> <span style="color: #FF0000">}</span>
float4<span style="color: #FF0000">{</span> float2<span style="color: #990000">,</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span> <span style="color: #FF0000">}</span>
float4<span style="color: #FF0000">{</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> float2<span style="color: #990000">,</span> <span style="color: #009900">float</span> <span style="color: #FF0000">}</span>
float4<span style="color: #FF0000">{</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> float2 <span style="color: #FF0000">}</span>
float4<span style="color: #FF0000">{</span> float2<span style="color: #990000">,</span> float2 <span style="color: #FF0000">}</span>
float4<span style="color: #FF0000">{</span> float3<span style="color: #990000">,</span> <span style="color: #009900">float</span> <span style="color: #FF0000">}</span>
float4<span style="color: #FF0000">{</span> <span style="color: #009900">float</span><span style="color: #990000">,</span> float3 <span style="color: #FF0000">}</span>
float4<span style="color: #FF0000">{</span> <span style="color: #009900">float</span> <span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>Operands are evaluated by standard rules for function evaluation, except that implicit scalar-to-vector conversion shall not occur.
The order in which the operands are evaluated is undefined.
The operands are assigned to their respective positions in the result vector as they appear in memory order.
That is, the first element of the first operand is assigned to result.x, the second element of the first operand (or the first element of the second operand if the first operand was a scalar) is assigned to result.y, etc.
In the case of the form that has a single scalar operand, the operand is replicated across all lanes of the vector.</p></div>
<div class="paragraph"><p>Examples:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">float4</span> f <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">3</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">4</span><span style="color: #990000">.</span>0f<span style="color: #990000">);</span>
<span style="color: #008080">uint4</span> u <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">uint4</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// u will be (1, 1, 1, 1).</span></span>
<span style="color: #008080">float4</span> f <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">float2</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">.</span>0f<span style="color: #990000">),</span>
<span style="font-weight: bold"><span style="color: #000000">float2</span></span><span style="color: #990000">(</span><span style="color: #993399">3</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">4</span><span style="color: #990000">.</span>0f<span style="color: #990000">));</span>
<span style="color: #008080">float4</span> f <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #000000">float2</span></span><span style="color: #990000">(</span><span style="color: #993399">2</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">3</span><span style="color: #990000">.</span>0f<span style="color: #990000">),</span> <span style="color: #993399">4</span><span style="color: #990000">.</span>0f<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> f <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">.</span>0f<span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// error</span></span>
<span style="color: #008080">int4</span> i <span style="color: #990000">=</span> <span style="color: #990000">(</span>int4<span style="color: #990000">)(</span><span style="color: #993399">1</span><span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">,</span> <span style="color: #993399">3</span><span style="color: #990000">,</span> <span style="color: #993399">4</span><span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// warning, vector literals (from OpenCL C) are</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// not part of OpenCL C++,</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// this expression will be evaluated to (int4)4,</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// and i will be (4, 4, 4, 4)</span></span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="vector-types-and-usual-arithmetic-conversions">Vector Types and Usual Arithmetic Conversions</h5>
<div class="paragraph"><p>Many operators that expect operands of arithmetic type cause conversions and yield result types in a similar way.
The purpose is to determine a common real type for the operands and result.
For the specified operands, each operand is converted, without change of type domain, to a type whose corresponding real type is the common real type.
For this purpose, all vector types shall be considered to have higher conversion ranks than scalars.
Unless explicitly stated otherwise, the common real type is also the corresponding real type of the result, whose type domain is the type domain of the operands if they are the same, and complex otherwise.
This pattern is called the usual arithmetic conversions.
If the operands are of more than one vector type, then an error shall occur.
Implicit conversions between vector types are not permitted, per <em><a href="#implicit-type-conversions">Implicit Type Conversions</a> section</em>.</p></div>
<div class="paragraph"><p>Otherwise, if there is only a single vector type, and all other operands are scalar types, the scalar types are converted to the type of the vector element, then widened into a new vector containing the same number of elements as the vector, by duplication of the scalar value across the width of the new vector.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="alignment-of-types">2.1.3. Alignment of Types</h4>
<div class="paragraph"><p>A data item declared to be a data type in memory is always aligned to the size of the data type in bytes.
For example, a <span class="monospaced">float4</span> variable will be aligned to a 16-byte boundary, a <span class="monospaced">char2</span> variable will be aligned to a 2-byte boundary.</p></div>
<div class="paragraph"><p>For 3-component vector data types, the size of the data type is <span class="monospaced">4 * sizeof(component)</span>.
This means that a 3-component vector data type will be aligned to a <span class="monospaced">4 * sizeof(component)</span> boundary.
The <span class="monospaced">vload3</span> and <span class="monospaced">vstore3</span> built-in functions can be used to read and write, respectively, 3-component vector data types from an array of packed scalar data type.</p></div>
<div class="paragraph"><p>A built-in data type that is not a power of two bytes in size must be aligned to the next larger power of two.
This rule applies to built-in types only, not structs or unions.</p></div>
<div class="paragraph"><p>The OpenCL C++ compiler is responsible for aligning data items to the appropriate alignment as required by the data type.
For arguments to a kernel function declared to be a pointer to a data type, the OpenCL compiler can assume that the pointee is always appropriately aligned as required by the data type.
The behavior of an unaligned load or store is undefined, except for the <span class="monospaced">vload</span><em>n</em>, <span class="monospaced">vload_half</span><em>n</em>, <span class="monospaced">vstore</span><em>n</em>, and <span class="monospaced">vstore_half</span><em>n</em> functions defined in <em><a href="#vector-data-load-and-store-functions">Vector Data Load and Store Functions</a> section</em>.
The vector load functions can read a vector from an address aligned to the element type of the vector.
The vector store functions can write a vector to an address aligned to the element type of the vector.</p></div>
</div>
</div>
<div class="sect2">
<h3 id="keywords">2.2. Keywords</h3>
<div class="paragraph"><p>The following names are reserved for use as keywords in OpenCL C++ and shall not be used otherwise.</p></div>
<div class="ulist"><ul>
<li>
<p>
Names reserved as keywords by C++14.
</p>
</li>
<li>
<p>
OpenCL C++ data types defined in <a href="#device_builtin_scalar_data_types">Device built-in scalar data types</a> and <a href="#device_builtin_vector_data_types">Device built-in vector data types</a> tables.
</p>
</li>
<li>
<p>
Function qualifiers: <span class="monospaced">__kernel</span> and <span class="monospaced">kernel</span>.
</p>
</li>
<li>
<p>
Access qualifiers: <span class="monospaced">__read_only</span>, <span class="monospaced">read_only</span>, <span class="monospaced">__write_only</span>, <span class="monospaced">write_only</span>, <span class="monospaced">__read_write</span> and <span class="monospaced">read_write</span>.
</p>
</li>
</ul></div>
</div>
<div class="sect2">
<h3 id="implicit-type-conversions">2.3. Implicit Type Conversions</h3>
<div class="paragraph"><p>Implicit conversions between scalar built-in types defined in <a href="#device_builtin_scalar_data_types">Device built-in scalar data types</a> table (except <span class="monospaced">void</span>) are supported.
When an implicit conversion is done, it is not just a re-interpretation of the expression&#8217;s value, but a conversion of that value to an equivalent value in the new type.
For example, the integer value 5 will be converted to the floating-point value 5.0.</p></div>
<div class="paragraph"><p>Implicit conversions from a scalar type to a vector type are allowed.
In this case, the scalar may be subject to the usual arithmetic conversion to the element type used by the vector.
The scalar type is then widened to the vector.
If conversion from a scalar type to the element type used by the vector result in truncation or precision loss, the program is ill-formed, with the exception that:</p></div>
<div class="ulist"><ul>
<li>
<p>
if scalar value is prvalue of literal type and the value is representable as the element type, the conversion should take place without error (warnings may be generated in this case).
</p>
</li>
</ul></div>
<div class="paragraph"><p>Implicit conversions between built-in vector data types are disallowed.
Explicit conversions described in <em><a href="#conversions-library">Conversions Library</a> section</em> must be used instead.</p></div>
<div class="paragraph"><p>Implicit conversions for pointer types follow the rules described in the C++14 specification.</p></div>
</div>
<div class="sect2">
<h3 id="expressions">2.4. Expressions</h3>
<div class="paragraph"><p>All expressions behave as described in <em>[ISO/IEC 14882:2014: expr, ch. 5]</em> with the the restrictions described in <em><a href="#opencl_cxx_restrictions">OpenCL C++ Restrictions</a> section</em> and the following changes:</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
All built-in operators have their vector counterparts.
</p>
</li>
<li>
<p>
All built-in vector operations, apart from conditional operator, are performed component-wise.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">Conditional operator logical-or-expression cannot be of vector type.</td>
</tr></table>
</div>
</li>
<li>
<p>
Built in operators taking two vectors require that vectors have the same number of components, otherwise expression is ill-formed.
</p>
</li>
<li>
<p>
Vector swizzle operations meet extra requirements and restrictions described in <em><a href="#vector-component-access">Vector Component Access</a> section</em>.
</p>
</li>
<li>
<p>
Implicit and explicit casts between vector types are not legal.
The conversion between vector types can be done only using <span class="monospaced">convert_cast</span> from <em><a href="#conversions-library">Conversions Library</a> section</em>.
</p>
<div class="paragraph"><p>Examples:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">int4</span> i<span style="color: #990000">;</span>
<span style="color: #008080">uint4</span> u <span style="color: #990000">=</span> <span style="color: #990000">(</span>uint4<span style="color: #990000">)</span> i<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// not allowed</span></span>
<span style="color: #008080">float4</span> f<span style="color: #990000">;</span>
<span style="color: #008080">int4</span> i <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">static_cast</span></span><span style="color: #990000">&lt;</span>int4<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// not allowed</span></span>
<span style="color: #008080">float4</span> f<span style="color: #990000">;</span>
<span style="color: #008080">int8</span> i <span style="color: #990000">=</span> <span style="color: #990000">(</span>int8<span style="color: #990000">)</span> f<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// not allowed</span></span></tt></pre></div></div>
</li>
<li>
<p>
Implicit and explicit casts from scalar to vector types are supported.
</p>
</li>
<li>
<p>
All built-in arithmetic operators return result of the same built-in type (integer or floating-point) as the type of the operands, after operand type conversion.
After conversion, the following cases are valid:
</p>
<div class="olist loweralpha"><ol class="loweralpha">
<li>
<p>
The two operands are scalars. In this case, the operation is applied, resulting in a scalar.
</p>
</li>
<li>
<p>
One operand is a scalar, and the other is a vector.
In this case, the scalar may be subject to the usual arithmetic conversion to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of components as the vector operand.
The operation is done component-wise resulting in the same size vector.
</p>
</li>
<li>
<p>
The two operands are vectors of the same type.
In this case, the operation is done component-wise resulting in the same size vector.
</p>
</li>
</ol></div>
</li>
<li>
<p>
The built-in relational and equality operators equal (<span class="monospaced">==</span>), not equal (<span class="monospaced">!=</span>), greater than (<span class="monospaced">&gt;</span>), greater than or equal (<span class="monospaced">&gt;=</span>), less than (<span class="monospaced">&lt;</span>), and less than or equal (<span class="monospaced">&lt;=</span>) operate on scalar and vector types.
All relational and equality operators result in a boolean (scalar or vector) type.
After operand type conversion, the following cases are valid:
</p>
<div class="olist loweralpha"><ol class="loweralpha">
<li>
<p>
The two operands are scalars.
In this case, the operation is applied, resulting in a boolean scalar.
</p>
</li>
<li>
<p>
One operand is a scalar, and the other is a vector.
In this case, the scalar may be subject to the usual arithmetic conversion to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of components as the vector operand.
The operation is done component-wise resulting in the same size boolean vector.
</p>
</li>
<li>
<p>
The two operands are vectors of the same type.
In this case, the operation is done component-wise resulting in the same size boolean vector.
</p>
</li>
</ol></div>
</li>
<li>
<p>
The built-in bitwise operators and (<span class="monospaced">&amp;</span>), or (<span class="monospaced">|</span>), exclusive or (<span class="monospaced">^</span>), not (<span class="monospaced">~</span>) operate on all scalar and vector built-in types except the built-in scalar and vector float types.
For vector built-in types, the operators are applied component-wise.
If one operand is a scalar and the other is a vector, the scalar may be subject to the usual arithmetic conversion to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of components as the vector operand.
The operation is done component-wise resulting in the same size vector.
</p>
</li>
<li>
<p>
The built-in logical operators and (<span class="monospaced">&amp;&amp;</span>), or (<span class="monospaced">||</span>) operate on all scalar and vector built-in types.
For scalar built-in types the logical operator and (&amp;&amp;) will only evaluate the right hand operand if the left hand operand compares unequal to <span class="monospaced">false</span>.
For scalar built-in types the logical operator or (<span class="monospaced">||</span>) will only evaluate the right hand operand if the left hand operand compares equal to <span class="monospaced">false</span>.
For built-in vector types, both operands are evaluated and the operators are applied component-wise.
If one operand is a scalar and the other is a vector, the scalar may be subject to the usual arithmetic conversion to the element type used by the vector operand.
The scalar type is then widened to a vector that has the same number of components as the vector operand.
The operation is done component-wise resulting in the same size vector.
</p>
<div class="paragraph"><p>The result is a scalar or vector boolean.</p></div>
</li>
<li>
<p>
The built-in logical unary operator not (<span class="monospaced">!</span>) operates on all scalar and vector built-in types.
For built-in vector types, the operators are applied component-wise.
</p>
<div class="paragraph"><p>The result is a scalar or vector boolean.</p></div>
</li>
<li>
<p>
The built-in conditional operator (?: described in <em>[ISO/IEC 14882:2014: expr, ch. 5.2]</em> operates on three expressions (<span class="monospaced">exp1 ? exp2 : exp3</span>).
This operator evaluates the first expression <span class="monospaced">exp1</span>, which must be a scalar boolean result.
If the result is <em>true</em> it selects to evaluate the second expression, otherwise it selects to evaluate the third expression.
The second and third expressions can be any type, as long their types match, or there is a conversion in <em><a href="#implicit-type-conversions">Implicit Type Conversions</a> section</em> that can be applied to one of the expressions to make their types match, or one is a vector and the other is a scalar and the scalar may be subject to the usual arithmetic conversion to the element type used by the vector operand and widened to the same type as the vector type.
</p>
<div class="paragraph"><p>This resulting matching type is the type of the entire expression.</p></div>
</li>
<li>
<p>
The built-in shift operators are supported for built-in vector types except the built-in scalar and vector float types.
For built-in vector types, the operators are applied component-wise.
For the right-shift (<span class="monospaced">&gt;&gt;</span>), left-shift (<span class="monospaced">&lt;&lt;</span>) operators, the rightmost operand must be a scalar if the first operand is a scalar, and the rightmost operand can be a vector or scalar if the first operand is a vector.
The result of <span class="monospaced">E1 &lt;&lt; E2</span> is <span class="monospaced">E1</span> left-shifted by <span class="monospaced">log2(N)</span> least significant bits in <span class="monospaced">E2</span> viewed as an unsigned integer value, where <span class="monospaced">N</span> is the number of bits used to represent the data type of <span class="monospaced">E1</span> after integer promotion, if <span class="monospaced">E1</span> is a scalar, or the number of bits used to represent the type of <span class="monospaced">E1</span> elements, if <span class="monospaced">E1</span> is a vector.
The vacated bits are filled with zeros.
The result of <span class="monospaced">E1 &gt;&gt; E2</span> is <span class="monospaced">E1</span> right-shifted by <span class="monospaced">log2(N)</span> least significant bits in <span class="monospaced">E2</span> viewed as an unsigned integer value, where <span class="monospaced">N</span> is the number of bits used to represent the data type of <span class="monospaced">E1</span> after integer promotion, if <span class="monospaced">E1</span> is a scalar, or the number of bits used to represent the type of <span class="monospaced">E1</span> elements, if <span class="monospaced">E1</span> is a vector.
</p>
<div class="paragraph"><p>If <span class="monospaced">E1</span> has an unsigned type or if <span class="monospaced">E1</span> has a signed type and a nonnegative value, the vacated bits are filled with zeros.</p></div>
<div class="paragraph"><p>If <span class="monospaced">E1</span> has a signed type and a negative value, the vacated bits are filled with ones.</p></div>
</li>
</ol></div>
</div>
<div class="sect2">
<h3 id="address-spaces">2.5. Address Spaces</h3>
<div class="paragraph"><p>The OpenCL C++ kernel language doesn&#8217;t introduce any explicit named address spaces, but they are implemented as part of the standard library described in <em><a href="#address-spaces-library">Address Spaces Library</a> section</em>.
There are 4 types of memory supported by all OpenCL devices: global, local, private and constant.
The developers should be aware of them and know their limitations.</p></div>
<div class="sect3">
<h4 id="implicit-storage-classes">2.5.1. Implicit Storage Classes</h4>
<div class="paragraph"><p>The OpenCL C++ compiler can deduce an address space based on the scope where an object is declared:</p></div>
<div class="ulist"><ul>
<li>
<p>
If a variable is declared in program scope, with <span class="monospaced">static</span> or <span class="monospaced">extern</span> specifier and the standard library storage class (<em><a href="#address-spaces-library">Address Spaces Library</a> section</em>) is not used, the variable is allocated in the global memory of a device.
</p>
</li>
<li>
<p>
If a variable is declared in function scope, without <span class="monospaced">static</span> specifier and the standard library storage class (<em><a href="#address-spaces-library">Address Spaces Library</a> section</em>) is not used, the variable is allocated in the private memory of a device.
</p>
</li>
</ul></div>
</div>
<div class="sect3">
<h4 id="memory-pools">2.5.2. Memory Pools</h4>
<div class="sect4">
<h5 id="global">Global</h5>
<div class="paragraph"><p>The variables are allocated from the global memory pool if they meet the criteria described in <em><a href="#implicit-storage-classes">Implicit Storage Classes</a> section</em> for the implicit global storage class or they are declared using explicit global storage class from the standard library (<em><a href="#global-class">global class</a> section</em>).</p></div>
<div class="paragraph"><p>The global memory objects can be:</p></div>
<div class="ulist"><ul>
<li>
<p>
Passed by pointer or reference to a kernel from the host.
In such case the host manages their visibility, lifetime and a type of allocation.
</p>
</li>
<li>
<p>
Declared in the program source (<span class="monospaced">static</span>, <span class="monospaced">extern</span> and program scope global variables).
In such case they are:
</p>
<div class="ulist"><ul>
<li>
<p>
the coarse-grained SVM allocations that can be usable by multiple kernels on the same device safely
</p>
</li>
<li>
<p>
not shared across devices
</p>
</li>
<li>
<p>
not accessible from the host
</p>
</li>
<li>
<p>
their lifetime is the same as a program
</p>
</li>
</ul></div>
</li>
</ul></div>
<div class="paragraph"><p>The non-trivial constructors and destructors are supported with limitations described in <em><a href="#memory-initialization">Memory initialization</a> section</em>.</p></div>
<div class="paragraph"><p>The constructors of objects in global memory are executed before the first kernel execution in the program.
The destructors executed at program release time.</p></div>
<div class="paragraph"><p>The additional restrictions may apply if the explicit global storage class is used.
Please refer to <em><a href="#restrictions-2">Restrictions</a> section</em> for more details.</p></div>
</div>
<div class="sect4">
<h5 id="local">Local</h5>
<div class="paragraph"><p>The local variables can be only allocated in a program using the explicit local storage class from the standard library (<em><a href="#local-class">local class</a> section</em>).
This type of memory is allocated for each work-group executing the kernel and exist only for the lifetime of the work-group executing the kernel.</p></div>
<div class="paragraph"><p>The non-trivial constructors and destructors are supported with limitations described in <em><a href="#memory-initialization">Memory initialization</a> section</em>.</p></div>
<div class="paragraph"><p>The constructors of objects in local memory are executed by one work-item before the kernel body execution.
The destructors are executed by one work-item after the kernel body execution.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">initialization of local variables can cause performance degradation.</td>
</tr></table>
</div>
<div class="paragraph"><p>The additional restrictions may apply if the explicit local storage class is used.
Please refer to <em><a href="#restrictions-2">Restrictions</a> section</em> for more details.</p></div>
</div>
<div class="sect4">
<h5 id="private">Private</h5>
<div class="paragraph"><p>The variables are allocated from the private memory pool if they meet the criteria described in <a href="#implicit-storage-classes">Implicit Storage Classes</a> for the implicit private storage class or they were declared using explicit private storage class from the standard library (<em><a href="#priv-class">priv class</a> section</em>).</p></div>
<div class="paragraph"><p>The non-trivial constructors and destructors are supported.</p></div>
<div class="paragraph"><p>The additional restrictions may apply if the explicit priv storage class is used.
Please refer to <em><a href="#restrictions-2">Restrictions</a> section</em> for more details.</p></div>
</div>
<div class="sect4">
<h5 id="constant">Constant</h5>
<div class="paragraph"><p>The constant variables can be only allocated in a program using the explicit constant storage class from the standard library (<em><a href="#constant-class">constant class</a> section</em>).
The variables declared using the <span class="monospaced">constant&lt;T&gt;</span> class refer to memory objects allocated from the global memory pool and which are accessed inside a kernel(s) as read-only variables.
These read-only variables can be accessed by all (global) work-items of the kernel during its execution.</p></div>
<div class="paragraph"><p>The constant objects must be constructible at compile time, they cannot have any user defined constructors, destructors, methods and operators.
Otherwise behavior is undefined.</p></div>
<div class="paragraph"><p>The additional restrictions may apply if the explicit constant storage class is used.
Please refer to <em><a href="#restrictions-2">Restrictions</a> section</em> for more details.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="pointers-and-references">2.5.3. Pointers and references</h4>
<div class="paragraph"><p>All C++ pointers and references point to an object in the unnamed/generic address space if the explicit address space pointer classes are not used.
The explicit address space pointer classes are implemented as a part of the standard library and they are described in <em><a href="#explicit-address-space-pointer-classes">Explicit address space pointer classes</a> section</em>.</p></div>
</div>
<div class="sect3">
<h4 id="memory-initialization">2.5.4. Memory initialization</h4>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 8. Supported memory initializers</caption>
<col style="width:13%;">
<col style="width:12%;">
<col style="width:25%;">
<col style="width:25%;">
<col style="width:25%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Storage memory (address space)</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Scope type</strong></th>
<th class="tableblock halign-left valign-top" colspan="3" ><strong>Initialization type</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">uninitialized (no constructor or trivial default constructor)</p>
<p class="tableblock"><strong>AND</strong></p>
<p class="tableblock">trivial destructor</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">initialized by constant expression</p>
<p class="tableblock"><strong>AND</strong></p>
<p class="tableblock">trivial destructor</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">custom initializer</p>
<p class="tableblock"><strong>OR</strong></p>
<p class="tableblock">custom destructor</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" rowspan="4" ><p class="tableblock">local</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">program</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported (not zero-pre-init)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">kernel</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are not zero-pre-initialized.</p>
<p class="tableblock">Optional zero-pre-initialization possible using switch: -cl-zero-init-local-mem-vars</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are not zero-pre-initialized.</p>
<p class="tableblock">Materialize temporary expressions are not supported.</p>
<p class="tableblock">Optional zero-pre-initialization possible using switch: -cl-zero-init-local-mem-vars</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are not zero-pre-initialized.</p>
<p class="tableblock">Materialize temporary expressions are not supported.</p>
<p class="tableblock">Optional zero-pre-initialization possible using switch: -cl-zero-init-local-mem-vars</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">local (non-kernel)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">class (static data member)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are not zero-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" rowspan="3" ><p class="tableblock">global</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">program</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are zero-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are zero or constexpr-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">kernel / local</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are zero-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are zero or constexpr-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">class (static data member)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are zero-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are zero or constexpr-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">constant</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(any)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are zero-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p>
<p class="tableblock">Variables are zero or constexpr-pre-initialized.</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">not supported</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">private</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(any)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">supported</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect2">
<h3 id="kernel-functions">2.6. Kernel Functions</h3>
<div class="sect3">
<h4 id="function-qualifiers">2.6.1. Function Qualifiers</h4>
<div class="paragraph"><p>The <span class="monospaced">kernel</span> (or <span class="monospaced">__kernel</span>) qualifier declares a function to be a kernel that can be executed by an application on an OpenCL device(s).
The following rules apply to functions that are declared with this qualifier:</p></div>
<div class="ulist"><ul>
<li>
<p>
It can be executed on the device only.
</p>
</li>
<li>
<p>
It can be enqueued by the host or on the device.
</p>
</li>
</ul></div>
<div class="paragraph"><p>The <span class="monospaced">kernel</span> and <span class="monospaced">__kernel</span> names are reserved for use as functions qualifiers and shall not be used otherwise.</p></div>
</div>
<div class="sect3">
<h4 id="restrictions">2.6.2. Restrictions</h4>
<div class="sect4">
<h5 id="kernel-function-restrictions">Kernel Function Restrictions</h5>
<div class="ulist"><ul>
<li>
<p>
A kernel functions are by implicitly declared as <span class="monospaced">extern "C"</span>.
</p>
</li>
<li>
<p>
A kernel function cannot be overloaded.
</p>
</li>
<li>
<p>
A kernel function cannot be template functions.
</p>
</li>
<li>
<p>
A kernel function cannot be called by another kernel function.
</p>
</li>
<li>
<p>
A kernel function cannot have parameters specified with default values.
</p>
</li>
<li>
<p>
A kernel function must have the return type <span class="monospaced">void</span>.
</p>
</li>
<li>
<p>
A kernel function cannot be called <span class="monospaced">main</span>.
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="kernel-parameter-restrictions">Kernel Parameter Restrictions</h5>
<div class="paragraph"><p>The OpenCL host compiler and the OpenCL C++ kernel language device compiler can have different requirements for i.e. type sizes, data packing and alignment, etc., therefore the kernel parameters must meet the following requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
Types passed by pointer or reference must be standard layout types.
</p>
</li>
<li>
<p>
Types passed by value must be POD types.
</p>
</li>
<li>
<p>
Types cannot be declared with the built-in bool scalar type, vector type or a class that contain bool scalar or vector type fields.
</p>
</li>
<li>
<p>
Types cannot be structures and classes with bit field members.
</p>
</li>
<li>
<p>
Marker types must be passed by value (<em><a href="#marker-types">Marker Types</a> section</em>).
</p>
</li>
<li>
<p>
<span class="monospaced">global</span>, <span class="monospaced">constant</span>, <span class="monospaced">local</span> storage classes can be passed only by reference or pointer. More details in <em><a href="#explicit-address-space-storage-classes">Explicit address space storage classes</a> section</em>.
</p>
</li>
<li>
<p>
Pointers and references must point to one of the following address spaces: global, local or constant.
</p>
</li>
</ul></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="preprocessor-directives-and-macros">2.7. Preprocessor Directives and Macros</h3>
<div class="paragraph"><p>The preprocessing directives defined by the C++14 specification (<em>section 16</em>) are supported.</p></div>
<div class="paragraph"><p>The <span class="monospaced">#pragma</span> directive is described as:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#pragma</span></span> pp<span style="color: #990000">-</span><span style="color: #008080">tokensopt</span> <span style="font-weight: bold"><span style="color: #0000FF">new</span></span><span style="color: #990000">-</span>line</tt></pre></div></div>
<div class="paragraph"><p>A <span class="monospaced">#pragma</span> directive where the preprocessing token <span class="monospaced">OPENCL</span> (used instead of <span class="monospaced">STDC</span>) does not immediately follow pragma in the directive (prior to any macro replacement) causes the implementation to behave in an implementation-defined manner.
The behavior might cause translation to fail or cause the translator or the resulting program to behave in a non-conforming manner.
Any such pragma that is not recognized by the implementation is ignored.
If the preprocessing token <span class="monospaced">OPENCL</span> does immediately follow pragma in the directive (prior to any macro replacement), then no macro replacement is performed on the directive, and the directive shall have one of the following forms whose meanings are described elsewhere:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#pragma</span></span> <span style="color: #008080">OPENCL</span> <span style="color: #008080">FP_CONTRACT</span> on<span style="color: #990000">-</span>off<span style="color: #990000">-</span><span style="font-weight: bold"><span style="color: #0000FF">switch</span></span> <span style="font-style: italic"><span style="color: #9A1900">// on-off-switch: one of ON OFF DEFAULT</span></span>
<span style="font-weight: bold"><span style="color: #000080">#pragma</span></span> OPENCL <span style="color: #008080">EXTENSION</span> extensionname <span style="color: #990000">:</span> behavior
<span style="font-weight: bold"><span style="color: #000080">#pragma</span></span> OPENCL <span style="color: #008080">EXTENSION</span> all <span style="color: #990000">:</span> behavior</tt></pre></div></div>
<div class="paragraph"><p>The following predefined macro names are available.</p></div>
<div class="paragraph"><p><span class="monospaced">__FILE__</span> The presumed name of the current source file (a character string literal).</p></div>
<div class="paragraph"><p><span class="monospaced">__LINE__</span> The presumed line number (within the current source file) of the current source line (an integer constant).</p></div>
<div class="paragraph"><p><span class="monospaced">__OPENCL_CPP_VERSION__</span> substitutes an integer reflecting the OpenCL C++ version specified when compiling the OpenCL C++ program.
The version of OpenCL C++ described in this document will have <span class="monospaced">__OPENCL_CPP_VERSION__</span> substitute the integer <span class="monospaced">100</span>.</p></div>
<div class="paragraph"><p>The macro names defined by the C++14 specification in <em>section 16</em> but not currently supported by OpenCL are reserved for future use.</p></div>
<div class="paragraph"><p>The predefined identifier <span class="monospaced">__func__</span> is available.</p></div>
</div>
<div class="sect2">
<h3 id="attribute-qualifiers">2.8. Attribute Qualifiers</h3>
<div class="paragraph"><p>The <span class="monospaced">[[ ]]</span> attribute qualifier syntax allows additional attributes to be attached to types, variables, kernel functions, kernel parameters, or loops.</p></div>
<div class="paragraph"><p>Some attributes change the semantics of the program and are required for program correctness.
Other attributes are optional hints that may be ignored without affecting program correctness.
Nevertheless, frontend compilers that compile to an intermediate representation are required to faithfully pass optional attribute hints with an intermediate representation to device compilers for further processing.</p></div>
<div class="sect3">
<h4 id="optional-type-attributes">2.8.1. Optional Type Attributes</h4>
<div class="paragraph"><p><span class="monospaced">[[ ]]</span> attribute syntax can be used to specify special attributes of enum, class and union types when you define such types.
Two attributes are currently defined for types: <span class="monospaced">aligned</span>, and <span class="monospaced">packed</span>.</p></div>
<div class="paragraph"><p>You may specify type attributes in an enum, class or union type declaration or definition, or for other types in a typedef declaration.</p></div>
<div class="paragraph"><p>For an enum, class or union type, you may specify attributes either between the enum, class or union tag and the name of the type, or just past the closing curly brace of the definition.
The former syntax is preferred.</p></div>
<div class="sect4">
<h5 id="claligned-alignment">cl::aligned (alignment)</h5>
<div class="paragraph"><p>This attribute specifies a minimum alignment (in bytes) for variables of the specified type.
For example, the declarations:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">S</span> <span style="color: #FF0000">{</span> <span style="color: #009900">short</span> f<span style="color: #990000">[</span><span style="color: #993399">3</span><span style="color: #990000">];</span> <span style="color: #FF0000">}</span> <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">8</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #009900">int</span> more_aligned_int <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">8</span><span style="color: #990000">)]];</span></tt></pre></div></div>
<div class="paragraph"><p>force the compiler to insure (as far as it can) that each variable whose type is struct S or <span class="monospaced">more_aligned_int</span> will be allocated and aligned <em>at least</em> on a 8-byte boundary.</p></div>
<div class="paragraph"><p>Note that the alignment of any given struct or union type is required by the C++ standard to be at least a perfect multiple of the lowest common multiple of the alignments of all of the members of the struct or union in question and must also be a power of two.
This means that you <em>can</em> effectively adjust the alignment of a class or union type by attaching an aligned attribute to any one of the members of such a type, but the notation illustrated in the example above is a more obvious, intuitive, and readable way to request the compiler to adjust the alignment of an entire class or union type.</p></div>
<div class="paragraph"><p>As in the preceding example, you can explicitly specify the alignment (in bytes) that you wish the compiler to use for a given class or union type.
Alternatively, you can leave out the alignment factor and just ask the compiler to align a type to the maximum useful alignment for the target machine you are compiling for.
For example, you could write:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">S</span> <span style="color: #FF0000">{</span> <span style="color: #009900">short</span> f<span style="color: #990000">[</span><span style="color: #993399">3</span><span style="color: #990000">];</span> <span style="color: #FF0000">}</span> <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span>aligned<span style="color: #990000">]];</span></tt></pre></div></div>
<div class="paragraph"><p>Whenever you leave out the alignment factor in an aligned attribute specification, the compiler automatically sets the alignment for the type to the largest alignment which is ever used for any data type on the target machine you are compiling for.
In the example above, the size of each short is 2 bytes, and therefore the size of the entire struct S type is 6 bytes.
The smallest power of two which is greater than or equal to that is 8, so the compiler sets the alignment for the entire struct S type to 8 bytes.</p></div>
<div class="paragraph"><p>Note that the effectiveness of aligned attributes may be limited by inherent limitations of the OpenCL device and compiler.
For some devices, the OpenCL compiler may only be able to arrange for variables to be aligned up to a certain maximum alignment.
If the OpenCL compiler is only able to align variables up to a maximum of 8 byte alignment, then specifying <span class="monospaced">aligned(16)</span> will still only provide you with 8 byte alignment.
See your platform-specific documentation for further information.</p></div>
<div class="paragraph"><p>The aligned attribute can only increase the alignment; but you can decrease it by specifying packed as well.
See below.</p></div>
</div>
<div class="sect4">
<h5 id="clpacked">cl::packed</h5>
<div class="paragraph"><p>This attribute, attached to class or union type definition, specifies that each member of the structure or union is placed to minimize the memory required.
When attached to an enum definition, it indicates that the smallest integral type should be used.</p></div>
<div class="paragraph"><p>Specifying this attribute for class and union types is equivalent to specifying the packed attribute on each of the structure or union members.</p></div>
<div class="paragraph"><p>In the following example struct my_packed_struct&#8217;s members are packed closely together, but the internal layout of its s member is not packed.
To do that, struct <span class="monospaced">my_unpacked_struct</span> would need to be packed, too.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">my_unpacked_struct</span>
<span style="color: #FF0000">{</span>
<span style="color: #009900">char</span> c<span style="color: #990000">;</span>
<span style="color: #009900">int</span> i<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span>packed<span style="color: #990000">]]</span> my_packed_struct
<span style="color: #FF0000">{</span>
<span style="color: #009900">char</span> c<span style="color: #990000">;</span>
<span style="color: #009900">int</span> i<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">my_unpacked_struct</span> s<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>You may only specify this attribute on the definition of an enum, class or union, not on a typedef which does not also define the enumerated type, structure or union.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="optional-variable-attributes">2.8.2. Optional Variable Attributes</h4>
<div class="paragraph"><p>[[ ]] syntax allows you to specify special attributes of variables or structure fields.
The following attribute qualifiers are currently defined:</p></div>
<div class="sect4">
<h5 id="claligned">cl::aligned</h5>
<div class="paragraph"><p>This attribute specifies a minimum alignment for the variable or class field, measured in bytes.
For example, the declaration:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">int</span> x <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">16</span><span style="color: #990000">)]]</span> <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>causes the compiler to allocate the global variable <span class="monospaced">x</span> on a 16-byte boundary.
The alignment value specified must be a power of two.</p></div>
<div class="paragraph"><p>You can also specify the alignment of structure fields.
For example, to create double-word aligned int pair, you could write:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">foo</span> <span style="color: #FF0000">{</span> <span style="color: #009900">int</span> x<span style="color: #990000">[</span><span style="color: #993399">2</span><span style="color: #990000">]</span> <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">8</span><span style="color: #990000">)]];</span> <span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>This is an alternative to creating a union with a double member that forces the union to be double-word aligned.</p></div>
<div class="paragraph"><p>As in the preceding examples, you can explicitly specify the alignment (in bytes) that you wish the compiler to use for a given variable or structure field.
Alternatively, you can leave out the alignment factor and just ask the compiler to align a variable or field to the maximum useful alignment for the target machine you are compiling for.
For example, you could write:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">short</span> array<span style="color: #990000">[</span><span style="color: #993399">3</span><span style="color: #990000">]</span> <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span>aligned<span style="color: #990000">]];</span></tt></pre></div></div>
<div class="paragraph"><p>Whenever you leave out the alignment factor in an aligned attribute specification, the OpenCL compiler automatically sets the alignment for the declared variable or field to the largest alignment which is ever used for any data type on the target device you are compiling for.</p></div>
<div class="paragraph"><p>When used on a class, or class member, the aligned attribute can only increase the alignment; in order to decrease it, the packed attribute must be specified as well.
When used as part of a typedef, the aligned attribute can both increase and decrease alignment, and specifying the packed attribute will generate a warning.</p></div>
<div class="paragraph"><p>Note that the effectiveness of aligned attributes may be limited by inherent limitations of the OpenCL device and compiler.
For some devices, the OpenCL compiler may only be able to arrange for variables to be aligned up to a certain maximum alignment.
If the OpenCL
compiler is only able to align variables up to a maximum of 8 byte alignment, then specifying <span class="monospaced">aligned(16)</span> will still only provide you with 8 byte alignment.
See your platform-specific documentation for further information.</p></div>
</div>
<div class="sect4">
<h5 id="clpacked-1">cl::packed</h5>
<div class="paragraph"><p>The <span class="monospaced">packed</span> attribute specifies that a variable or class field should have the smallest possible alignment - one byte for a variable, unless you specify a larger value with the aligned attribute.</p></div>
<div class="paragraph"><p>Here is a structure in which the field <span class="monospaced">x</span> is packed, so that it immediately follows a:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">foo</span>
<span style="color: #FF0000">{</span>
<span style="color: #009900">char</span> a<span style="color: #990000">;</span>
<span style="color: #009900">int</span> x<span style="color: #990000">[</span><span style="color: #993399">2</span><span style="color: #990000">]</span> <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span>packed<span style="color: #990000">]];</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>An attribute list placed at the beginning of a user-defined type applies to the variable of that type and not the type, while attributes following the type body apply to the type.</p></div>
<div class="paragraph"><p>For example:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-style: italic"><span style="color: #9A1900">/* a has alignment of 128 */</span></span>
<span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">128</span><span style="color: #990000">)]]</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">A</span> <span style="color: #FF0000">{</span> <span style="color: #009900">int</span> i<span style="color: #990000">;</span> <span style="color: #FF0000">}</span> a<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">/* b has alignment of 16 */</span></span>
<span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">16</span><span style="color: #990000">)]]</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">B</span> <span style="color: #FF0000">{</span> <span style="color: #009900">double</span> d<span style="color: #990000">;</span> <span style="color: #FF0000">}</span> <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">32</span><span style="color: #990000">)]]</span> b<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">A</span> a1<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">/* a1 has alignment of 4 */</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">B</span> b1<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">/* b1 has alignment of 32 */</span></span></tt></pre></div></div>
</div>
</div>
<div class="sect3">
<h4 id="optional-kernel-function-attributes">2.8.3. Optional Kernel Function Attributes</h4>
<div class="paragraph"><p>The kernel qualifier can be used with the <span class="monospaced">[[ ]]</span> attribute syntax to declare additional information about the kernel function.
The kernel function attributes must appear immediately before the kernel function to be affected.</p></div>
<div class="paragraph"><p>The following attributes are supported:</p></div>
<div class="sect4">
<h5 id="clwork_group_size_hint">cl::work_group_size_hint</h5>
<div class="paragraph"><p>The optional <span class="monospaced">[[cl::work_group_size_hint(X, Y, Z)]]</span> is a hint to the compiler and is intended to specify the work-group size that may be used i.e. value most likely to be specified by the <span class="monospaced">local_work_size</span> argument to <span class="monospaced">clEnqueueNDRangeKernel</span>.
For example the <span class="monospaced">[[cl::work_group_size_hint(1, 1, 1)]]</span> is a hint to the compiler that the kernel will most likely be executed with a work-group size of 1.</p></div>
<div class="paragraph"><p>The specialization constants (<em><a href="#specialization-constants-library">Specialization Constants</a> section</em>) can be used as arguments of <span class="monospaced">cl::work_group_size_hint</span> attribute.</p></div>
</div>
<div class="sect4">
<h5 id="clrequired_work_group_size">cl::required_work_group_size</h5>
<div class="paragraph"><p>The optional <span class="monospaced">[[cl::required_work_group_size(X, Y, Z)]]</span> is the work-group size that must be used as the <span class="monospaced">local_work_size</span> argument to <span class="monospaced">clEnqueueNDRangeKernel</span>.
This allows the compiler to optimize the generated code appropriately for this kernel.</p></div>
<div class="paragraph"><p>If <span class="monospaced">Z</span> is one, the <span class="monospaced">work_dim</span> argument to <span class="monospaced">clEnqueueNDRangeKernel</span> can be 2 or 3.
If <span class="monospaced">Y</span> and <span class="monospaced">Z</span> are one, the <span class="monospaced">work_dim</span> argument to <span class="monospaced">clEnqueueNDRangeKernel</span> can be 1, 2 or 3.</p></div>
<div class="paragraph"><p>The specialization constants (<em><a href="#specialization-constants-library">Specialization Constants</a> section</em>) can be used as arguments of <span class="monospaced">cl::required_work_group_size(X, Y, Z)</span> attribute.</p></div>
</div>
<div class="sect4">
<h5 id="clrequired_num_sub_groups">cl::required_num_sub_groups</h5>
<div class="paragraph"><p>The optional <span class="monospaced">[[cl::required_num_sub_groups(X)]]</span> is the number of sub-groups that must be generated by a kernel launch.
To ensure that this number is created the queries mapping number of sub-groups to local size may be used.
This allows the compiler to optimize the kernel based on the sub-group count and in addition allows the API to enforce correctness of kernel use to the user when concurrency of sub-groups is a requirement.</p></div>
<div class="paragraph"><p>The specialization constants (<em><a href="#specialization-constants-library">Specialization Constants</a> section</em>) can be used as argument of <span class="monospaced">cl::required_num_sub_groups</span> attribute.</p></div>
</div>
<div class="sect4">
<h5 id="clvec_type_hint">cl::vec_type_hint</h5>
<div class="paragraph"><p>The optional <span class="monospaced">[[cl::vec_type_hint(&lt;type&gt;)]]</span> is a hint to the compiler and is intended to be a representation of the computational <em>width</em> of the kernel, and should serve as the basis for calculating processor bandwidth utilization when the compiler is looking to autovectorize the code.
In the <span class="monospaced">[[cl::vec_type_hint(&lt;type&gt;)]]</span> qualifier <span class="monospaced">&lt;type&gt;</span> is one of the built-in vector types listed in <a href="#device_builtin_vector_data_types">Device built-in vector data types</a> table or the constituent scalar element types.
If <span class="monospaced">cl::vec_type_hint(&lt;type&gt;)</span> is not specified, the kernel is assumed to have the <span class="monospaced">[[cl::vec_type_hint(int)]]</span> qualifier.</p></div>
<div class="paragraph"><p>For example, where the developer specified a width of <span class="monospaced">float4</span>, the compiler should assume that the computation usually uses up to 4 lanes of a float vector, and would decide to merge work-items or possibly even separate one work-item into many threads to better match the hardware capabilities.
A conforming implementation is not required to autovectorize code, but shall support the hint.
A compiler may autovectorize, even if no hint is provided.
If an implementation merges N work-items into one thread, it is responsible for correctly handling cases where the number of global or local work-items in any dimension modulo N is not zero.</p></div>
<div class="paragraph"><p>Examples:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-style: italic"><span style="color: #9A1900">// autovectorize assuming float4 as the</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// basic computation width</span></span>
<span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">vec_type_hint</span></span><span style="color: #990000">(</span>float4<span style="color: #990000">)]]</span> kernel
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">(</span>cl<span style="color: #990000">::</span><span style="color: #008080">global_ptr&lt;float4&gt;</span> p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="color: #990000">...</span> <span style="color: #FF0000">}</span>
<span style="font-style: italic"><span style="color: #9A1900">// autovectorize assuming double as the</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// basic computation width</span></span>
<span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">vec_type_hint</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span><span style="color: #990000">)]]</span> kernel
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">(</span>cl<span style="color: #990000">::</span><span style="color: #008080">global_ptr&lt;float4&gt;</span> p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="color: #990000">...</span> <span style="color: #FF0000">}</span>
<span style="font-style: italic"><span style="color: #9A1900">// autovectorize assuming int (default)</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// as the basic computation width</span></span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">(</span>cl<span style="color: #990000">::</span><span style="color: #008080">global_ptr&lt;float4&gt;</span> p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="color: #990000">...</span> <span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
<div class="sect3">
<h4 id="optional-kernel-parameter-attributes">2.8.4. Optional Kernel Parameter Attributes</h4>
<div class="paragraph"><p>The kernel parameter can be used with the <span class="monospaced">[[ ]]</span> attribute syntax to declare additional information about an argument passed to the kernel.
The kernel parameter attributes must appear immediately before or after the kernel parameter declaration to be affected.</p></div>
<div class="paragraph"><p>The following attributes are supported:</p></div>
<div class="sect4">
<h5 id="clmax_size">cl::max_size</h5>
<div class="paragraph"><p>This attribute can be provided with a kernel argument of type <span class="monospaced">constant_ptr&lt;T&gt;</span>, <span class="monospaced">constant&lt;T&gt;*</span>, <span class="monospaced">constant&lt;T&gt;&amp;</span>, <span class="monospaced">local_ptr&lt;T&gt;</span>, <span class="monospaced">local&lt;T&gt;*</span>, <span class="monospaced">local&lt;T&gt;&amp;</span>.
The value of the attribute specifies the maximum size in bytes of the corresponding memory object.
This size cannot exceed the limits supported by the device:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE</span> for the kernel arguments in constant memory
</p>
</li>
<li>
<p>
<span class="monospaced">CL_DEVICE_LOCAL_MEM_SIZE</span> for the kernel arguments in local memory
</p>
</li>
</ul></div>
<div class="paragraph"><p>The specialization constants (<em><a href="#specialization-constants-library">Specialization Constants</a> section</em>) can be used as argument of <span class="monospaced">cl::max_size</span> attribute.</p></div>
<div class="paragraph"><p>Examples:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_memory&gt;</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">([[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">max_size</span></span><span style="color: #990000">(</span><span style="color: #993399">65536</span><span style="color: #990000">)]]</span> cl<span style="color: #990000">::</span><span style="color: #008080">constant_ptr&lt;int&gt;</span> arg<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
<div class="sect3">
<h4 id="optional-loop-attributes">2.8.5. Optional Loop Attributes</h4>
<div class="sect4">
<h5 id="clunroll_hint">cl::unroll_hint</h5>
<div class="paragraph"><p>The <span class="monospaced">[[cl::unroll_hint]]</span> and <span class="monospaced">[[cl::unroll_hint(n)]]</span> attribute qualifiers can be used to specify that a loop (<span class="monospaced">for</span>, <span class="monospaced">while</span> and <span class="monospaced">do</span> loops) can be unrolled.
This attribute qualifier can be used to specify full unrolling or partial unrolling by a specified amount.
This is a compiler hint and the compiler may ignore this directive.</p></div>
<div class="paragraph"><p><span class="monospaced">n</span> is the loop unrolling factor and must be a positive integral compile time constant expression.
An unroll factor of 1 disables unrolling.
If <span class="monospaced">n</span> is not specified, the compiler determines the unrolling factor for the loop.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">The <span class="monospaced">[[cl::unroll_hint(n)]]</span> attribute qualifier must appear immediately before the loop to be affected.</td>
</tr></table>
</div>
<div class="paragraph"><p>Examples:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">unroll_hint</span></span><span style="color: #990000">(</span><span style="color: #993399">2</span><span style="color: #990000">)]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">while</span></span> <span style="color: #990000">(*</span>s <span style="color: #990000">!=</span> <span style="color: #993399">0</span><span style="color: #990000">)</span>
<span style="color: #990000">*</span>p<span style="color: #990000">++</span> <span style="color: #990000">=</span> <span style="color: #990000">*</span>s<span style="color: #990000">++;</span></tt></pre></div></div>
<div class="paragraph"><p>This tells the compiler to unroll the above while loop by a factor of 2.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>cl<span style="color: #990000">::</span>unroll_hint<span style="color: #990000">]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span> <span style="color: #990000">(</span><span style="color: #009900">int</span> i<span style="color: #990000">=</span><span style="color: #993399">0</span><span style="color: #990000">;</span> i<span style="color: #990000">&lt;</span><span style="color: #993399">2</span><span style="color: #990000">;</span> i<span style="color: #990000">++)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>In the example above, the compiler will determine how much to unroll the loop.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">unroll_hint</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">)]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span> <span style="color: #990000">(</span><span style="color: #009900">int</span> i<span style="color: #990000">=</span><span style="color: #993399">0</span><span style="color: #990000">;</span> i<span style="color: #990000">&lt;</span><span style="color: #993399">32</span><span style="color: #990000">;</span> i<span style="color: #990000">++)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The above is an example where the loop should not be unrolled.</p></div>
<div class="paragraph"><p>Below are some examples of invalid usage of <span class="monospaced">[[cl::unroll_hint(n)]]</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">unroll_hint</span></span><span style="color: #990000">(-</span><span style="color: #993399">1</span><span style="color: #990000">)]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">while</span></span> <span style="color: #990000">(</span><span style="font-style: italic"><span style="color: #9A1900">/* ... */</span></span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The above example is an invalid usage of the loop unroll factor as the loop unroll factor is negative.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>cl<span style="color: #990000">::</span>unroll_hint<span style="color: #990000">]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span><span style="font-style: italic"><span style="color: #9A1900">/* ... */</span></span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The above example is invalid because the <span class="monospaced">unroll_hint</span> attribute qualifier is used on a non-loop construct.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt>kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">my_kernel</span></span><span style="color: #990000">(</span><span style="font-style: italic"><span style="color: #9A1900">/* ... */</span></span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> x<span style="color: #990000">;</span>
<span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">unroll_hint</span></span><span style="color: #990000">(</span>x<span style="color: #990000">)]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span> <span style="color: #990000">(</span><span style="color: #009900">int</span> i<span style="color: #990000">=</span><span style="color: #993399">0</span><span style="color: #990000">;</span> i<span style="color: #990000">&lt;</span>x<span style="color: #990000">;</span> i<span style="color: #990000">++)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The above example is invalid because the loop unroll factor is not a compile-time constant expression.</p></div>
</div>
<div class="sect4">
<h5 id="clivdep">cl::ivdep</h5>
<div class="paragraph"><p>The <span class="monospaced">[[cl::ivdep]]</span> (ignore vector dependencies) attribute qualifier is a hint to the compiler and may appear in loops to indicate that the compiler may assume there are no memory dependencies across loop iterations in order to autovectorize consecutive iterations of the loop.
This attribute qualifier may appear in one of the following
forms:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>cl<span style="color: #990000">::</span>ivdep<span style="color: #990000">]]</span>
<span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">ivdep</span></span><span style="color: #990000">(</span>len<span style="color: #990000">)]]</span></tt></pre></div></div>
<div class="paragraph"><p>If the parameter <span class="monospaced">len</span> is specified, it is used to specify the maximum number of consecutive iterations without loop-carried dependencies.
<span class="monospaced">len</span> is a lower bound on the distance of any loop-carried dependence, and it applies to arbitrary alignment.
For example, any 4 consecutive iterations can be vectorized with <span class="monospaced">cl::ivdep(4)</span>.
The <span class="monospaced">len</span> parameter must be a positive integer.
The final decision whether to autovectorize the complete loop may be subject to other compiler heuristics as well as flags e.g., <em>-cl-fast-relaxed-math</em> to ignore non-associated operations.</p></div>
<div class="paragraph"><p>Examples:</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>cl<span style="color: #990000">::</span>ivdep<span style="color: #990000">]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span> <span style="color: #990000">(</span><span style="color: #009900">int</span> i<span style="color: #990000">=</span><span style="color: #993399">0</span><span style="color: #990000">;</span> i<span style="color: #990000">&lt;</span>N<span style="color: #990000">;</span> i<span style="color: #990000">++)</span> <span style="color: #FF0000">{</span>
C<span style="color: #990000">[</span>i<span style="color: #990000">+</span>offset<span style="color: #990000">]</span> <span style="color: #990000">=</span> A<span style="color: #990000">[</span>i<span style="color: #990000">+</span>offset<span style="color: #990000">]</span> <span style="color: #990000">*</span> B<span style="color: #990000">[</span>i<span style="color: #990000">+</span>offset<span style="color: #990000">];</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>In the example above, assuming that <span class="monospaced">A</span> and <span class="monospaced">B</span> are not restricted pointers, it is unknown if <span class="monospaced">C</span> aliases <span class="monospaced">A</span> or <span class="monospaced">B</span>.
Placing the <span class="monospaced">[[cl::ivdep]]</span> attribute before the loop lets the compiler assume there are no memory dependencies across the loop iterations.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>c<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">ivdep</span></span><span style="color: #990000">(</span><span style="color: #993399">8</span><span style="color: #990000">)]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span> <span style="color: #990000">(</span><span style="color: #009900">int</span> i<span style="color: #990000">=</span><span style="color: #993399">0</span><span style="color: #990000">;</span> i<span style="color: #990000">&lt;</span>N<span style="color: #990000">;</span> i<span style="color: #990000">++)</span> <span style="color: #FF0000">{</span>
A<span style="color: #990000">[</span>i<span style="color: #990000">+</span>K<span style="color: #990000">]</span> <span style="color: #990000">=</span> A<span style="color: #990000">[</span>i<span style="color: #990000">]</span> <span style="color: #990000">*</span> B<span style="color: #990000">[</span>i<span style="color: #990000">];</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>In the example above, buffer <span class="monospaced">A</span> is read from and written to in the loop iterations.
In each iteration, the read and write to <span class="monospaced">A</span> are to different indices.
In this case it is not safe to vectorize the loop to a vector length greater than <span class="monospaced">K</span>, so the <span class="monospaced">len</span> parameter is specified with a value that is known to be not greater than any value that <span class="monospaced">K</span> may take during the execution of loop.
In this example we are guaranteed (by <span class="monospaced">len</span>) that <span class="monospaced">K</span> will always be greater than or equal to 8.</p></div>
<div class="paragraph"><p>Below is an example of invalid usage of <span class="monospaced">[[cl::ivdep]]</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">ivdep</span></span><span style="color: #990000">(-</span><span style="color: #993399">1</span><span style="color: #990000">)]]</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span> <span style="color: #990000">(</span><span style="color: #009900">int</span> i<span style="color: #990000">=</span><span style="color: #993399">0</span><span style="color: #990000">;</span> i<span style="color: #990000">&lt;</span>N<span style="color: #990000">;</span> i<span style="color: #990000">++)</span> <span style="color: #FF0000">{</span>
C<span style="color: #990000">[</span>i<span style="color: #990000">+</span>offset<span style="color: #990000">]</span> <span style="color: #990000">=</span> A<span style="color: #990000">[</span>i<span style="color: #990000">+</span>offset<span style="color: #990000">]</span> <span style="color: #990000">*</span> B<span style="color: #990000">[</span>i<span style="color: #990000">+</span>offset<span style="color: #990000">];</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The above example is an invalid usage of the attribute qualifier as <span class="monospaced">len</span> is negative.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="extending-attribute-qualifiers">2.8.6. Extending Attribute Qualifiers</h4>
<div class="paragraph"><p>The attribute syntax can be extended for standard language extensions and vendor specific extensions.
Any extensions should follow the naming conventions outlined in the introduction to <em>section 9</em> in the OpenCL 2.2 Extension Specification.</p></div>
<div class="paragraph"><p>Attributes are intended as useful hints to the compiler.
It is our intention that a particular implementation of OpenCL be free to ignore all attributes and the resulting executable binary will produce the same result.
This does not preclude an implementation from making use of the additional information provided by attributes and performing optimizations or other transformations as it sees fit.
In this case it is the programmer&#8217;s responsibility to guarantee that the information provided is in some sense correct.</p></div>
</div>
</div>
<div class="sect2">
<h3 id="opencl_cxx_restrictions">2.9. Restrictions</h3>
<div class="paragraph"><p>The following C++14 features are not supported by OpenCL C++:</p></div>
<div class="ulist"><ul>
<li>
<p>
the <span class="monospaced">dynamic_cast</span> operator (<em>ISO C++ Section 5.2.7</em>)
</p>
</li>
<li>
<p>
type identification (<em>ISO C++ Section 5.2.8</em>)
</p>
</li>
<li>
<p>
recursive function calls (<em>ISO C++ Section 5.2.2, item 9</em>) unless they are a compile-time constant expression
</p>
</li>
<li>
<p>
non-placement <span class="monospaced">new</span> and <span class="monospaced">delete</span> operators (<em>ISO C++ Sections 5.3.4 and 5.3.5</em>)
</p>
</li>
<li>
<p>
<span class="monospaced">goto</span> statement (<em>ISO C++ Section 6.6</em>)
</p>
</li>
<li>
<p>
<span class="monospaced">register</span> and <span class="monospaced">thread_local</span> storage qualifiers (<em>ISO C++ Section 7.1.1</em>)
</p>
</li>
<li>
<p>
virtual function qualifier (<em>ISO C++ Section 7.1.2</em>)
</p>
</li>
<li>
<p>
function pointers (<em>ISO C++ Sections 8.3.5 and 8.5.3</em>) unless they are a compile-time constant expression
</p>
</li>
<li>
<p>
virtual functions and abstract classes (<em>ISO C++ Sections 10.3 and 10.4</em>)
</p>
</li>
<li>
<p>
exception handling (<em>ISO C++ Section 15</em>)
</p>
</li>
<li>
<p>
the C++ standard library (<em>ISO C++ Sections 17 &#8230; 30</em>)
</p>
</li>
<li>
<p>
<span class="monospaced">asm</span> declaration (<em>ISO C++ Section 7.4</em>)
</p>
</li>
<li>
<p>
no implicit lambda to function pointer conversion (<em>ISO C++ Section 5.1.2, item 6</em>)
</p>
</li>
<li>
<p>
variadic functions (<em>ISO C99 Section 7.15, Variable arguments &lt;stdarg.h&gt;</em>)
</p>
</li>
<li>
<p>
and, like C++, OpenCL C++ does not support variable length arrays (<em>ISO C99, Section 6.7.5</em>).
</p>
</li>
</ul></div>
<div class="paragraph"><p>To avoid potential confusion with the above, please note the following features <em>are</em> supported in OpenCL C++:</p></div>
<div class="ulist"><ul>
<li>
<p>
All variadic templates (<em>ISO C++ Section 14.5.3</em>) including variadic function templates are supported.
</p>
</li>
</ul></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">This page refers to <em>ISO C99</em> instead of <em>ISO C11</em> since the <em>ISO C++14</em> document refers to <em>ISO C99</em> in <em>ISO C++ Section 1.2 and Annex C</em>.</td>
</tr></table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="opencl-c-standard-library">3. OpenCL C++ Standard Library</h2>
<div class="sectionbody">
<div class="paragraph"><p>OpenCL C++ does not support the C++14 standard library, but instead implements its own standard library.
No OpenCL types and functions are auto-included.</p></div>
<div class="sect2">
<h3 id="opencl-definitions">3.1. OpenCL Definitions</h3>
<div class="paragraph"><p>Header <em>&lt;opencl_def&gt;</em> defines OpenCL scalar, vector types and macros.
<span class="monospaced">cl_</span>* types are guaranteed to have exactly the same size as their host counterparts defined in <em>cl_platform.h</em> file.</p></div>
<div class="sect3">
<h4 id="header-opencl_def-synopsis">3.1.1. Header &lt;opencl_def&gt; Synopsis</h4>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#define</span></span> __OPENCL_CPP_VERSION__ <span style="color: #993399">100</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__SIZE_TYPE__</span> size_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__PTRDIFF_TYPE__</span> ptrdiff_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>nullptr<span style="color: #990000">)</span> nullptr_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> NULL nullptr
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__INT8_TYPE__</span> int8_t <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__UINT8_TYPE__</span> uint8_t <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__INT16_TYPE__</span> int16_t <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">2</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__UINT16_TYPE__</span> uint16_t <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">2</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__INT32_TYPE__</span> int32_t <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">4</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__UINT32_TYPE__</span> uint32_t <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">4</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__INT64_TYPE__</span> int64_t <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">8</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">__UINT64_TYPE__</span> uint64_t <span style="color: #990000">[[</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">8</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> __INTPTR_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int32_t</span> intptr_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint32_t</span> uintptr_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#elif</span></span> __INTPTR_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int64_t</span> intptr_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint64_t</span> uintptr_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="color: #990000">::</span>intptr_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="color: #990000">::</span>uintptr_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="color: #990000">::</span>ptrdiff_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="color: #990000">::</span>nullptr_t<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="color: #990000">::</span>size_t<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int8_t</span> cl_char<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint8_t</span> cl_uchar<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int16_t</span> cl_short
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint16_t</span> cl_ushort<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int32_t</span> cl_int<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint32_t</span> cl_uint<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int64_t</span> cl_long<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint64_t</span> cl_ulong<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">half</span> cl_half <span style="color: #990000">[[</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">2</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #009900">float</span> cl_float <span style="color: #990000">[[</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">4</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp64
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #009900">double</span> cl_double <span style="color: #990000">[[</span><span style="font-weight: bold"><span style="color: #000000">aligned</span></span><span style="color: #990000">(</span><span style="color: #993399">8</span><span style="color: #990000">)]];</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> bool2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> bool3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> bool4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> bool8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> bool16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> char2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> char3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> char4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> char8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> char16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uchar2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uchar3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uchar4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uchar8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uchar16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> short2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> short3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> short4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> short8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> short16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ushort2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ushort3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ushort4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ushort8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ushort16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> int2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> int3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> int4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> int8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> int16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uint2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uint3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uint4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uint8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> uint16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> long2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> long3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> long4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> long8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> long16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ulong2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ulong3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ulong4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ulong8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> ulong16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> float2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> float3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> float4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> float8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> float16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> half2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> half3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> half4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> half8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> half16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp64
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> double2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> double3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> double4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> double8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> implementation<span style="color: #990000">-</span><span style="color: #008080">defined</span> double16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">bool2</span> cl_bool2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">bool3</span> cl_bool3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">bool4</span> cl_bool4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">bool8</span> cl_bool8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">bool16</span> cl_bool16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">char2</span> cl_char2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">char3</span> cl_char3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">char4</span> cl_char4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">char8</span> cl_char8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">char16</span> cl_char16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uchar2</span> cl_uchar2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uchar3</span> cl_uchar3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uchar4</span> cl_uchar4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uchar8</span> cl_uchar8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uchar16</span> cl_uchar16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">short2</span> cl_short2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">short3</span> cl_short3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">short4</span> cl_short4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">short8</span> cl_short8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">short16</span> cl_short16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ushort2</span> cl_ushort2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ushort3</span> cl_ushort3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ushort4</span> cl_ushort4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ushort8</span> cl_ushort8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ushort16</span> cl_ushort16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int2</span> cl_int2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int3</span> cl_int3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int4</span> cl_int4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int8</span> cl_int8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">int16</span> cl_int16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint2</span> cl_uint2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint3</span> cl_uint3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint4</span> cl_uint4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint8</span> cl_uint8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">uint16</span> cl_uint16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">long2</span> cl_long2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">long3</span> cl_long3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">long4</span> cl_long4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">long8</span> cl_long8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">long16</span> cl_long16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ulong2</span> cl_ulong2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ulong3</span> cl_ulong3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ulong4</span> cl_ulong4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ulong8</span> cl_ulong8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ulong16</span> cl_ulong16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">float2</span> cl_float2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">float3</span> cl_float3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">float4</span> cl_float4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">float8</span> cl_float8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">float16</span> cl_float16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">half2</span> cl_half2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">half3</span> cl_half3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">half4</span> cl_half4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">half8</span> cl_half8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">half16</span> cl_half16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp64
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">double2</span> cl_double2<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">double3</span> cl_double3<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">double4</span> cl_double4<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">double8</span> cl_double8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">double16</span> cl_double16<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span></tt></pre></div></div>
</div>
</div>
<div class="sect2">
<h3 id="conversions-library">3.2. Conversions Library</h3>
<div class="paragraph"><p>This section describes the explicit conversion cast functions.
These functions provide a full set of type conversions between supported scalar and vector data types (see <em><a href="#builtin-scalar-data-types">Built-in Scalar Data Types</a></em> and <em><a href="#builtin-vector-data-types">Built-in Vector Data Types</a> sections</em>) except for the following types: <span class="monospaced">size_t</span>, <span class="monospaced">ptrdiff_t</span>, <span class="monospaced">intptr_t</span>, <span class="monospaced">uintptr_t</span>, and <span class="monospaced">void</span>.</p></div>
<div class="paragraph"><p>The behavior of the conversion may be modified by one or two optional modifiers that specify saturation for out-of-range inputs and rounding behavior.</p></div>
<div class="paragraph"><p>The <span class="monospaced">convert_cast</span> type conversion operator that specifies a rounding mode and saturation is also provided.</p></div>
<div class="sect3">
<h4 id="header-opencl_convert-synopsis">3.2.1. Header &lt;opencl_convert&gt; Synopsis</h4>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">enum</span></span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">rounding_mode</span> <span style="color: #FF0000">{</span> rte<span style="color: #990000">,</span> rtz<span style="color: #990000">,</span> rtp<span style="color: #990000">,</span> rtn <span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">enum</span></span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">saturate</span> <span style="color: #FF0000">{</span> off<span style="color: #990000">,</span> on <span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">convert_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">U</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">convert_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="color: #008080">rounding_mode</span> rmode<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">convert_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">U</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="color: #008080">rounding_mode</span> rmode<span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">convert_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="color: #008080">saturate</span> smode<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">convert_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">U</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="color: #008080">saturate</span> smode<span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">convert_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="color: #008080">rounding_mode</span> rmode<span style="color: #990000">,</span> <span style="color: #008080">saturate</span> smode<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">convert_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">U</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="color: #008080">rounding_mode</span> rmode<span style="color: #990000">,</span> <span style="color: #008080">saturate</span> smode<span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">convert_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="data-types">3.2.2. Data Types</h4>
<div class="paragraph"><p>Conversions are available for the following scalar types: <span class="monospaced">bool</span>, <span class="monospaced">char</span>, <span class="monospaced">uchar</span>, <span class="monospaced">short</span>, <span class="monospaced">ushort</span>, <span class="monospaced">int</span>, <span class="monospaced">uint</span>, <span class="monospaced">long</span>, <span class="monospaced">ulong</span>, <span class="monospaced">half</span> <a href="#ftn4">[4</a>], <span class="monospaced">float</span>, <span class="monospaced">double</span>, and built-in vector types derived therefrom.
The operand and result type must have the same number of elements.
The operand and result type may be the same type in which case the conversion has no effect on the type or value of an expression.</p></div>
<div class="paragraph"><p>Conversions between integer types follow the conversion rules specified in the C++14 specification except for out-of-range behavior and saturated conversions which are described in <em><a href="#out-of-range-behavior-and-saturated-conversions">Out-of-Range Behavior and Saturated Conversions</a> section</em> below.</p></div>
</div>
<div class="sect3">
<h4 id="rounding-modes">3.2.3. Rounding Modes</h4>
<div class="paragraph"><p>Conversions to and from floating-point type shall conform to IEEE-754 rounding rules.
Conversions may have an optional rounding mode specified as described in the table belows.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 9. Rounding Modes</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><div class="paragraph"><p><strong>Rounding Mode</strong></p></div></th>
<th class="tableblock halign-left valign-top" ><div class="paragraph"><p><strong>Description</strong></p></div></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">rte</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>Round to nearest even</p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">rtz</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>Round toward zero</p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">rtp</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>Round toward positive infinity</p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">rtn</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>Round toward negative infinity</p></div></div></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>If a rounding mode is not specified, conversions to integer type use the <span class="monospaced">rtz</span> (round toward zero) rounding mode and conversions to floating-point type <a href="#ftn5">[5</a>] uses the <span class="monospaced">rte</span> rounding mode.</p></div>
</div>
<div class="sect3">
<h4 id="out-of-range-behavior-and-saturated-conversions">3.2.4. Out-of-Range Behavior and Saturated Conversions</h4>
<div class="paragraph"><p>When the conversion operand is either greater than the greatest representable destination value or less than the least representable destination value, it is said to be out-of-range.
The result of out-of-range conversion is determined by the conversion rules specified by the C++14 specification in <em>chapter 4.9</em>.
When converting from a floating-point type to integer type, the behavior is implementation-defined.</p></div>
<div class="paragraph"><p>Conversions to integer type may opt to convert using the optional saturation mode.
When in saturated mode, values that are outside the representable range shall clamp to the nearest representable value in the destination format.
(NaN should be converted to 0).</p></div>
<div class="paragraph"><p>Conversions to floating-point type shall conform to IEEE-754 rounding rules. The <span class="monospaced">convert_cast</span> operator with a saturate argument may not be used for conversions to floating-point formats.</p></div>
</div>
<div class="sect3">
<h4 id="examples-1">3.2.5. Examples</h4>
<div class="sect4">
<h5 id="example-1-1">Example 1</h5>
<div class="paragraph"><p>Examples of casting between two vector types with saturation.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_convert&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl<span style="color: #990000">;</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">Foo</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">short4</span> s<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// negative values clamped to 0</span></span>
<span style="color: #008080">ushort4</span> u <span style="color: #990000">=</span> convert_cast<span style="color: #990000">&lt;</span>ushort4<span style="color: #990000">,</span>saturate<span style="color: #990000">::</span>on<span style="color: #990000">&gt;(</span>s<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// values &gt; CHAR_MAX converted to CHAR_MAX</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// values &lt; CHAR_MIN converted to CHAR_MIN</span></span>
<span style="color: #008080">char4</span> c <span style="color: #990000">=</span> convert_cast<span style="color: #990000">&lt;</span>char4<span style="color: #990000">,</span> saturate<span style="color: #990000">::</span>on<span style="color: #990000">&gt;(</span>s<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-2-1">Example 2</h5>
<div class="paragraph"><p>Examples of casting from float to integer vector type with saturation and rounding mode specified.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_convert&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl<span style="color: #990000">;</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">Foo</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">float4</span> f<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// values implementation defined for</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// f &gt; INT_MAX, f &lt; INT_MIN or NaN</span></span>
<span style="color: #008080">int4</span> i1 <span style="color: #990000">=</span> convert_cast<span style="color: #990000">&lt;</span>int4<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// values &gt; INT_MAX clamp to INT_MAX, values &lt; INT_MIN clamp</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// to INT_MIN. NaN should produce 0.</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// The rtz rounding mode is used to produce the integer</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// values.</span></span>
<span style="color: #008080">int4</span> i2 <span style="color: #990000">=</span> convert_cast<span style="color: #990000">&lt;</span>int4<span style="color: #990000">,</span>saturate<span style="color: #990000">::</span>on<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// similar to convert_cast&lt;int4&gt;, except that floating-point</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// values are rounded to the nearest integer instead of</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// truncated</span></span>
<span style="color: #008080">int4</span> i3 <span style="color: #990000">=</span> convert_cast<span style="color: #990000">&lt;</span>int4<span style="color: #990000">,</span> rounding_mode<span style="color: #990000">::</span>rte<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// similar to convert_cast&lt;int4, saturate::on&gt;, except that</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// floating-point values are rounded to the nearest integer</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// instead of truncated</span></span>
<span style="color: #008080">int4</span> i4 <span style="color: #990000">=</span> convert_cast<span style="color: #990000">&lt;</span>int4<span style="color: #990000">,</span> rounding_mode<span style="color: #990000">::</span>rte<span style="color: #990000">,</span>
saturate<span style="color: #990000">::</span>on<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-3">Example 3</h5>
<div class="paragraph"><p>Examples of casting from integer to float vector type.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_convert&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl<span style="color: #990000">;</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">Foo</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">int4</span> i<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// convert ints to floats using the default rounding mode.</span></span>
<span style="color: #008080">float4</span> f1 <span style="color: #990000">=</span> convert_cast<span style="color: #990000">&lt;</span>float4<span style="color: #990000">&gt;(</span>i<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// convert ints to floats. integer values that cannot</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// be exactly represented as floats should round up to the</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// next representable float.</span></span>
<span style="color: #008080">float4</span> f2 <span style="color: #990000">=</span> convert_cast<span style="color: #990000">&lt;</span>float4<span style="color: #990000">,</span> rounding_mode<span style="color: #990000">::</span>rtp<span style="color: #990000">&gt;(</span>i<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="reinterpreting-data-library">3.3. Reinterpreting Data Library</h3>
<div class="paragraph"><p>It is frequently necessary to reinterpret bits in a data type as another data type in OpenCL C++.
This is typically required when direct access to the bits in a floating-point type is needed, for example to mask off the sign bit or make use of the result of a vector relational operator on floating-point data.</p></div>
<div class="sect3">
<h4 id="header-opencl_reinterpret-synopsis">3.3.1. Header &lt;opencl_reinterpret&gt; Synopsis</h4>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">as_type</span></span><span style="color: #990000">(</span><span style="color: #008080">U</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> arg<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="reinterpreting-types">3.3.2. Reinterpreting Types</h4>
<div class="paragraph"><p>All data types described in <a href="#device_builtin_scalar_data_types">Device built-in scalar data types</a> and <a href="#device_builtin_vector_data_types">Device built-in vector data types</a> tables (except <span class="monospaced">bool</span> and <span class="monospaced">void</span>) may be also reinterpreted as another data type of the same size using the <span class="monospaced">as_type()</span> <a href="#ftn6">[6</a>] function for scalar and vector data types.
When the operand and result type contain the same number of elements, the bits in the operand shall be returned directly without modification as the new type.
The usual type promotion for function arguments shall not be performed.</p></div>
<div class="paragraph"><p>For example, <span class="monospaced">as_type&lt;float&gt;(0x3f800000)</span> returns <span class="monospaced">1.0f</span>, which is the value that the bit pattern <span class="monospaced">0x3f800000</span> has if viewed as an IEEE-754 single precision value.</p></div>
<div class="paragraph"><p>When the operand and result type contain a different number of elements, the result shall be implementation-defined except if the operand is a 4-component vector and the result is a 3-component vector.
In this case, the bits in the operand shall be returned directly without modification as the new type.
That is, a conforming implementation shall explicitly define a behavior, but two conforming implementations need not have the same behavior when the number of elements in the result and operand types does not match.
The implementation may define the result to contain all, some or none of the original bits in whatever order it chooses.
It is an error to use the <span class="monospaced">as_type&lt;T&gt;</span> operator to reinterpret data to a type of a different number of bytes.</p></div>
</div>
<div class="sect3">
<h4 id="examples-2">3.3.3. Examples</h4>
<div class="sect4">
<h5 id="example-1-2">Example 1</h5>
<div class="paragraph"><p>Examples of reinterpreting data types using <span class="monospaced">as_type&lt;&gt;</span> function.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_reinterpret&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl<span style="color: #990000">;</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">Foo</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">float</span> f <span style="color: #990000">=</span> <span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">;</span>
<span style="color: #008080">uint</span> u <span style="color: #990000">=</span> as_type<span style="color: #990000">&lt;</span>uint<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// Legal. Contains: 0x3f800000</span></span>
<span style="color: #008080">float4</span> f <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">float4</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">3</span><span style="color: #990000">.</span>0f<span style="color: #990000">,</span> <span style="color: #993399">4</span><span style="color: #990000">.</span>0f<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// Legal. Contains:</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// int4(0x3f800000, 0x40000000, 0x40400000, 0x40800000)</span></span>
<span style="color: #008080">int4</span> i <span style="color: #990000">=</span> as_type<span style="color: #990000">&lt;</span>int4<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span>
<span style="color: #009900">int</span> i<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// Legal. Result is implementation-defined.</span></span>
<span style="color: #008080">short2</span> j <span style="color: #990000">=</span> as_type<span style="color: #990000">&lt;</span>short2<span style="color: #990000">&gt;(</span>i<span style="color: #990000">);</span>
<span style="color: #008080">int4</span> i<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// Legal. Result is implementation-defined.</span></span>
<span style="color: #008080">short8</span> j <span style="color: #990000">=</span> as_type<span style="color: #990000">&lt;</span>short8<span style="color: #990000">&gt;(</span>i<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> f<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// Error. Result and operand have different sizes</span></span>
<span style="color: #008080">double4</span> g <span style="color: #990000">=</span> as_type<span style="color: #990000">&lt;</span>double4<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> f<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// Legal. g.xyz will have same values as f.xyz. g.w is</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// undefined</span></span>
<span style="color: #008080">float3</span> g <span style="color: #990000">=</span> as_type<span style="color: #990000">&lt;</span>float3<span style="color: #990000">&gt;(</span>f<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="address-spaces-library">3.4. Address Spaces Library</h3>
<div class="paragraph"><p>Unlike OpenCL C, OpenCL C++ does not require the address space qualifiers to allocate storage from global, local and constant memory pool.
The same functionality is provided using the storage and pointer classes.
These new types are designed to avoid many programming issues and it is recommended to use them for the static and program scope variables even if it is not required.</p></div>
<div class="sect3">
<h4 id="header-opencl_memory-synopsis">3.4.1. Header &lt;opencl_memory&gt; Synopsis</h4>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">enum</span></span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">mem_fence</span>
<span style="color: #FF0000">{</span>
local<span style="color: #990000">,</span>
global<span style="color: #990000">,</span>
image
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">inline</span></span> <span style="color: #008080">mem_fence</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">~(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">inline</span></span> <span style="color: #008080">mem_fence</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">&amp;(</span><span style="color: #008080">mem_fence</span> LHS<span style="color: #990000">,</span> <span style="color: #008080">mem_fence</span> RHS<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">inline</span></span> <span style="color: #008080">mem_fence</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">|(</span><span style="color: #008080">mem_fence</span> LHS<span style="color: #990000">,</span> <span style="color: #008080">mem_fence</span> RHS<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">inline</span></span> <span style="color: #008080">mem_fence</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">^(</span><span style="color: #008080">mem_fence</span> LHS<span style="color: #990000">,</span> <span style="color: #008080">mem_fence</span> RHS<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// address space pointer classes</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">global_ptr</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">local_ptr</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">private_ptr</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">constant_ptr</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> global <span style="color: #990000">=</span> see <span style="color: #FF0000">'global class'</span> section<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> local <span style="color: #990000">=</span> see <span style="color: #FF0000">'local class'</span> section<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> priv <span style="color: #990000">=</span> see <span style="color: #FF0000">'priv class'</span> section<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> constant <span style="color: #990000">=</span> see <span style="color: #FF0000">'constant class'</span> section<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// address space query functions</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">mem_fence</span> <span style="font-weight: bold"><span style="color: #000000">get_mem_fence</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> <span style="color: #990000">*</span>ptr<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// address space cast functions</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">dynamic_asptr_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> <span style="color: #990000">*</span>ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">local_ptr&lt;T&gt; static_asptr_cast(local_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">global_ptr&lt;T&gt; static_asptr_cast(global_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">constant_ptr&lt;T&gt; static_asptr_cast(constant_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">private_ptr&lt;T&gt; static_asptr_cast(private_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">local_ptr&lt;T&gt; reinterpret_asptr_cast(local_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">global_ptr&lt;T&gt; reinterpret_asptr_cast(global_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">constant_ptr&lt;T&gt; reinterpret_asptr_cast(constant_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">private_ptr&lt;T&gt; reinterpret_asptr_cast(private_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">addressof</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;</span> t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="explicit-address-space-storage-classes">3.4.2. Explicit address space storage classes</h4>
<div class="paragraph"><p>The explicit address space storage classes described in this section are designed to allocate memory in one of the named address spaces: global, local, constant or private.</p></div>
<div class="sect4">
<h5 id="global-class">global class</h5>
<div class="paragraph"><p>The variables declared using <span class="monospaced">global&lt;T&gt;</span> class refer to memory objects allocated from the global memory pool (<em><a href="#global">Global Memory Pool</a> section</em>).
The global storage class can only be used to declare variables at program, function and class scope.
The variables at function and class scope must be declared with <span class="monospaced">static</span> specifier.</p></div>
<div class="paragraph"><p>If <span class="monospaced">T</span> is a fundamental or an array type, the <span class="monospaced">global</span> class should meet the following requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
no user provide default constructor
</p>
</li>
<li>
<p>
default copy and move constructors
</p>
</li>
<li>
<p>
default copy and move assignment operators
</p>
</li>
<li>
<p>
address-of operators that return a generic <span class="monospaced">T</span> pointer (<span class="monospaced">T*</span>)
</p>
</li>
<li>
<p>
conversion operators to a generic <span class="monospaced">T</span> lvalue reference type (<span class="monospaced">T&amp;</span>)
</p>
</li>
<li>
<p>
assignment <span class="monospaced">const T&amp;</span> operator
</p>
</li>
<li>
<p>
<span class="monospaced">ptr()</span> methods that return a <span class="monospaced">global_ptr&lt;T&gt;</span> pointer class
</p>
</li>
</ul></div>
<div class="paragraph"><p>If <span class="monospaced">T</span> is a class type, the <span class="monospaced">global</span> class should provide the following interface:</p></div>
<div class="ulist"><ul>
<li>
<p>
the same public interface as <span class="monospaced">T</span> type including constructors and assignment operators address-of operators that return a generic <span class="monospaced">T</span> pointer (<span class="monospaced">T*</span>)
</p>
</li>
<li>
<p>
conversion operators to a generic <span class="monospaced">T</span> lvalue reference type (<span class="monospaced">T&amp;</span>)
</p>
</li>
<li>
<p>
<span class="monospaced">ptr()</span> methods that return a <span class="monospaced">global_ptr&lt;T&gt;</span> pointer class
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="local-class">local class</h5>
<div class="paragraph"><p>The variables declared using <span class="monospaced">local&lt;T&gt;</span> class refer to memory objects allocated from the local memory pool (<em><a href="#local">Local Memory Pool</a> section</em>).
The local storage class can only be used to declare variables at program, kernel and class scope.
The variables at class scope must be declared with <span class="monospaced">static</span> specifier.</p></div>
<div class="paragraph"><p>If <span class="monospaced">T</span> is a fundamental or an array type, the <span class="monospaced">local</span> class should meet the following requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
no user provide default constructor
</p>
</li>
<li>
<p>
default copy and move constructors
</p>
</li>
<li>
<p>
default copy and move assignment operators
</p>
</li>
<li>
<p>
address-of operators that return a generic <span class="monospaced">T</span> pointer (<span class="monospaced">T*</span>)
</p>
</li>
<li>
<p>
conversion operators to a generic <span class="monospaced">T</span> lvalue reference type (<span class="monospaced">T&amp;</span>)
</p>
</li>
<li>
<p>
assignment <span class="monospaced">const T&amp;</span> operator
</p>
</li>
<li>
<p>
<span class="monospaced">ptr()</span> methods that return a <span class="monospaced">local_ptr&lt;T&gt;</span> pointer class
</p>
</li>
</ul></div>
<div class="paragraph"><p>If <span class="monospaced">T</span> is a class type, the <span class="monospaced">local</span> class should provide the following interface:</p></div>
<div class="ulist"><ul>
<li>
<p>
the same public interface as <span class="monospaced">T</span> type including constructors
and assignment operators
</p>
</li>
<li>
<p>
address-of operators that return a generic <span class="monospaced">T</span> pointer (<span class="monospaced">T*</span>)
</p>
</li>
<li>
<p>
conversion operators to a generic <span class="monospaced">T</span> lvalue reference type (<span class="monospaced">T&amp;</span>)
</p>
</li>
<li>
<p>
<span class="monospaced">ptr()</span> methods that return a <span class="monospaced">local_ptr&lt;T&gt;</span> pointer class
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="priv-class">priv class</h5>
<div class="paragraph"><p>The variables declared using the <span class="monospaced">priv&lt;T&gt;</span> class refer to memory objects allocated from the private memory pool.</p></div>
<div class="paragraph"><p>The <span class="monospaced">priv</span> storage class cannot be used to declare variables in the program scope, with <span class="monospaced">static</span> specifier or <span class="monospaced">extern</span> specifier.</p></div>
<div class="paragraph"><p>If <span class="monospaced">T</span> is a fundamental or an array type, the <span class="monospaced">priv</span> class should meet the following requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
no user provide default constructor
</p>
</li>
<li>
<p>
default copy and move constructors
</p>
</li>
<li>
<p>
default copy and move assignment operators
</p>
</li>
<li>
<p>
address-of operators that return a generic <span class="monospaced">T</span> pointer (<span class="monospaced">T*</span>)
</p>
</li>
<li>
<p>
conversion operators to a generic <span class="monospaced">T</span> lvalue reference type (<span class="monospaced">T&amp;</span>)
</p>
</li>
<li>
<p>
assignment const <span class="monospaced">T&amp;</span> operator
</p>
</li>
<li>
<p>
<span class="monospaced">ptr()</span> methods that return a <span class="monospaced">private_ptr&lt;T&gt;</span> pointer class
</p>
</li>
</ul></div>
<div class="paragraph"><p>If <span class="monospaced">T</span> is a class type, the <span class="monospaced">priv</span> class should provide the following interface:</p></div>
<div class="ulist"><ul>
<li>
<p>
the same public interface as <span class="monospaced">T</span> type including constructors and assignment operators
</p>
</li>
<li>
<p>
address-of operators that return a generic <span class="monospaced">T</span> pointer (<span class="monospaced">T*</span>)
</p>
</li>
<li>
<p>
conversion operators to a generic <span class="monospaced">T</span> lvalue reference type (<span class="monospaced">T&amp;</span>)
</p>
</li>
<li>
<p>
<span class="monospaced">ptr()</span> methods that return a <span class="monospaced">private_ptr&lt;T&gt;</span> pointer class
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="constant-class">constant class</h5>
<div class="paragraph"><p>The variables declared using the <span class="monospaced">constant&lt;T&gt;</span> class refer to memory objects allocated from the global memory pool and which are accessed inside a kernel(s) as read-only variables.
The constant storage class can only be used to declare variables at program, kernel and class scope.
The variables at class scope must be declared with <span class="monospaced">static</span> specifier.</p></div>
<div class="paragraph"><p>The <span class="monospaced">T</span> type must meet the following requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">T</span> must be constructible at compile time
</p>
</li>
<li>
<p>
<span class="monospaced">T</span> cannot have any user defined constructors, destructors, methods and operators
</p>
</li>
</ul></div>
<div class="paragraph"><p>If <span class="monospaced">T</span> is a fundamental, array or class type, the <span class="monospaced">constant</span> class should meet the following requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
no user provide default constructor
</p>
</li>
<li>
<p>
default copy and move constructors
</p>
</li>
<li>
<p>
copy and move assignment operators deleted
</p>
</li>
<li>
<p>
address-of operators that return a <span class="monospaced">constant_ptr&lt;T&gt;</span> pointer class
</p>
</li>
<li>
<p>
<span class="monospaced">ptr()</span> methods that return a <span class="monospaced">constant_ptr&lt;T&gt;</span> pointer class
</p>
</li>
<li>
<p>
conversion operators to a constant <span class="monospaced">T</span> lvalue reference type (<span class="monospaced">add_constant_t&lt;T&gt;&amp;</span>)
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect3">
<h4 id="explicit-address-space-pointer-classes">3.4.3. Explicit address space pointer classes</h4>
<div class="paragraph"><p>The explicit address space pointer classes are just like pointers: they can be converted to and from pointers with compatible address spaces, qualifiers and types.
Assignment or casting between explicit pointer types of incompatible address spaces is illegal.</p></div>
<div class="paragraph"><p>All named address spaces are incompatible with all other address spaces, but local, global and private pointers can be converted to standard C++ pointers.</p></div>
<div class="sect4">
<h5 id="global_ptr-class">global_ptr class</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">global_ptr</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">public</span></span><span style="color: #990000">:</span>
<span style="font-style: italic"><span style="color: #9A1900">//types:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">T</span> element_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ptrdiff_t</span> difference_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_global_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_global_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> const_reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_global_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_global_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//constructors:</span></span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//assignment:</span></span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//observers:</span></span>
<span style="color: #008080">add_lvalue_reference_t&lt;add_global_t&lt;T&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-&gt;()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//modifiers:</span></span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">pointer</span></span><span style="color: #990000">())</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>global_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">global_ptr</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">[]&gt;</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">public</span></span><span style="color: #990000">:</span>
<span style="font-style: italic"><span style="color: #9A1900">//types:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">T</span> element_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ptrdiff_t</span> difference_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_global_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_global_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> const_reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_global_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_global_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//constructors:</span></span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//assignment:</span></span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//observers:</span></span>
<span style="color: #008080">reference</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">size_t</span> pos<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//modifiers:</span></span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span>noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">nullptr_t</span> p <span style="color: #990000">=</span> nullptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>global_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>global_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">,</span> global_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="local_ptr-class">local_ptr class</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">local_ptr</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">public</span></span><span style="color: #990000">:</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">size_type</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">size_type</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> size<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="font-weight: bold"><span style="color: #000000">size_t</span></span><span style="color: #990000">();</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//types:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">T</span> element_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ptrdiff_t</span> difference_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_local_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_local_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> const_reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_local_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_local_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//constructors:</span></span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//assignment:</span></span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//observers:</span></span>
<span style="color: #008080">add_lvalue_reference_t&lt;add_local_t&lt;T&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-&gt;()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//modifiers:</span></span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">pointer</span></span><span style="color: #990000">())</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>local_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">local_ptr</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">[]&gt;</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">public</span></span><span style="color: #990000">:</span>
<span style="font-style: italic"><span style="color: #9A1900">//types:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">T</span> element_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ptrdiff_t</span> difference_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_local_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_local_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> const_reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_local_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_local_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//constructors:</span></span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//assignment:</span></span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//observers:</span></span>
<span style="color: #008080">reference</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">size_t</span> pos<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//modifiers:</span></span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span>noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">nullptr_t</span> p <span style="color: #990000">=</span> nullptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>local_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>local_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">,</span> local_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="private_ptr-class">private_ptr class</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">private_ptr</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">public</span></span><span style="color: #990000">:</span>
<span style="font-style: italic"><span style="color: #9A1900">//types:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">T</span> element_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ptrdiff_t</span> difference_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_private_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_private_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> const_reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_private_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_private_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//constructors:</span></span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//assignment:</span></span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//observers:</span></span>
<span style="color: #008080">add_lvalue_reference_t&lt;add_private_t&lt;T&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-&gt;()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//modifiers:</span></span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">pointer</span></span><span style="color: #990000">())</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>private_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">private_ptr</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">[]&gt;</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">public</span></span><span style="color: #990000">:</span>
<span style="font-style: italic"><span style="color: #9A1900">//types:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">T</span> element_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ptrdiff_t</span> difference_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_private_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_private_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> const_reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_private_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_private_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//constructors:</span></span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//assignment:</span></span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//observers:</span></span>
<span style="color: #008080">reference</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">size_t</span> pos<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//modifiers:</span></span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span>noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">nullptr_t</span> p <span style="color: #990000">=</span> nullptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>private_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>private_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">,</span> private_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="constant_ptr-class">constant_ptr class</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">constant_ptr</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">public</span></span><span style="color: #990000">:</span>
<span style="font-style: italic"><span style="color: #9A1900">//types:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">T</span> element_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ptrdiff_t</span> difference_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_constant_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_constant_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> const_reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_constant_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_constant_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//constructors:</span></span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//assignment:</span></span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//observers:</span></span>
<span style="color: #008080">add_lvalue_reference_t&lt;add_constant_t&lt;T&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-&gt;()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//modifiers:</span></span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">pointer</span></span><span style="color: #990000">())</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>constant_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">constant_ptr</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">[]&gt;</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">public</span></span><span style="color: #990000">:</span>
<span style="font-style: italic"><span style="color: #9A1900">//types:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">T</span> element_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">ptrdiff_t</span> difference_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_constant_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_constant_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> const_reference<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> add_constant_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> add_constant_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//constructors:</span></span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//assignment:</span></span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//observers:</span></span>
<span style="color: #008080">reference</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">size_t</span> pos<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//modifiers:</span></span>
<span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span>noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">nullptr_t</span> p <span style="color: #990000">=</span> nullptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>constant_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>constant_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">,</span> constant_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="constructors">Constructors</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Constructs an object which points to nothing.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Constructs an object which points to <span class="monospaced">p</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> global_ptr <span style="color: #990000">&amp;)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> local_ptr <span style="color: #990000">&amp;)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> private_ptr <span style="color: #990000">&amp;)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> constant_ptr <span style="color: #990000">&amp;)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Copy constructor.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span><span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Move constructor.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">global_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">local_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">private_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">constant_ptr</span></span><span style="color: #990000">(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Constructs an object initialized with <span class="monospaced">nullptr</span>.</p></div>
</div>
<div class="sect4">
<h5 id="assignment-operators">Assignment operators</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Copy assignment operator</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Move assignment operator</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">pointer</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Assigns <span class="monospaced">r</span> pointer to the stored pointer</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Assigns <span class="monospaced">nullptr</span> to the stored pointer</p></div>
</div>
<div class="sect4">
<h5 id="observers">Observers</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">add_lvalue_reference_t&lt;add_global_t&lt;T&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">add_lvalue_reference_t&lt;add_local_t&lt;T&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">add_lvalue_reference_t&lt;add_private_t&lt;T&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">add_lvalue_reference_t&lt;add_constant_t&lt;T&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">*get()</span>. It is only defined in single object version of the explicit address space pointer class.
The result of this operator is undefined if <span class="monospaced">get() == nullptr</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-&gt;()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">get()</span>. It is only defined in single object version of the explicit address space pointer class.
The result of this operator is undefined if <span class="monospaced">get() == nullptr</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">reference</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">size_t</span> pos<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">get()[pos]</span>. The subscript operator is only defined in specialized <span class="monospaced">global_ptr&lt;T[]&gt;</span>, <span class="monospaced">local_ptr&lt;T[]&gt;</span>, <span class="monospaced">private_ptr&lt;T[]&gt;</span> and <span class="monospaced">constant_ptr&lt;T[]&gt;</span> version for array types.
The result of this operator is undefined if <span class="monospaced">pos &gt;=</span> the number of elements in the array to which the stored pointer points.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the stored pointer.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">bool</span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">get() != nullptr</span>.</p></div>
</div>
<div class="sect4">
<h5 id="modifiers">Modifiers</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">pointer</span> <span style="font-weight: bold"><span style="color: #000000">release</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Assigns <span class="monospaced">nullptr</span> to the stored pointer and returns the value <span class="monospaced">get()</span> had at the start of the call to release.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">pointer</span></span><span style="color: #990000">())</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Assigned <span class="monospaced">p</span> to the stored pointer.
It is only defined in single object version of the explicit address space pointer class</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">pointer</span> p<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Assigned <span class="monospaced">p</span> to the stored pointer.
It is only defined in specialized <span class="monospaced">global_ptr&lt;T[]&gt;</span>, <span class="monospaced">local_ptr&lt;T[]&gt;</span>, <span class="monospaced">private_ptr&lt;T[]&gt;</span> and <span class="monospaced">constant_ptr&lt;T[]&gt;</span> version for array types.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">reset</span></span><span style="color: #990000">(</span><span style="color: #008080">nullptr_t</span> p <span style="color: #990000">=</span> nullptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Equivalent to <span class="monospaced">reset(pointer())</span>.
It is only defined in specialized <span class="monospaced">global_ptr&lt;T[]&gt;</span>, <span class="monospaced">local_ptr&lt;T[]&gt;</span>, <span class="monospaced">private_ptr&lt;T[]&gt;</span> and <span class="monospaced">constant_ptr&lt;T[]&gt;</span> version for array types.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>global_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>local_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>private_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>constant_ptr<span style="color: #990000">&amp;</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Invokes swap on the stored pointers.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Prefix increment operator.
Increments the stored pointer by one.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Postfix increment operator.
Increments the stored pointer by one.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Prefix decrement operator.
Decrements the stored pointer by one.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--(</span><span style="color: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Postfix decrement operator.
Decrements the stored pointer by one.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Adds <span class="monospaced">r</span> to the stored pointer and returns <span class="monospaced">*this</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Subtracts <span class="monospaced">r</span> to the stored pointer and returns <span class="monospaced">*this</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Adds <span class="monospaced">r</span> to the stored pointer and returns the value <span class="monospaced">*this</span> has at the start of <span class="monospaced">operator</span>+.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="color: #008080">global_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">local_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">private_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constant_ptr</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-(</span><span style="color: #008080">difference_type</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Subtracts <span class="monospaced">r</span> to the stored pointer and returns the value <span class="monospaced">*this</span> has at the start of <span class="monospaced">operator-</span>.</p></div>
</div>
<div class="sect4">
<h5 id="non-member-functions">Non-member functions</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator==</span> for the explicit address space pointer classes.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">==(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator==</span> for the explicit address space pointer classes with a <span class="monospaced">nullptr_t</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator!=</span> for the explicit address space pointer classes.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">!=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator!=</span> for the explicit address space pointer classes with a <span class="monospaced">nullptr_t</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator&lt;</span> for the explicit address space pointer classes.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator&lt;</span> for the explicit address space pointer classes with a <span class="monospaced">nullptr_t</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator&gt;</span> for the explicit address space pointer classes.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator&gt;</span> for the explicit address space pointer classes with a <span class="monospaced">nullptr_t</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator&lt;=</span> for the explicit address space pointer classes.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator&lt;=</span> for the explicit address space pointer classes with a <span class="monospaced">nullptr_t</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt; &amp;a, const global_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt; &amp;a, const local_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt; &amp;a, const private_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt; &amp;a, const constant_ptr&lt;U&gt;</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator&gt;=</span> for the explicit address space pointer classes.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">global_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">local_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">private_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span>nullptr_t<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;=(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">constant_ptr&lt;T&gt;</span> <span style="color: #990000">&amp;</span>x<span style="color: #990000">,</span> nullptr_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison <span class="monospaced">operator&gt;=</span> for the explicit address space pointer classes with a <span class="monospaced">nullptr_t</span>.</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>global_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">,</span> global_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>local_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">,</span> local_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>private_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">,</span> private_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>constant_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">,</span> constant_ptr<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;&amp;</span> b<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Calls <span class="monospaced">a.swap(b)</span></p></div>
</div>
</div>
<div class="sect3">
<h4 id="other-functions">3.4.4. Other functions</h4>
<div class="paragraph"><p>The OpenCL C++ address space library implements the address space query and cast functions.
The cast function that allows to explicitly convert from a pointer in the generic address space to a pointer in the global, local and private address space.</p></div>
<div class="sect4">
<h5 id="get_mem_fence">get_mem_fence</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">mem_fence</span> <span style="font-weight: bold"><span style="color: #000000">get_mem_fence</span></span> <span style="color: #990000">(</span><span style="color: #008080">T</span> <span style="color: #990000">*</span>ptr<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the <span class="monospaced">mem_fence</span> value for <span class="monospaced">ptr</span>.
<span class="monospaced">ptr</span> must be the generic pointer and it cannot be the explicit address space pointer (<span class="monospaced">global_ptr&lt;&gt;</span>, <span class="monospaced">local_ptr&lt;&gt;</span>, <span class="monospaced">private_ptr&lt;&gt;</span> and <span class="monospaced">constant_ptr&lt;&gt;</span>) or pointer to address space storage class (<span class="monospaced">global&lt;&gt;*</span>, <span class="monospaced">local&lt;&gt;*</span>, <span class="monospaced">priv&lt;&gt;*</span> and <span class="monospaced">constant&lt;&gt;*</span>).</p></div>
</div>
<div class="sect4">
<h5 id="dynamic_asptr_cast">dynamic_asptr_cast</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">dynamic_asptr_cast</span></span><span style="color: #990000">(</span><span style="color: #008080">U</span> <span style="color: #990000">*</span>ptr<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns a pointer that points to a region in the address space pointer class specified in <span class="monospaced">T</span> if <span class="monospaced">dynamic_asptr_cast</span> can cast <span class="monospaced">ptr</span> to the specified address space.
Otherwise it returns <span class="monospaced">nullptr</span>.
Only <span class="monospaced">global_ptr&lt;U&gt;</span>, <span class="monospaced">local_ptr&lt;U&gt;</span> and <span class="monospaced">private_ptr&lt;U&gt;</span> are valid <span class="monospaced">T</span> template arguments.
<span class="monospaced">ptr</span> must be the generic pointer and it cannot be the explicit address space pointer (<span class="monospaced">global_ptr&lt;&gt;</span>, <span class="monospaced">local_ptr&lt;&gt;</span>, <span class="monospaced">private_ptr&lt;&gt;</span> and <span class="monospaced">constant_ptr&lt;&gt;</span>) or pointer to address space storage class (<span class="monospaced">global&lt;&gt;*</span>, <span class="monospaced">local&lt;&gt;*</span>, <span class="monospaced">priv&lt;&gt;*</span> and <span class="monospaced">constant&lt;&gt;*</span>).</p></div>
</div>
<div class="sect4">
<h5 id="static_asptr_cast">static_asptr_cast</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">local_ptr&lt;T&gt; static_asptr_cast(local_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">global_ptr&lt;T&gt; static_asptr_cast(global_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">constant_ptr&lt;T&gt; static_asptr_cast(constant_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">private_ptr&lt;T&gt; static_asptr_cast(private_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>The expression <span class="monospaced">static_cast(r.get())</span> shall be well formed.</p></div>
</div>
<div class="sect4">
<h5 id="reinterpret_asptr_cast">reinterpret_asptr_cast</h5>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">local_ptr&lt;T&gt; reinterpret_asptr_cast(local_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">global_ptr&lt;T&gt; reinterpret_asptr_cast(global_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">constant_ptr&lt;T&gt; reinterpret_asptr_cast(constant_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">T</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">U</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">private_ptr&lt;T&gt; reinterpret_asptr_cast(private_ptr&lt;U&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">&amp;</span> ptr<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>The expression <span class="monospaced">reinterpret_cast(r.get())</span> shall be well formed.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="restrictions-2">3.4.5. Restrictions</h4>
<div class="paragraph"><p>1.
The objects allocated using <span class="monospaced">global</span>, <span class="monospaced">local</span> and <span class="monospaced">constant</span> storage classes can be passed to a function only by reference or pointer</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_memory&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_array&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl<span style="color: #990000">;</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">(</span><span style="color: #008080">global&lt;array&lt;int, 5&gt;&gt;</span> val<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// Error: variable in the global</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// address space passed by value</span></span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">bar</span></span><span style="color: #990000">(</span><span style="color: #008080">global&lt;array&lt;int, 5&gt;&gt;</span> <span style="color: #990000">&amp;</span>val<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">foobar</span></span><span style="color: #990000">(</span><span style="color: #008080">global_ptr&lt;int&gt;</span> val<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">barfoo</span></span><span style="color: #990000">(</span><span style="color: #008080">global_ptr&lt;int[]&gt;</span> val<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>2.
The <span class="monospaced">global</span>, <span class="monospaced">local</span>, <span class="monospaced">priv</span> and <span class="monospaced">constant</span> storage classes cannot be used as a return type of function</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_memory&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_array&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl<span style="color: #990000">;</span>
<span style="color: #008080">global&lt;array&lt;int, 5&gt;&gt;</span> programVar<span style="color: #990000">;</span>
<span style="color: #008080">global&lt;array&lt;int, 5&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">// error: variable in the global</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// address space returned by value</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">return</span></span> programVar<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span>
<span style="color: #008080">global&lt;array&lt;int, 5&gt;&gt;</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #000000">bar</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">return</span></span> programVar<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>3.
The <span class="monospaced">global</span>, <span class="monospaced">local</span> and <span class="monospaced">constant</span> storage classes cannot be used to declare class members unless <span class="monospaced">static</span> keyword is used</p></div>
<div class="listingblock">
<div class="content"><!-- Generator: GNU source-highlight 3.1.8
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_memory&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_array&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> <span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> cl<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">Foo</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">global&lt;int&gt;</span> a<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error: class members cannot be qualified</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// with address space</span></span>
<span style="color: #008080">local&lt;array&lt;int, 5&gt;&gt;</span> b<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error: class members cannot be</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// qualified with address space</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">global&lt;int&gt;</span> c<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">local&lt;array&lt;int, 5&gt;&gt;</span> d<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class=