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="paragraph"><p>4.
The <span class="monospaced">global</span> storage class cannot be used to declare variables at function scope 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: #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">global&lt;int&gt;</span> b<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">global&lt;int&gt;</span> b<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>5.
The <span class="monospaced">local</span> variables can be declared only at kernel function scope, program scope and with <span class="monospaced">static</span> keyword</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-style: italic"><span style="color: #9A1900">// An array of 5 ints allocated in</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// local address space.</span></span>
<span style="color: #008080">local&lt;array&lt;int, 5&gt;&gt;</span> a <span style="color: #990000">=</span> <span style="color: #FF0000">{</span> <span style="color: #993399">10</span> <span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK: program scope local</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// variable</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> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// A single int allocated in</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// local address space</span></span>
<span style="color: #008080">local&lt;int&gt;</span> b<span style="color: #FF0000">{</span><span style="color: #993399">1</span><span style="color: #FF0000">}</span><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;int&gt;</span> d<span style="color: #FF0000">{</span><span style="color: #993399">1</span><span style="color: #FF0000">}</span><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">if</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)</span> <span style="color: #990000">==</span> <span style="color: #993399">0</span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// example of variable in local address space</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// but not declared at __kernel function scope.</span></span>
<span style="color: #008080">local&lt;int&gt;</span> c<span style="color: #FF0000">{</span><span style="color: #993399">2</span><span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// not allowed</span></span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>6.
The objects allocated using <span class="monospaced">global</span> storage class must be initialized with the constant expression arguments</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_work_item&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">int</span> a <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">global&lt;int&gt;</span> b<span style="color: #FF0000">{</span>a<span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// undefined behavior</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: #FF0000">{</span><span style="color: #993399">0</span><span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>7.
The constructors of objects allocated using <span class="monospaced">constant</span> storage class must be constant expression</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_work_item&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">constant&lt;int&gt;</span> b<span style="color: #FF0000">{</span><span style="color: #993399">0</span><span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</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> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> a <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constant&lt;int&gt;</span> b<span style="color: #FF0000">{</span>a<span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// undefined behavior</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>8.
Constant variables must be initialized</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: #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">constant&lt;int&gt;</span> a<span style="color: #FF0000">{</span><span style="color: #993399">0</span><span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK</span></span>
<span style="color: #008080">constant&lt;int&gt;</span> b<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error: constant variable must be initialized</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> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constant&lt;int&gt;</span> c<span style="color: #FF0000">{</span><span style="color: #993399">0</span><span style="color: #FF0000">}</span><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">constant&lt;int&gt;</span> d<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error: constant variable must be initialized</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>9.
The <span class="monospaced">priv</span> storage class cannot be used to declare variables in the program scope or with <span class="monospaced">static</span> specifier.</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: #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">priv&lt;int&gt;</span> a<span style="color: #FF0000">{</span><span style="color: #993399">0</span><span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error: priv variable in program scope</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> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">priv&lt;int&gt;</span> c<span style="color: #FF0000">{</span><span style="color: #993399">0</span><span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error: priv variable with static specifier</span></span>
<span style="color: #008080">priv&lt;int&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></tt></pre></div></div>
<div class="paragraph"><p>10.
<span class="monospaced">T</span> type used in <span class="monospaced">constant</span> storage class cannot have any user defined constructors, destructors, operators and methods</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: #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">bar</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="color: #993399">10</span><span style="color: #990000">;</span> <span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span><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">constant&lt;bar&gt;</span> a<span style="color: #990000">;</span>
<span style="color: #009900">int</span> b <span style="color: #990000">=</span> a<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> <span style="font-style: italic"><span style="color: #9A1900">// undefined behavior</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>11.
<span class="monospaced">T</span> type used in <span class="monospaced">global</span>, <span class="monospaced">local</span>, <span class="monospaced">priv</span> and <span class="monospaced">constant</span> storage class cannot be sealed 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="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: #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">bar</span> final <span style="color: #FF0000">{</span> <span style="color: #FF0000">}</span><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">local&lt;bar&gt;</span> a<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error: bar is marked as final</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>12.
Using work-group barriers or relying on a specific work-item to be executed in constructors and destructors of global and local objects can result in undefined behavior</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_synchronization&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="font-weight: bold"><span style="color: #000000">Foo</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">work_group_barrier</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>local<span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">// not allowed</span></span>
<span style="color: #FF0000">}</span>
<span style="color: #990000">~</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-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)</span> <span style="color: #990000">!=</span> <span style="color: #993399">5</span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="font-style: italic"><span style="color: #9A1900">// not allowed</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">while</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">)</span> <span style="color: #FF0000">{}</span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</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: #FF0000">{</span>
<span style="color: #008080">local&lt;Foo&gt;</span> a<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>13.
All local (address-space) variable declarations in kernel-scope shall be declared before any explicit return statement.
Declaring local variable after return statement may cause undefined behavior.
Implementation is encouraged to generate at least a warning in such cases.</p></div>
</div>
<div class="sect3">
<h4 id="examples-3">3.4.6. Examples</h4>
<div class="sect4">
<h5 id="example-1-3">Example 1</h5>
<div class="paragraph"><p>Example of passing an explicit address space storage object to a kernel.</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: #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;int&gt;</span> <span style="color: #990000">*</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 class="sect4">
<h5 id="example-2-2">Example 2</h5>
<div class="paragraph"><p>Example of passing an explicit address space pointer object to a kernel.</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: #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_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 class="sect4">
<h5 id="example-3-1">Example 3</h5>
<div class="paragraph"><p>Example of casting a generic pointer to an explicit address space pointer object.
This is the runtime operation and the <span class="monospaced">dynamic_asptr_cast</span> can fail.</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: #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_ptr&lt;int&gt;</span> arg<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> <span style="color: #990000">*</span>ptr <span style="color: #990000">=</span> arg<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> globalPtr <span style="color: #990000">=</span> dynamic_asptr_cast<span style="color: #990000">&lt;</span>global_ptr<span style="color: #990000">&lt;</span><span style="color: #009900">int</span><span style="color: #990000">&gt;&gt;(</span>ptr<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>globalPtr<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>
<div class="sect4">
<h5 id="example-4">Example 4</h5>
<div class="paragraph"><p>Example of using an array with an explicit address space storage 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="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: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">local&lt;array&lt;int, 2&gt;&gt;</span> localArray<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-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)</span> <span style="color: #990000">==</span> <span style="color: #993399">0</span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> it <span style="color: #990000">=</span> localArray<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">();</span> it <span style="color: #990000">!=</span> localArray<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">();</span> <span style="color: #990000">++</span>it<span style="color: #990000">)</span>
<span style="color: #990000">*</span>it <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #000000">work_group_barrier</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>local<span style="color: #990000">);</span>
localArray<span style="color: #990000">[</span><span style="color: #993399">0</span><span style="color: #990000">]</span> <span style="color: #990000">+=</span> <span style="color: #993399">1</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-5">Example 5</h5>
<div class="paragraph"><p>Example of using a fundamental type with an explicit address space storage 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="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_work_item&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">local&lt;int&gt;</span> a<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-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)</span> <span style="color: #990000">==</span> <span style="color: #993399">0</span><span style="color: #990000">)</span>
a <span style="color: #990000">=</span> <span style="color: #993399">1</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">work_group_barrier</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>local<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-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)</span> <span style="color: #990000">==</span> <span style="color: #993399">1</span><span style="color: #990000">)</span>
a <span style="color: #990000">+=</span> <span style="color: #993399">1</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="specialization-constants-library">3.5. Specialization Constants Library</h3>
<div class="paragraph"><p>The specialization constants are objects that will not have known constant values until after initial generation of a SPIR-V module.
Such objects are called specialization constants.
Application might provide values for the specialization constants that will be used when SPIR-V program is built.</p></div>
<div class="sect3">
<h4 id="header-opencl_spec_constant-synopsis">3.5.1. Header &lt;opencl_spec_constant&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="color: #009900">unsigned</span> <span style="color: #009900">int</span> ID<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">spec_constant</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">spec_constant</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">spec_constant</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> spec_constant <span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">spec_constant</span></span><span style="color: #990000">(</span>spec_constant<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">spec_constant</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</span> value<span style="color: #990000">);</span>
spec_constant<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> spec_constant<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
spec_constant<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>spec_constant<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</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">operator</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></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="color: #009900">unsigned</span> <span style="color: #009900">int</span> ID<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</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> <span style="color: #008080">spec_constant&lt;T, ID&gt;</span> <span style="color: #990000">&amp;</span>r<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="spec_constant-class-methods-and-get-function">3.5.2. spec_constant class methods and get function</h4>
<div class="sect4">
<h5 id="spec_constantspec_constant">spec_constant::spec_constant</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">spec_constant</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</span> value<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Constructor of spec_constant class.
The value parameter is a default value of the specialization constant that will be used if a value is not set by the host API.
It must be a literal value.</p></div>
</div>
<div class="sect4">
<h5 id="get">get</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">const</span></span> T<span style="color: #990000">&amp;</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">operator</span></span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;()</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">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: #009900">unsigned</span> <span style="color: #009900">int</span> ID<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</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> <span style="color: #008080">spec_constant&lt;T, ID&gt;</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>Return a value of specialization constant.
If an object is not specialized from the host, the default value will be returned.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="requirements-2">3.5.3. Requirements</h4>
<div class="paragraph"><p>Specialization constant variables cannot be defined <span class="monospaced">constexpr</span>.</p></div>
<div class="sect4">
<h5 id="data-1">Data</h5>
<div class="paragraph"><p>Template parameter <span class="monospaced">T</span> in spec_constant class template denotes the data type of specialization constant.
The type <span class="monospaced">T</span> must be integral or floating point type.</p></div>
</div>
<div class="sect4">
<h5 id="id">ID</h5>
<div class="paragraph"><p>Template parameter <span class="monospaced">ID</span> in spec_constant class template denotes an unique ID of the specialization constant that can be used to set a value from the host API.
The value of <span class="monospaced">ID</span> must be unique within this compilation unit and across any other SPIR-V modules that it is linked with.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="examples-9">3.5.4. Examples</h4>
<div class="sect4">
<h5 id="example-1-9">Example 1</h5>
<div class="paragraph"><p>Example of using the specialization constant in the kernel.</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_spec_constant&gt;</span>
cl<span style="color: #990000">::</span><span style="color: #008080">spec_constant&lt;int, 1&gt;</span> spec1<span style="color: #FF0000">{</span> <span style="color: #993399">255</span> <span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> cl<span style="color: #990000">::</span><span style="color: #008080">spec_constant&lt;int, 2&gt;</span> spec2<span style="color: #FF0000">{</span> <span style="color: #993399">255</span> <span style="color: #FF0000">}</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// error, constexpr specialization</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// constant variables are not allowed</span></span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">myKernel</span></span><span style="color: #990000">()</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">(</span>spec1<span style="color: #990000">)</span> <span style="color: #990000">==</span> <span style="color: #993399">255</span><span style="color: #990000">)</span>
<span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// do something if a default value is used</span></span>
<span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">else</span></span>
<span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// do something if the spec constant was specialized by the host</span></span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-2-7">Example 2</h5>
<div class="paragraph"><p>Example of specializing one of the dimensions in <span class="monospaced">cl::required_work_group_size</span> attribute.</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_spec_constant&gt;</span>
cl<span style="color: #990000">::</span><span style="color: #008080">spec_constant&lt;int, 1&gt;</span> spec1<span style="color: #FF0000">{</span> <span style="color: #993399">512</span> <span style="color: #FF0000">}</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">required_work_group_size</span></span><span style="color: #990000">(</span>spec1<span style="color: #990000">,</span> <span style="color: #993399">1</span><span style="color: #990000">,</span> <span style="color: #993399">1</span><span style="color: #990000">)]]</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">myKernel</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>
</div>
</div>
<div class="sect2">
<h3 id="half-wrapper-library">3.6. Half Wrapper Library</h3>
<div class="paragraph"><p>The OpenCL C++ programming language implements a wrapper class for the built-in half data type (<a href="#builtin-half-data-type">Built-in Half Data Type</a> section).
The class methods perform implicit <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> operations from <em><a href="#vector-data-load-and-store-functions">Vector Data Load and Store Functions</a> section</em>.</p></div>
<div class="sect3">
<h4 id="header-opencl_half-synopsis">3.6.1. Header &lt;opencl_half&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">struct</span></span> <span style="color: #008080">fp16</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">fp16</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">fp16</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16 <span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">fp16</span></span><span style="color: #990000">(</span>fp16 <span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">fp16</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> fp16 <span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">fp16</span> <span style="color: #990000">&amp;</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>fp16 <span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><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-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="font-weight: bold"><span style="color: #000000">fp16</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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">half</span> r<span style="color: #990000">)</span> noexcept<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">half</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: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000000">fp16</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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: #009900">float</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">float</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: #000080">#ifdef</span></span> cl_khr_fp64
<span style="font-weight: bold"><span style="color: #000000">fp16</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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: #009900">double</span> r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #009900">double</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: #000080">#endif</span></span>
<span style="color: #008080">fp16</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">fp16</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">fp16</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">fp16</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">fp16</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">fp16</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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">fp16</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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">fp16</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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">fp16</span> <span style="color: #990000">&amp;</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="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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</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="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</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="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">fp16</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<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="constructors-1">3.6.2. Constructors</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: #000000">fp16</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">half</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>Constructs an object with a half built-in 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: #000000">fp16</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #009900">float</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>Constructs an object with a float built-in type.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vstore_half</span> built-in function is called with the default rounding mode.</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">fp16</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #009900">double</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>Constructs an object with a double built-in type.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vstore_half</span> built-in function is called with the default rounding mode.
The constructor is only present if the double precision support is enabled.</p></div>
</div>
<div class="sect3">
<h4 id="assignment-operators-1">3.6.3. Assignment operators</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="color: #008080">fp16</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">half</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>Assigns r to the stored half 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="color: #008080">fp16</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: #009900">float</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>Assigns r to the stored half type.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vstore_half</span> built-in function is called with the default rounding mode.</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">fp16</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: #009900">double</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>Assigns r to the stored half type.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vstore_half</span> built-in function is called with the default rounding mode.
The operator is only present if the double precision support is enabled.</p></div>
</div>
<div class="sect3">
<h4 id="conversion-operators">3.6.4. Conversion operators</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">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">m != 0.0h</span>.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.</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">operator</span></span> <span style="font-weight: bold"><span style="color: #000000">half</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>Conversion operator to the built-in half 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: #0000FF">operator</span></span> <span style="color: #009900">float</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>Conversion operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.</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">operator</span></span> <span style="color: #009900">double</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>Conversion operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.
The operator is only present if the double precision support is enabled.</p></div>
</div>
<div class="sect3">
<h4 id="arithmetic-operations">3.6.5. Arithmetic operations</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="color: #008080">fp16</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>Pre-increment operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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>Post-increment operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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>Pre-decrement operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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>Pre-decrement operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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">fp16</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>Addition operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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">fp16</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>Subtract operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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">fp16</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>Multiplication operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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">fp16</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>Division operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</p></div>
</div>
<div class="sect3">
<h4 id="non-member-functions-1">3.6.6. Non-member functions</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="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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison operator ==.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.</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">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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison operator !=.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.</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">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&lt;</span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison operator &lt;.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.</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">bool</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&gt;</span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison operator &gt;.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.</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">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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison operator &#8656;.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.</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">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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Comparison operator &gt;=.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> built-in function is called.</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">fp16</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Addition operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Subtract operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Multiplication operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</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">fp16</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> fp16<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> fp16<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Division operator.
If the <em>cl_khr_fp16</em> extension is not supported, <span class="monospaced">vload_half</span> and <span class="monospaced">vstore_half</span> built-in functions are called.</p></div>
</div>
</div>
<div class="sect2">
<h3 id="vector-wrapper-library">3.7. Vector Wrapper Library</h3>
<div class="paragraph"><p>The OpenCL C++ programming language implements a vector wrapper type that works efficiently on the OpenCL devices.
The vector class supports methods that allow construction of a new vector from a swizzled set of component elements or from a built-in vector type.
The vector class can be converted to a corresponding built-in vector type.</p></div>
<div class="paragraph"><p>The <span class="monospaced">Size</span> parameter can be one of: 2, 3, 4, 8 or 16.
Any other value should produce a compilation failure.
The element type parameter <span class="monospaced">T</span>, must be one of the basic scalar types defined in <a href="#device_builtin_scalar_data_types">Device built-in scalar data types</a> table except void type.</p></div>
<div class="sect3">
<h4 id="header-opencl_vec-synopsis">3.7.1. Header &lt;opencl_vec&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">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">size_t</span> undef_channel <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">static_cast</span></span><span style="color: #990000">&lt;</span>size_t<span style="color: #990000">&gt;(-</span><span style="color: #993399">1</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">channel</span> <span style="color: #990000">:</span> size_t <span style="color: #FF0000">{</span> r <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">,</span> g <span style="color: #990000">=</span> <span style="color: #993399">1</span><span style="color: #990000">,</span> b <span style="color: #990000">=</span> <span style="color: #993399">2</span><span style="color: #990000">,</span> a <span style="color: #990000">=</span> <span style="color: #993399">3</span><span style="color: #990000">,</span> x <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">,</span> y <span style="color: #990000">=</span> <span style="color: #993399">1</span><span style="color: #990000">,</span> z <span style="color: #990000">=</span> <span style="color: #993399">2</span><span style="color: #990000">,</span> w <span style="color: #990000">=</span> <span style="color: #993399">3</span><span style="color: #990000">,</span> undef <span style="color: #990000">=</span> undef_channel <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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">vec</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> element_type <span style="color: #990000">=</span> T<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> vector_type <span style="color: #990000">=</span> make_vector_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> Size<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">size_t</span> size <span style="color: #990000">=</span> Size<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">vec</span></span><span style="color: #990000">(</span> <span style="color: #990000">)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">vec</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vec <span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">vec</span></span><span style="color: #990000">(</span>vec <span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">vec</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vector_type</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">vec</span></span><span style="color: #990000">(</span><span style="color: #008080">vector_type</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: #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: #990000">...</span> Params<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #000000">vec</span></span><span style="color: #990000">(</span>Params<span style="color: #990000">...</span> params<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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> vec <span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
vec<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>vec <span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
vec<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">vector_type</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">vector_type</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: #0000FF">operator</span></span> <span style="font-weight: bold"><span style="color: #000000">vector_type</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>
vec<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>
vec<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: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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>
vec<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: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</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: #0000FF">template</span></span> <span style="color: #990000">&lt;</span>size_t<span style="color: #990000">...</span> Sizes<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">swizzle</span></span><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>size_t<span style="color: #990000">...</span> Sizes<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">swizzle</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: #000080">#ifdef</span></span> SIMPLE_SWIZZLES
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">x</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #990000">...</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">xyzw</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #990000">...</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">zzzz</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></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>size_t<span style="color: #990000">...</span> Swizzle<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Vec</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">swizzle</span></span><span style="color: #990000">(</span>Vec<span style="color: #990000">&amp;</span> v<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span>channel<span style="color: #990000">...</span> Swizzle<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Vec</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">swizzle</span></span><span style="color: #990000">(</span>Vec<span style="color: #990000">&amp;</span> v<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">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator==(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator!=(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator&lt;(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator&gt;(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator&lt;=(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator&gt;=(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator+(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator+(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">T</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator+(const T &amp;lhs, const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator-(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator-(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">T</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator-(const T &amp;lhs, const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator*(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator*(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">T</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator*(const T &amp;lhs, const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator/(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator/(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">T</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator/(const T &amp;lhs, const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="constructors-2">3.7.2. Constructors</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: #000000">vec</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vector_type</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 constructor.
Constructs an object with the corresponding built-in 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: #000000">vec</span></span><span style="color: #990000">(</span><span style="color: #008080">vector_type</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.
Constructs an object with the corresponding built-in 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: #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: #990000">...</span> Params<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #000000">vec</span></span><span style="color: #990000">(</span>Params<span style="color: #990000">...</span> params<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Constructs a vector object from a swizzled set of component elements.</p></div>
</div>
<div class="sect3">
<h4 id="assignment-operators-2">3.7.3. Assignment operators</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>vec<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">vector_type</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.
The operator assigns a corresponding built-in 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>vec<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">vector_type</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.
The operator assigns a corresponding built-in vector type.</p></div>
</div>
<div class="sect3">
<h4 id="conversion-operators-1">3.7.4. Conversion operators</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">operator</span></span> <span style="font-weight: bold"><span style="color: #000000">vector_type</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>Conversion operator.
The operator converts from the vector wrapper class to a corresponding built-in vector type.</p></div>
</div>
<div class="sect3">
<h4 id="arithmetic-operations-1">3.7.5. Arithmetic operations</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>vec<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>Pre-increment 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>vec<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: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Post-increment 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>vec<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>Pre-decrement 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>vec<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: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Post-decrement 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>vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</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>Add each element of <span class="monospaced">r</span> to the respective element of the current vector in-place.</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>vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</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>Subtract each element of <span class="monospaced">r</span> from the respective element of the current vector in-place.</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>vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</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>Multiply each element of <span class="monospaced">r</span> by the respective element of the current vector in-place.</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>vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</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>Divide each element of the current vector in-place by the respective element of <span class="monospaced">r</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>vec<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">vec</span> <span style="color: #990000">&amp;</span>r<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
vec<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">element_type</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>Remainder of each element of the current vector in-place by the respective element of <span class="monospaced">r</span>.</p></div>
</div>
<div class="sect3">
<h4 id="swizzle-methods">3.7.6. Swizzle methods</h4>
<div class="paragraph"><p>All swizzle methods return a temporary object representing a swizzled set of the original vector&#8217;s member elements.
The swizzled vector may be used as a source (rvalue) and destination (lvalue).
In order to enable the r-value and lvalue swizzling to work, this returns an intermediate swizzled-vector class, which can be implicitly converted to a vector (rvalue evaluation) or assigned to.</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>size_t<span style="color: #990000">...</span> Sizes<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">swizzle</span></span><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>size_t<span style="color: #990000">...</span> Sizes<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">swizzle</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 a vector swizzle.
The number of template parameters specified in <span class="monospaced">Sizes</span> must be from <span class="monospaced">1</span> to <span class="monospaced">Size</span>.
<span class="monospaced">Sizes</span> parameters must be channel values: <span class="monospaced">channel::r</span>, <span class="monospaced">channel::b</span>, <span class="monospaced">&#8230;</span>.
Swizzle letters may be repeated or re-ordered.</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">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">x</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #990000">...</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">xyzw</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #990000">...</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">zzzz</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Returns a swizzle.
These swizzle methods are only generated if the user defined the <span class="monospaced">SIMPLE_SWIZZLES</span> macro before including <em>opencl_vec</em> header.</p></div>
</div>
<div class="sect3">
<h4 id="non-member-functions-2">3.7.7. Non-member functions</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">template</span></span> <span style="color: #990000">&lt;</span>size_t<span style="color: #990000">...</span> Swizzle<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Vec</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">swizzle</span></span><span style="color: #990000">(</span>Vec<span style="color: #990000">&amp;</span> v<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span>channel<span style="color: #990000">...</span> Swizzle<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Vec</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">swizzle</span></span><span style="color: #990000">(</span>Vec<span style="color: #990000">&amp;</span> v<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns a vector swizzle.
The number of template parameters specified in <span class="monospaced">Sizes</span> must be from <span class="monospaced">1</span> to <span class="monospaced">Size</span>.
<span class="monospaced">Sizes</span> parameters must be channel values: <span class="monospaced">channel::r</span>, <span class="monospaced">channel::b</span>, <span class="monospaced">&#8230;</span> .
Swizzle letters may be repeated or re-ordered.</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator==(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Return <span class="monospaced">true</span> if all elements of <span class="monospaced">rhs</span> compare equal to the respective element of <span class="monospaced">lhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator!=(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Return <span class="monospaced">true</span> if any one element of <span class="monospaced">rhs</span> does not compare equal to the respective element of <span class="monospaced">lhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator&lt;(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Return <span class="monospaced">true</span> if all elements of <span class="monospaced">lhs</span> are less than the respective element of <span class="monospaced">rhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator&gt;(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Return <span class="monospaced">true</span> if all elements of <span class="monospaced">lhs</span> are greater than the respective element of <span class="monospaced">rhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator&lt;=(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Return <span class="monospaced">true</span> if all elements of <span class="monospaced">lhs</span> are less than or equal to the respective element of <span class="monospaced">rhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;bool, Size&gt; operator&gt;=(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Return <span class="monospaced">true</span> if all elements of <span class="monospaced">lhs</span> are greater than or equal to the respective element of <span class="monospaced">rhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator+(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator+(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">T</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator+(const T &amp;lhs, const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Add each element of <span class="monospaced">rhs</span> to the respective element of <span class="monospaced">lhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator-(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator-(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">T</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator-(const T &amp;lhs, const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Subtract each element of <span class="monospaced">rhs</span> from the respective element of <span class="monospaced">lhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator*(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator*(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">T</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator*(const T &amp;lhs, const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Multiply each element of <span class="monospaced">rhs</span> by the respective element of <span class="monospaced">lhs</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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator/(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator/(const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>lhs<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">T</span> <span style="color: #990000">&amp;</span>rhs<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="color: #008080">size_t</span> Size<span style="color: #990000">&gt;</span>
<span style="color: #008080">vec&lt;T, Size&gt; operator/(const T &amp;lhs, const vec&lt;T, Size&gt;</span> <span style="color: #990000">&amp;</span>rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Divide each element of <span class="monospaced">lhs</span> by the respective element of the <span class="monospaced">rhs</span>.</p></div>
</div>
</div>
<div class="sect2">
<h3 id="range-library">3.8. Range Library</h3>
<div class="paragraph"><p>OpenCL C++ implements small library that contains useful utilities to manipulate iterator ranges.</p></div>
<div class="sect3">
<h4 id="header-opencl_range-synopsis">3.8.1. Header &lt;opencl_range&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">It</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">range_type</span>
<span style="color: #FF0000">{</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">range_type</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<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">range_type</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<span style="color: #990000">,</span> <span style="color: #008080">difference_type</span> end<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">range_type</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<span style="color: #990000">,</span> <span style="color: #008080">difference_type</span> begin<span style="color: #990000">,</span>
<span style="color: #008080">difference_type</span> end<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="color: #008080">auto</span> <span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span> <span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="color: #008080">auto</span> <span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span> <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">It</span><span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">auto</span> <span style="font-weight: bold"><span style="color: #000000">range</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<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">It</span><span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">auto</span> <span style="font-weight: bold"><span style="color: #000000">range</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<span style="color: #990000">,</span> <span style="color: #008080">difference_type</span> end<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">It</span><span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">auto</span> <span style="font-weight: bold"><span style="color: #000000">range</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<span style="color: #990000">,</span> <span style="color: #008080">difference_type</span> begin<span style="color: #990000">,</span>
<span style="color: #008080">difference_type</span> end<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// difference_type is It::difference_type if present ptrdiff_t otherwise.</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="range-type">3.8.2. Range type</h4>
<div class="paragraph"><p>Range type represents a given range over iterable type.
Depending on constructor 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="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">range_type</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Represents range from <span class="monospaced">begin(it)</span> to <span class="monospaced">end(it)</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">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">range_type</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<span style="color: #990000">,</span> <span style="color: #008080">difference_type</span> end<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Represents range from <span class="monospaced">begin(it)</span> to <span class="monospaced">begin(it)+end</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">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">range_type</span></span><span style="color: #990000">(</span>It<span style="color: #990000">&amp;</span> it<span style="color: #990000">,</span> <span style="color: #008080">difference_type</span> begin<span style="color: #990000">,</span>
<span style="color: #008080">difference_type</span> end<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Represents range from <span class="monospaced">begin(it)+begin</span> to <span class="monospaced">begin(it)+end</span>.</p></div>
</div>
<div class="sect3">
<h4 id="range-function">3.8.3. Range function</h4>
<div class="paragraph"><p>range function is present in three overloads matching <span class="monospaced">range_type</span> constructors.
It is a factory function building <span class="monospaced">range_type</span>.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">This function main purpose is enabling the use of range based for loops on built-in vectors.</td>
</tr></table>
</div>
</div>
</div>
<div class="sect2">
<h3 id="vector-utilities-library">3.9. Vector Utilities Library</h3>
<div class="paragraph"><p>OpenCL C++ implements vector utilities library that contains multiple helper classes to help working with built-in vectors.</p></div>
<div class="sect3">
<h4 id="header-opencl_vector_utility-synopsis">3.9.1. Header &lt;opencl_vector_utility&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="color: #008080">size_t</span> Channel<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Vec</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">remove_attrs_t&lt;vector_element_t&lt;Vec&gt;&gt;</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">(</span>Vec <span style="color: #990000">&amp;</span> vector<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="color: #008080">size_t</span> Channel<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Vec</span><span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">set</span></span><span style="color: #990000">(</span>Vec <span style="color: #990000">&amp;</span> vector<span style="color: #990000">,</span>
<span style="color: #008080">remove_attrs_t&lt;vector_element_t&lt;Vec&gt;&gt;</span> value<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">Vec</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">channel_ref</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> type <span style="color: #990000">=</span> remove_attrs_t<span style="color: #990000">&lt;</span>vector_element_t<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&gt;;</span>
constexpr <span style="color: #008080">operator</span> <span style="font-weight: bold"><span style="color: #000000">type</span></span><span style="color: #990000">(</span> <span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">+(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">-(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">*(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">/(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">%(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">^(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">&amp;=(</span><span style="color: #008080">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">&amp;(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">|(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">channel_ref</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">constexpr</span> channel_ref<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: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">channel_ref</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: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">channel_ref</span><span style="color: #990000">&lt;</span>floating_point_vector<span style="color: #990000">&gt;</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> type <span style="color: #990000">=</span> remove_attrs_t<span style="color: #990000">&lt;</span>vector_element_t<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&gt;;</span>
constexpr <span style="color: #008080">operator</span> <span style="font-weight: bold"><span style="color: #000000">type</span></span><span style="color: #990000">(</span> <span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">+(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">-(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">*(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">/(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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: #009900">int</span><span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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: #009900">int</span><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;&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">channel_ref</span><span style="color: #990000">&lt;</span>boolean_vector<span style="color: #990000">&gt;</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> type <span style="color: #990000">=</span> remove_attrs_t<span style="color: #990000">&lt;</span>vector_element_t<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&gt;;</span>
constexpr <span style="color: #008080">operator</span> <span style="font-weight: bold"><span style="color: #000000">type</span></span><span style="color: #990000">(</span> <span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">+(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">-(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">*(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">/(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">%(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">^(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">&amp;=(</span><span style="color: #008080">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">&amp;(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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">type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> <span style="color: #008080">type</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> <span style="color: #990000">|(</span><span style="color: #008080">channel_ref</span> lhs<span style="color: #990000">,</span> <span style="color: #008080">type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ref<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: #009900">int</span><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">Vec</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">channel_ptr</span>
<span style="color: #FF0000">{</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">channel_ptr</span></span><span style="color: #990000">(</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">channel_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> channel_ref<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&amp;</span> ref<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">channel_ptr</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> channel_ptr<span style="color: #990000">&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">channel_ptr</span></span><span style="color: #990000">(</span>channel_ptr<span style="color: #990000">&amp;&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ptr<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> channel_ptr<span style="color: #990000">&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> channel_ptr<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>channel_ptr<span style="color: #990000">&amp;&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> type <span style="color: #990000">=</span> remove_attrs_t<span style="color: #990000">&lt;</span>vector_element_t<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&gt;;</span>
<span style="color: #008080">constexpr</span> channel_ref<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">*(</span> <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">Vec</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">vector_iterator</span> <span style="color: #990000">:</span> iterator<span style="color: #990000">&lt;</span>random_access_iterator_tag<span style="color: #990000">,</span>
remove_attrs_t<span style="color: #990000">&lt;</span>vector_element_t<span style="color: #990000">&lt;</span>remove_attrs_t<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&gt;&gt;,</span>
ptrdiff_t<span style="color: #990000">,</span>
channel_ptr<span style="color: #990000">&lt;</span>remove_attrs_t<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&gt;,</span>
channel_ref<span style="color: #990000">&lt;</span>remove_attrs_t<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;&gt;&gt;</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> type <span style="color: #990000">=</span> remove_attrs_t<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">vector_iterator</span></span><span style="color: #990000">(</span>type <span style="color: #990000">&amp;</span> vector<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> offset<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">vector_iterator</span></span><span style="color: #990000">(</span> <span style="color: #990000">)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">vector_iterator</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vector_iterator<span style="color: #990000">&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">vector_iterator</span></span><span style="color: #990000">(</span>vector_iterator<span style="color: #990000">&amp;&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> vector_iterator<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> vector_iterator<span style="color: #990000">&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> vector_iterator<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>vector_iterator<span style="color: #990000">&amp;&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> vector_iterator<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> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="color: #008080">friend</span> <span style="color: #008080">vector_iterator</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> vector_iterator<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span>
<span style="color: #008080">difference_type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="color: #008080">friend</span> <span style="color: #008080">vector_iterator</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> lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vector_iterator<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> vector_iterator<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> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <span style="color: #008080">friend</span> <span style="color: #008080">vector_iterator</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> vector_iterator<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span>
<span style="color: #008080">difference_type</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">vector_iterator</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">constexpr</span> vector_iterator<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: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">vector_iterator</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">constexpr</span> vector_iterator<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: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> constexpr <span style="color: #008080">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> vector_iterator<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vector_iterator<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> constexpr <span style="color: #008080">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> vector_iterator<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vector_iterator<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> constexpr <span style="color: #008080">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> vector_iterator<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vector_iterator<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> constexpr <span style="color: #008080">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> vector_iterator<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vector_iterator<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> constexpr <span style="color: #008080">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> vector_iterator<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vector_iterator<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">friend</span></span> constexpr <span style="color: #008080">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> vector_iterator<span style="color: #990000">&amp;</span> lhs<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> vector_iterator<span style="color: #990000">&amp;</span> rhs<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <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: #990000">](</span><span style="color: #008080">difference_type</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <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: #990000">)</span> noexcept<span style="color: #990000">;</span>
constexpr <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="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">Vec</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #990000">=</span> enable_if_t<span style="color: #990000">&lt;</span>is_vector_type<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;::</span>value<span style="color: #990000">,</span> <span style="color: #009900">void</span><span style="color: #990000">&gt;&gt;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">channel_ref&lt;Vec&gt;</span> <span style="font-weight: bold"><span style="color: #000000">index</span></span><span style="color: #990000">(</span>Vec<span style="color: #990000">&amp;</span> vector<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> channel<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">Vec</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #990000">=</span> enable_if_t<span style="color: #990000">&lt;</span>is_vector_type<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;::</span>value<span style="color: #990000">,</span> <span style="color: #009900">void</span><span style="color: #990000">&gt;&gt;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">vector_iterator&lt;Vec&gt;</span> <span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span>Vec <span style="color: #990000">&amp;</span> vector<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">Vec</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #990000">=</span> enable_if_t<span style="color: #990000">&lt;</span>is_vector_type<span style="color: #990000">&lt;</span>Vec<span style="color: #990000">&gt;::</span>value<span style="color: #990000">,</span> <span style="color: #009900">void</span><span style="color: #990000">&gt;&gt;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">vector_iterator&lt;Vec&gt;</span> <span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span>Vec <span style="color: #990000">&amp;</span> vector<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="vector-iterator">3.9.2. Vector iterator</h4>
<div class="paragraph"><p>Vector iterator is a random access iterator that allows runtime iteration over vector channels.
Meets all the requirements for random access iterator.
Iterating outside of vector bounds is an undefined behavior.</p></div>
<div class="paragraph"><p>The library also exposes non member begin and end functions for vectors.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">Due to the usage of argument-dependent lookup in range based for loops this functions are not available, and the new range adapter has to be used</td>
</tr></table>
</div>
<div class="paragraph"><p>There is also an <span class="monospaced">index</span> function present in the library that allows runtime numerical indexing of channels.
It returns a channel reference to a given channel number.
Indexing out of vector bounds results in undefined behavior.</p></div>
<div class="paragraph"><p>The following example will present simple template function computing sum of channels of a given vector:</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">V</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">sum</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> V<span style="color: #990000">&amp;</span> v<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">vector_element_t&lt;V&gt;</span> temp <span style="color: #990000">=</span> <span style="color: #993399">0</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="font-weight: bold"><span style="color: #0000FF">auto</span></span> e <span style="color: #990000">:</span> <span style="font-weight: bold"><span style="color: #000000">range</span></span><span style="color: #990000">(</span>v<span style="color: #990000">))</span> <span style="color: #FF0000">{</span>
temp <span style="color: #990000">+=</span> e<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">return</span></span> temp<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="channel-reference-and-channel-pointer">3.9.3. Channel reference and channel pointer</h4>
<div class="paragraph"><p><span class="monospaced">channel_ref</span> and <span class="monospaced">channel_ptr</span> classes provide lightweight reference and pointer wrappers for vector channels.
This is required due to the fact that vector channels can be moved across memory during execution so direct physical addressing is impossible.
Reference wrapper provides a set of binary operators (depending on vector channel type).</p></div>
<div class="paragraph"><p>The following example will present a simple usage of channel reference to set first channel of given vector to 0:</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">V</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">fun</span></span><span style="color: #990000">(</span>V<span style="color: #990000">&amp;</span> v<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">channel_ref&lt;V&gt;</span> r <span style="color: #990000">=</span> <span style="color: #990000">*</span><span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span>v<span style="color: #990000">);</span>
r <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="get-and-set-functions">3.9.4. Get and set functions</h4>
<div class="paragraph"><p>Get and set functions allow compile time numerical indexing of channels to substitute for normal swizzling.
Indexing out of vector range generates a compile error.
Get function returns a copy of channel value.</p></div>
<div class="paragraph"><p>The following example will present how get and set functions can be used to duplicate the value of the first channel of given vector:</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">V</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">fun</span></span><span style="color: #990000">(</span>V<span style="color: #990000">&amp;</span> v<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> c <span style="color: #990000">=</span> get<span style="color: #990000">&lt;</span> <span style="color: #993399">0</span> <span style="color: #990000">&gt;(</span>v<span style="color: #990000">);</span>
set<span style="color: #990000">&lt;</span> <span style="color: #993399">0</span> <span style="color: #990000">&gt;(</span>v<span style="color: #990000">,</span> <span style="color: #993399">2</span><span style="color: #990000">*</span>c<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="examples-8">3.9.5. Examples</h4>
<div class="sect4">
<h5 id="example-1-8">Example 1</h5>
<div class="paragraph"><p>Example of using built-in vector iterators.</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_vector_utility&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_range&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">int8</span> v_i8<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> iter_begin <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span>v_i8<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> iter_end <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span>v_i8<span style="color: #990000">);</span>
iter_begin <span style="color: #990000">=</span> iter_end<span style="color: #990000">;</span>
<span style="color: #009900">int</span> a <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
a <span style="color: #990000">=</span> <span style="color: #990000">*</span>iter_begin<span style="color: #990000">;</span>
a <span style="color: #990000">=</span> iter_begin<span style="color: #990000">[</span><span style="color: #993399">0</span><span style="color: #990000">];</span>
iter_begin<span style="color: #990000">++;</span>
iter_begin<span style="color: #990000">+=</span><span style="color: #993399">1</span><span style="color: #990000">;</span>
iter_begin <span style="color: #990000">=</span> iter_begin <span style="color: #990000">+</span> <span style="color: #993399">1</span><span style="color: #990000">;</span>
iter_begin<span style="color: #990000">--;</span>
iter_begin<span style="color: #990000">-=</span><span style="color: #993399">1</span><span style="color: #990000">;</span>
iter_begin <span style="color: #990000">=</span> iter_begin <span style="color: #990000">-</span> <span style="color: #993399">1</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-2-6">Example 2</h5>
<div class="paragraph"><p>Example of iterating though built-in vector channels and using range library.</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_vector_utility&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_range&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> <span style="color: #FF0000">{</span>
<span style="color: #008080">int16</span> a<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> it <span style="color: #990000">=</span> cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span>a<span style="color: #990000">);</span> it <span style="color: #990000">!=</span> cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span>a<span style="color: #990000">);</span> it<span style="color: #990000">++)</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> b <span style="color: #990000">=</span> <span style="color: #990000">*</span>it<span style="color: #990000">;</span>
<span style="color: #990000">*</span>it <span style="color: #990000">=</span> <span style="color: #993399">2</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">for</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> c <span style="color: #990000">:</span> cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">range</span></span><span style="color: #990000">(</span>a<span style="color: #990000">,</span><span style="color: #993399">3</span><span style="color: #990000">,</span><span style="color: #993399">6</span><span style="color: #990000">))</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> b <span style="color: #990000">=</span> c<span style="color: #990000">;</span>
c <span style="color: #990000">=</span> <span style="color: #993399">2</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="marker-types">3.10. Marker Types</h3>
<div class="paragraph"><p>Some types in OpenCL C++ are considered marker types.
These types are special in the manner that their usages need to be tracked by the compiler.
This results in the following set of restrictions that marker types have to follow:</p></div>
<div class="ulist"><ul>
<li>
<p>
Marker types have the default constructor deleted.
</p>
</li>
<li>
<p>
Marker types have all default copy and move assignment operators deleted.
</p>
</li>
<li>
<p>
Marker types have address-of operator deleted.
</p>
</li>
<li>
<p>
Marker types cannot be used in divergent control flow. It can result in undefined behavior.
</p>
</li>
<li>
<p>
Size of marker types is undefined.
</p>
</li>
</ul></div>
<div class="sect3">
<h4 id="header-opencl_marker-synopsis">3.10.1. Header &lt;opencl_marker&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">struct</span></span> <span style="color: #008080">marker_type</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">struct</span></span> <span style="color: #008080">is_marker_type</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="marker_type-class">3.10.2. marker_type class</h4>
<div class="paragraph"><p>All special OpenCL C++ types must use the <span class="monospaced">marker_type</span> class as a base class.</p></div>
</div>
<div class="sect3">
<h4 id="is_marker_type-type-trait">3.10.3. is_marker_type type trait</h4>
<div class="paragraph"><p><span class="monospaced">is_marker_type</span> type trait provides compile-time check if the base of a class is <span class="monospaced">marker_type</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">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">struct</span></span> <span style="color: #008080">is_marker_type</span> <span style="color: #990000">:</span> integral_constant <span style="color: #990000">&lt;</span><span style="color: #009900">bool</span><span style="color: #990000">,</span> is_base_of<span style="color: #990000">&lt;</span>marker_type<span style="color: #990000">,</span> T<span style="color: #990000">&gt;::</span>value<span style="color: #990000">&gt;</span> <span style="color: #FF0000">{</span> <span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="examples">3.10.4. Examples</h4>
<div class="sect4">
<h5 id="example-1">Example 1</h5>
<div class="paragraph"><p>The examples of invalid use of <span class="monospaced">marker types</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: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_image&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">float4</span> <span style="font-weight: bold"><span style="color: #000000">bar</span></span><span style="color: #990000">(</span><span style="color: #008080">image1d&lt;float4&gt;</span> img<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">return</span></span> img<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #FF0000">{</span><span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">),</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">)</span><span style="color: #FF0000">}</span><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><span style="color: #008080">image1d&lt;float4&gt; img1, image1d&lt;float4&gt;</span> img2<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">image1d&lt;float4&gt;</span> img3<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">//error: marker type cannot be declared</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// in the kernel</span></span>
img1 <span style="color: #990000">=</span> img2<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">//error: marker type cannot be assigned</span></span>
<span style="color: #008080">image1d&lt;float4&gt;</span> <span style="color: #990000">*</span>imgPtr <span style="color: #990000">=</span> <span style="color: #990000">&amp;</span>img1<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">//error: taking address of</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// marker type</span></span>
<span style="color: #008080">size_t</span> s <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">sizeof</span></span><span style="color: #990000">(</span>img1<span style="color: #990000">);</span> <span style="font-style: italic"><span style="color: #9A1900">//undefined behavior: size of marker</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// type is not defined</span></span>
<span style="color: #008080">float4</span> val <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">bar</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)</span> <span style="color: #990000">?</span> img1<span style="color: #990000">:</span> img2<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//undefined behavior: divergent control flow</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-2">Example 2</h5>
<div class="paragraph"><p>The examples of how to use <span class="monospaced">is_marker_type</span> trait.</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_image&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">image1d&lt;float4&gt;</span> img<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">static_assert</span></span><span style="color: #990000">(</span>is_marker_type<span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>img<span style="color: #990000">)&gt;(),</span> <span style="color: #FF0000">""</span><span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="images-and-samplers-library">3.11. Images and Samplers Library</h3>
<div class="paragraph"><p>This section describes the image and sampler types and functions that can be used to read from and/or write to an image.
<span class="monospaced">image1d</span>, <span class="monospaced">image1d_buffer</span>, <span class="monospaced">image1d_array</span>, <span class="monospaced">image2d</span>, <span class="monospaced">image2d_array</span>, <span class="monospaced">image3d</span>, <span class="monospaced">image2d_depth</span>, <span class="monospaced">image2d_array_depth</span>, <span class="monospaced">image2d_ms</span>, <span class="monospaced">image2d_array_ms</span>, <span class="monospaced">image2d_depth_ms</span>, <span class="monospaced">image2d_array_depth_ms</span> <a href="#ftn13">[13</a>] and <span class="monospaced">sampler</span> follow the rules for marker types (<em><a href="#marker-types">Marker Types</a> section</em>).
The image and sampler types can only be used if the device support images i.e. <span class="monospaced">CL_DEVICE_IMAGE_SUPPORT</span> as described in table 4.3 in OpenCL 2.2 specification is <span class="monospaced">CL_TRUE</span>.</p></div>
<div class="sect3">
<h4 id="image-and-sampler-host-types">3.11.1. Image and Sampler Host Types</h4>
<div class="paragraph"><p>The below table describes the OpenCL image and sampler data types and the corresponding data type available to the application:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 10. Host image and sampler types</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type in OpenCL C++</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">cl::image1d</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image1d_buffer</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image1d_array</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image2d</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image2d_array</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image3d</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image2d_depth</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image2d_array_depth</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image2d_ms</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image2d_array_ms</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image2d_depth_ms</span>,</p>
<p class="tableblock"><span class="monospaced">cl::image2d_array_depth_ms</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_image</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl::sampler</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_sampler</span></p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="header-opencl_image-synopsis">3.11.2. Header &lt;opencl_image&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">image_access</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">image_channel_type</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">image_channel_order</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">addressing_mode</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">normalized_coordinates</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">filtering_mode</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">sampler</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="color: #008080">addressing_mode</span> A<span style="color: #990000">,</span> <span style="color: #008080">normalized_coordinates</span> C<span style="color: #990000">,</span> <span style="color: #008080">filtering_mode</span> F<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">sampler</span> <span style="font-weight: bold"><span style="color: #000000">make_sampler</span></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="color: #008080">image_access</span> A<span style="color: #990000">,</span> <span style="color: #008080">image_dim</span> Dim<span style="color: #990000">,</span> <span style="color: #009900">bool</span> Depth<span style="color: #990000">,</span> <span style="color: #009900">bool</span> Array<span style="color: #990000">,</span>
<span style="color: #009900">bool</span> MS<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">image</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="color: #008080">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image1d <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_1d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image1d_buffer <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_buffer<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image1d_array <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_1d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image2d <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_2d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image2d_depth <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_2d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image2d_array <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_2d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image3d <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_3d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image2d_array_depth <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span> image_2d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_gl_msaa_sharing<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_gl_depth_images<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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image2d_ms <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_2d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image2d_array_ms <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_2d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image2d_depth_ms <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_2d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">&gt;;</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">image_access</span> A <span style="color: #990000">=</span> image_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> image2d_array_depth_ms <span style="color: #990000">=</span> image<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> A<span style="color: #990000">,</span> image_dim<span style="color: #990000">::</span>image_2d<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">true</span></span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>Where <span class="monospaced">T</span> is the type of value returned when reading or sampling from given image or the type of color used to write to image.</p></div>
</div>
<div class="sect3">
<h4 id="image-class">3.11.3. image class</h4>
<div class="paragraph"><p>Every image type has the following set of publicly available members and typedefs:</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="color: #008080">image_access</span> A<span style="color: #990000">,</span> <span style="color: #008080">image_dim</span> Dim<span style="color: #990000">,</span> <span style="color: #009900">bool</span> Depth<span style="color: #990000">,</span> <span style="color: #009900">bool</span> Array<span style="color: #990000">,</span>
<span style="color: #009900">bool</span> MS<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">image</span><span style="color: #990000">:</span> marker_type
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">image_dim</span> dimension <span style="color: #990000">=</span> Dim<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">size_t</span> dimension_num <span style="color: #990000">=</span> image_dim_num<span style="color: #990000">&lt;</span>Dim<span style="color: #990000">&gt;::</span>value<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">size_t</span> image_size <span style="color: #990000">=</span> dimension_num <span style="color: #990000">+</span> <span style="color: #990000">(</span>Array<span style="color: #990000">?</span> <span style="color: #993399">1</span><span style="color: #990000">:</span> <span style="color: #993399">0</span><span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">image_access</span> access <span style="color: #990000">=</span> A<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_array <span style="color: #990000">=</span> Array<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_depth <span style="color: #990000">=</span> Depth<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_gl_msaa_sharing<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_gl_depth_images<span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_ms <span style="color: #990000">=</span> MS<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#else</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_ms <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></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: #008080">element_type</span> T<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">integer_coord</span> make_vector_t<span style="color: #990000">&lt;</span><span style="color: #009900">int</span><span style="color: #990000">,</span> image_size<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">float_coord</span> make_vector_t<span style="color: #990000">&lt;</span><span style="color: #009900">float</span><span style="color: #990000">,</span> image_size<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_mipmap_image
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">gradient_coord</span> make_vector_t<span style="color: #990000">&lt;</span><span style="color: #009900">float</span><span style="color: #990000">,</span> dimension_num<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">pixel</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">image</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">image</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> image<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">image</span></span><span style="color: #990000">(</span>image<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
image<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> image<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
image<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>image<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
image<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="image-element-types">3.11.4. Image element types</h4>
<div class="paragraph"><p>We can classify images into four categories: depth images which have the <span class="monospaced">Depth</span> template parameter set to <span class="monospaced">true</span>, multi-sample depth images which have the <span class="monospaced">Depth</span> and <span class="monospaced">MS</span> template parameters set to <span class="monospaced">true</span>, multi-sample which have the <span class="monospaced">MS</span> template parameter set to <span class="monospaced">true</span>, and the normal images which have the <span class="monospaced">Depth</span> and <span class="monospaced">MS</span> template parameters set to <span class="monospaced">false</span>.</p></div>
<div class="ulist"><ul>
<li>
<p>
For non-multisample depth images the only valid element types are: <span class="monospaced">float</span> and <span class="monospaced">half</span> <a href="#ftn4">[4</a>]
</p>
</li>
<li>
<p>
For normal images the only valid element types are: <span class="monospaced">float4</span>, <span class="monospaced">half4</span> <a href="#ftn4">[4</a>], <span class="monospaced">int4</span> and <span class="monospaced">uint4</span>
</p>
</li>
<li>
<p>
For multi-sample 2D and multi-sample 2D array images the only valid element types are: <span class="monospaced">float4</span>, <span class="monospaced">int4</span> and <span class="monospaced">uint4</span>
</p>
</li>
<li>
<p>
For multi-sample 2D depth and multi-sample 2D array depth images the only valid element type is: <span class="monospaced">float</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>Image type with invalid pixel type is ill formed.</p></div>
</div>
<div class="sect3">
<h4 id="image-dimension">3.11.5. Image dimension</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">image_dim</span>
<span style="color: #FF0000">{</span>
image_1d<span style="color: #990000">,</span>
image_2d<span style="color: #990000">,</span>
image_3d<span style="color: #990000">,</span>
image_buffer
<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="color: #008080">image_dim</span> Dim<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">image_dim_num</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>Image types present different set of methods depending on their dimensionality and arrayness.</p></div>
<div class="ulist"><ul>
<li>
<p>
Images of dimension 1 (<span class="monospaced">image_dim::image_1d</span> and <span class="monospaced">image_dim::buffer</span>) have method:
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">width</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>
</li>
<li>
<p>
Images of dimension 2 (<span class="monospaced">image_dim::image_2d</span>) have all methods of 1 dimensional images and
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">height</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>
</li>
<li>
<p>
Images of dimension 3 (<span class="monospaced">image_dim::image_3d</span>) have all methods of 2 dimensional images and
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">depth</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>
</li>
<li>
<p>
Arrayed images have additional method
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">array_size</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>
</li>
</ul></div>
<div class="paragraph"><p>If <em>cl_khr_mipmap_image</em> or <em>cl_khr_mipmap_image_writes</em> extension is enabled then the following methods are also present:</p></div>
<div class="ulist"><ul>
<li>
<p>
Images of dimension 1 (<span class="monospaced">image_dim::image_1d</span> and <span class="monospaced">image_dim::buffer</span>) have method:
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">width</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> lod<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>
</li>
<li>
<p>
Images of dimension 2 (<span class="monospaced">image_dim::image_2d</span>) have all methods of 1 dimensional images and
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">height</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> lod<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>
</li>
<li>
<p>
Images of dimension 3 (<span class="monospaced">image_dim::image_3d</span>) have all methods of 2 dimensional images and
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">depth</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> lod<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>
</li>
<li>
<p>
Arrayed images have additional method
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">array_size</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> lod<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>
</li>
</ul></div>
<div class="paragraph"><p>If <em>cl_khr_gl_msaa_sharing</em> and <em>cl_khr_gl_depth_images</em> extensions are enabled then the following methods are also present:</p></div>
<div class="ulist"><ul>
<li>
<p>
Images of dimension 2D (<span class="monospaced">image_dim::image_2d</span>) have method:
</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">num_samples</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>
</li>
</ul></div>
<div class="paragraph"><p>The following table describes the <span class="monospaced">image_dim_num</span> trait that return a number of dimensions based on <span class="monospaced">image_dim</span> parameter.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 11. Image_dim_num trait</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Template</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Value</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;image_dim Dim&gt;
struct image_dim_num;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If <span class="monospaced">Dim</span> is <span class="monospaced">image_dim::image_1d</span> or <span class="monospaced">image_dim::image_buffer</span>, image dimension is 1.</p>
<p class="tableblock">If <span class="monospaced">Dim</span> is <span class="monospaced">image_dim::image_2d</span>, image dimension is 2.</p>
<p class="tableblock">If <span class="monospaced">Dim</span> is <span class="monospaced">image_dim::image_3d</span>, image dimension is 3.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="image-access">3.11.6. Image access</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">image_access</span>
<span style="color: #FF0000">{</span>
sample<span style="color: #990000">,</span>
read<span style="color: #990000">,</span>
write<span style="color: #990000">,</span>
read_write
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The non-multisample image template class specializations present different set of methods based on their access parameter.</p></div>
<div class="ulist"><ul>
<li>
<p>
Images specified with <span class="monospaced">image_access::read</span> provide additional methods:
</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<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">pixel</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">integer_coord</span> coord<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">element_type</span> image<span style="color: #990000">::</span>pixel<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">element_type</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>
</li>
<li>
<p>
Images specified with <span class="monospaced">image_access::write</span> provide additional method:
</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: #009900">void</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">,</span> <span style="color: #008080">element_type</span> color<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
image<span style="color: #990000">::</span><span style="color: #008080">pixel</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
image<span style="color: #990000">::</span>pixel <span style="color: #990000">&amp;</span> image<span style="color: #990000">::</span>pixel<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">element_type</span> color<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
</li>
<li>
<p>
Images specified with <span class="monospaced">image_access::read_write</span> provide additional methods:
</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<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: #009900">void</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">,</span> <span style="color: #008080">element_type</span> color<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
image<span style="color: #990000">::</span><span style="color: #008080">pixel</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">element_type</span> image<span style="color: #990000">::</span>pixel<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">element_type</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>
image<span style="color: #990000">::</span>pixel <span style="color: #990000">&amp;</span> image<span style="color: #990000">::</span>pixel<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">element_type</span> color<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
</li>
<li>
<p>
Images specified with <span class="monospaced">image_access::sample</span> provide additional methods:
</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">sampler</span> <span style="color: #990000">&amp;</span>s<span style="color: #990000">,</span>
<span style="color: #008080">integer_coord</span> coord<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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">sampler</span> <span style="color: #990000">&amp;</span>s<span style="color: #990000">,</span> <span style="color: #008080">float_coord</span> coord<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
image<span style="color: #990000">::</span><span style="color: #008080">pixel</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">integer_coord</span> coord<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">element_type</span> image<span style="color: #990000">::</span>pixel<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">element_type</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>
</li>
</ul></div>
<div class="paragraph"><p>If <em>cl_khr_mipmap_image</em> extension is enabled the following methods are added to the non-multisample image types:</p></div>
<div class="ulist"><ul>
<li>
<p>
Images specified with <span class="monospaced">image_access::sample</span> provide additional methods:
</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">sampler</span> <span style="color: #990000">&amp;</span>s<span style="color: #990000">,</span> <span style="color: #008080">float_coord</span> coord<span style="color: #990000">,</span>
<span style="color: #009900">float</span> lod<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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">sampler</span> <span style="color: #990000">&amp;</span>s<span style="color: #990000">,</span> <span style="color: #008080">float_coord</span> coord<span style="color: #990000">,</span>
<span style="color: #008080">gradient_coord</span> gradient_x<span style="color: #990000">,</span>
<span style="color: #008080">gradient_coord</span> gradient_y<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>
</li>
</ul></div>
<div class="paragraph"><p>If <em>cl_khr_mipmap_image_writes</em> extension is enabled the following methods are added to the non-multisample image types:</p></div>
<div class="ulist"><ul>
<li>
<p>
Images specified with <span class="monospaced">image_access::write</span> provide additional method:
</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: #009900">void</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">,</span> <span style="color: #008080">element_type</span> color<span style="color: #990000">,</span> <span style="color: #009900">int</span> lod<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
</li>
</ul></div>
<div class="paragraph"><p>If <em>cl_khr_gl_msaa_sharing</em> and <em>cl_khr_gl_depth_images</em> extensions are enabled and the multisample image type is used, the following method is available:</p></div>
<div class="ulist"><ul>
<li>
<p>
The multisample images specified with <span class="monospaced">image_access::read</span> provide method:
</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">,</span> <span style="color: #009900">int</span> sample<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
</li>
</ul></div>
</div>
<div class="sect3">
<h4 id="common-image-methods">3.11.7. Common image methods</h4>
<div class="paragraph"><p>Each image type implements a set of common methods:</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">image_channel_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">data_type</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">image_channel_order</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">order</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>If <em>cl_khr_mipmap_image</em> or <em>cl_khr_mipmap_image_writes</em> extension is enabled then the following method is also present in the non-multisample image 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">int</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">miplevels</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>where <span class="monospaced">image_channel_type</span> and <span class="monospaced">image_channel_order</span> are defined as follows:</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">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">image_channel_type</span>
<span style="color: #FF0000">{</span>
snorm_int8<span style="color: #990000">,</span>
snorm_int16<span style="color: #990000">,</span>
unorm_int8<span style="color: #990000">,</span>
unorm_int16<span style="color: #990000">,</span>
unorm_int24<span style="color: #990000">,</span>
unorm_short_565<span style="color: #990000">,</span>
unorm_short_555<span style="color: #990000">,</span>
unorm_int_101010<span style="color: #990000">,</span>
unorm_int_101010_2<span style="color: #990000">,</span>
signed_int8<span style="color: #990000">,</span>
signed_int16<span style="color: #990000">,</span>
signed_int32<span style="color: #990000">,</span>
unsigned_int8<span style="color: #990000">,</span>
unsigned_int16<span style="color: #990000">,</span>
unsigned_int32<span style="color: #990000">,</span>
fp16<span style="color: #990000">,</span>
fp32
<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">image_channel_order</span>
<span style="color: #FF0000">{</span>
a<span style="color: #990000">,</span>
r<span style="color: #990000">,</span>
rx<span style="color: #990000">,</span>
rg<span style="color: #990000">,</span>
rgx<span style="color: #990000">,</span>
ra<span style="color: #990000">,</span>
rgb<span style="color: #990000">,</span>
rgbx<span style="color: #990000">,</span>
rgba<span style="color: #990000">,</span>
argb<span style="color: #990000">,</span>
bgra<span style="color: #990000">,</span>
intensity<span style="color: #990000">,</span>
luminance<span style="color: #990000">,</span>
abgr<span style="color: #990000">,</span>
depth<span style="color: #990000">,</span>
depth_stencil<span style="color: #990000">,</span>
srgb<span style="color: #990000">,</span>
srgbx<span style="color: #990000">,</span>
srgba<span style="color: #990000">,</span>
sbgra
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="other-image-methods">3.11.8. Other image methods</h4>
<div class="sect4">
<h5 id="imagesample">image::sample</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">sampler</span> <span style="color: #990000">&amp;</span>s<span style="color: #990000">,</span> <span style="color: #008080">float_coord</span> coord<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>Reads a color value from the non-multisample image using sampler and floating point coordinates.</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">sampler</span> <span style="color: #990000">&amp;</span>s<span style="color: #990000">,</span> <span style="color: #008080">integer_coord</span> coord<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>Reads a color value from non-multisample image using sampler and integer coordinates.</p></div>
<div class="paragraph"><p>A sampler must use filter mode set to <span class="monospaced">filtering_mode::nearest</span>, normalized coordinates and addressing mode set to <span class="monospaced">addressing_mode::clamp_to_edge</span>, <span class="monospaced">addressing_mode::clamp</span>, <span class="monospaced">addressing_mode::none</span>, otherwise the values returned are undefined.</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">sampler</span> <span style="color: #990000">&amp;</span>s<span style="color: #990000">,</span> <span style="color: #008080">float_coord</span> coord<span style="color: #990000">,</span> <span style="color: #009900">float</span> lod<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>Reads a color value from non-multisample image using sampler and floating point coordinates in the mip-level specified by <span class="monospaced">lod</span>.</p></div>
<div class="paragraph"><p>Method is present for non-multisample images if <em>cl_khr_mipmap_image</em> extension is enabled.</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">sampler</span> <span style="color: #990000">&amp;</span>s<span style="color: #990000">,</span> <span style="color: #008080">float_coord</span> coord<span style="color: #990000">,</span>
<span style="color: #008080">gradient_coord</span> gradient_x<span style="color: #990000">,</span>
<span style="color: #008080">gradient_coord</span> gradient_y<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>Use the gradients to compute the lod and coordinate <span class="monospaced">coord</span> to do an element lookup in the mip-level specified by the computed lod.</p></div>
<div class="paragraph"><p>Method is present if <em>cl_khr_mipmap_image</em> extension is enabled.</p></div>
<div class="paragraph"><p>Based on the parameters with which image was created on host side the
function will return different ranges of values</p></div>
<div class="ulist"><ul>
<li>
<p>
returns floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <span class="monospaced">image_channel_type</span> set to one of the pre-defined packed formats or <span class="monospaced">image_channel_type::unorm_int8</span> or <span class="monospaced">image_channel_type::unorm_int16</span>.
</p>
</li>
<li>
<p>
returns floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <span class="monospaced">image_channel_type::snorm_int8</span> or <span class="monospaced">image_channel_type::snorm_int16</span>.
</p>
</li>
<li>
<p>
returns floating-point values for image objects created with <span class="monospaced">image_channel_type::float16</span> or <span class="monospaced">image_channel_type::float32</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>Values returned by <span class="monospaced">image::sample</span> where <span class="monospaced">T</span> is a floating-point type for image objects with <span class="monospaced">image_channel_type</span> values not specified in the description above are undefined.</p></div>
<div class="paragraph"><p>The <span class="monospaced">image::sample</span> functions that take an image object where <span class="monospaced">T</span> is a signed integer type can only be used with image objects created with:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">image_channel_type::sint8</span>,
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::sint16</span> and
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::sint32</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>If the <span class="monospaced">image_channel_type</span> is not one of the above values, the values returned by <span class="monospaced">image::sample</span> are undefined.</p></div>
<div class="paragraph"><p>The <span class="monospaced">image::sample</span> functions that take an image object where <span class="monospaced">T</span> is an unsigned integer type can only be used with image objects created with:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">image_channel_type::uint8</span>,
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::uint16</span> and
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::uint32</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>If the <span class="monospaced">image_channel_type</span> is not one of the above values, the values returned by <span class="monospaced">image::sample</span> are undefined.</p></div>
</div>
<div class="sect4">
<h5 id="imageread">image::read</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<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>Reads a color value from non-multisample image without sampler and integral coordinates.
If <em>cl_khr_mipmap_image</em> extension is present may perform reads also from mipmap layer 0.</p></div>
<div class="paragraph"><p>Based on the parameters with which image was created on host side the function will return different ranges of values</p></div>
<div class="paragraph"><p>Read function behaves exactly as the corresponding image sample function with sampler that has filter mode set to <span class="monospaced">filtering_mode::nearest</span>, normalized coordinates set to <span class="monospaced">normalized_coordinates::unnormalized</span> and addressing mode to <span class="monospaced">addressing_mode::none</span>.
The coordinates must be between 0 and image size in that dimension non inclusive.</p></div>
<div class="ulist"><ul>
<li>
<p>
returns floating-point values in the range [0.0 &#8230; 1.0] for image objects created with <span class="monospaced">image_channel_type</span> set to one of the pre-defined packed formats or <span class="monospaced">image_channel_type::unorm_int8</span> or <span class="monospaced">image_channel_type::unorm_int16</span>.
</p>
</li>
<li>
<p>
returns floating-point values in the range [-1.0 &#8230; 1.0] for image objects created with <span class="monospaced">image_channel_type::snorm_int8</span> or <span class="monospaced">image_channel_type::snorm_int16</span>.
</p>
</li>
<li>
<p>
returns floating-point values for image objects created with <span class="monospaced">image_channel_type::float16</span> or <span class="monospaced">image_channel_type::float32</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>Values returned by <span class="monospaced">image::read</span> where <span class="monospaced">T</span> is a floating-point type for image objects with <span class="monospaced">image_channel_type</span> values not specified in the description above are undefined.</p></div>
<div class="paragraph"><p>The <span class="monospaced">image::read</span> functions that take an image object where <span class="monospaced">T</span> is a signed integer type can only be used with image objects created with:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">image_channel_type::sint8</span>,
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::sint16</span> and
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::sint32</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>If the <span class="monospaced">image_channel_type</span> is not one of the above values, the values returned by <span class="monospaced">image::read</span> are undefined.</p></div>
<div class="paragraph"><p>The <span class="monospaced">image::read</span> functions that take an image object where <span class="monospaced">T</span> is an unsigned integer type can only be used with image objects created with <span class="monospaced">image_channel_type</span> set to one of the following values:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">image_channel_type::uint8</span>,
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::uint16</span> and
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::uint32</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>If the <span class="monospaced">image_channel_type</span> is not one of the above values, the values returned by <span class="monospaced">image::read</span> are undefined.</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">element_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">,</span> <span style="color: #009900">int</span> sample<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Use the coordinate and sample to do an element lookup in the image object.
Method is only available in the MSAA image types and if <em>cl_khr_gl_msaa_sharing</em> and <em>cl_khr_gl_depth_images</em> extension are supported.</p></div>
<div class="paragraph"><p>When a multisample image is accessed in a kernel, the access takes one vector of integers describing which pixel to fetch and an integer corresponding to the sample numbers describing which sample within the pixel to fetch.
<span class="monospaced">sample</span> identifies the sample position in the multi-sample image.</p></div>
<div class="paragraph"><p>For best performance, we recommend that sample be a literal value so it is known at compile time and the OpenCL compiler can perform appropriate optimizations for multisample reads on the device.</p></div>
<div class="paragraph"><p>No standard sampling instructions are allowed on the multisample image.
Accessing a coordinate outside the image and/or a sample that is outside the number of samples associated with each pixel in the image is undefined.</p></div>
</div>
<div class="sect4">
<h5 id="imagewrite">image::write</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: #009900">void</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">,</span> <span style="color: #008080">element_type</span> color<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Writes a color value to location specified by coordinates from non-multisample image.
If <em>cl_khr_mipmap_image_writes</em> extension is present may perform writes also to the mipmap layer 0.
The coordinates must be between 0 and image size in that dimension non inclusive.</p></div>
<div class="paragraph"><p>Based on the parameters with which image was created on host side the function will perform appropriate data format conversions before writing a color value.</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> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">,</span> <span style="color: #008080">element_type</span> color<span style="color: #990000">,</span> <span style="color: #009900">int</span> lod<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Writes a color value to location specified by coordinates and lod from mipmap image.
The coordinates must be between 0 and image size in that dimension non inclusive.</p></div>
<div class="paragraph"><p>Method is present if <em>cl_khr_mipmap_image</em> extension is enabled.</p></div>
<div class="paragraph"><p>Based on the parameters with which image was created on host side the function will perform appropriate data format conversions before writing a color value.</p></div>
<div class="paragraph"><p>The <span class="monospaced">image::write</span> functions that take an image object where <span class="monospaced">T</span> is a floating-point type can only be used with image objects created with <span class="monospaced">image_channel_type</span> set to one of the pre-defined packed formats or set to:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">image_channel_type::snorm_int8</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::unorm_int8</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::snorm_int16</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::unorm_int16</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::float16</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::float32</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>The <span class="monospaced">image::write</span> functions that take an image object where <span class="monospaced">T</span> is a signed integer type can only be used with image objects created with:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">image_channel_type::sint8</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::sint16</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::sint32</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>The <span class="monospaced">image::write</span> functions that take an image object where <span class="monospaced">T</span> is an unsigned integer type can only be used with image objects created with:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">image_channel_type::uint8</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::uint16</span>
</p>
</li>
<li>
<p>
<span class="monospaced">image_channel_type::uint32</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>The behavior of <span class="monospaced">image::write</span> for image objects created with
<span class="monospaced">image_channel_type</span> values not specified in the description above is undefined.</p></div>
</div>
<div class="sect4">
<h5 id="imageoperator">image::operator[]</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">pixel</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">integer_coord</span> coord<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">pixel</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">integer_coord</span> coord<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>Creates a pixel which can be used to read or/and write operation(s).
It depends on image_access specified in the image.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">The pixel stores a reference to image and coordinates.
This operation can consume more private memory than <span class="monospaced">image::read</span> and <span class="monospaced">image::write</span> methods.
It can also negatively impact performance.</td>
</tr></table>
</div>
</div>
<div class="sect4">
<h5 id="imagepixeloperator-element_type">image::pixel::operator element_type</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">element_type</span> pixel<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">element_type</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>Reads a color value from non-multisample image without sampler and integral coordinates specified in pixel.
If <em>cl_khr_mipmap_image</em> extension is present may perform reads also from mipmap layer 0.</p></div>
<div class="paragraph"><p>This function is similar to <span class="monospaced">image::read</span> method.
Please refer to description of this method for more details.</p></div>
</div>
<div class="sect4">
<h5 id="imagepixeloperator">image::pixel::operator=</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>pixel <span style="color: #990000">&amp;</span> pixel<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span><span style="color: #008080">element_type</span> color<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Writes a color value to location specified by coordinates in pixel from non-multisample image.
If <em>cl_khr_mipmap_image_writes</em> extension is present may perform writes also to the mipmap layer 0.
The coordinates specified in pixel must be between 0 and image size in that dimension non inclusive.</p></div>
<div class="paragraph"><p>Based on the parameters with which image was created on host side the function will perform appropriate data format conversions before writing a color value.</p></div>
<div class="paragraph"><p>This function is similar to <span class="monospaced">image::write</span> method.
Please refer to description of this method for more details.</p></div>
</div>
<div class="sect4">
<h5 id="imagewidth">image::width</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">width</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 width of the image.</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> <span style="font-weight: bold"><span style="color: #000000">width</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> lod<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 width of the mip-level specified by <span class="monospaced">lod</span>.</p></div>
<div class="paragraph"><p>Method is present in the non-multisample image types if <em>cl_khr_mipmap_image</em> extension is enabled.</p></div>
</div>
<div class="sect4">
<h5 id="imageheight">image::height</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">height</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 height of the image.</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> <span style="font-weight: bold"><span style="color: #000000">height</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> lod<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 height of the mip-level specified by <span class="monospaced">lod</span>.</p></div>
<div class="paragraph"><p>Method is present in the non-multisample image types if <em>cl_khr_mipmap_image</em> extension is enabled.</p></div>
</div>
<div class="sect4">
<h5 id="imagedepth">image::depth</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">depth</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 depth of the image.</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> <span style="font-weight: bold"><span style="color: #000000">depth</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> lod<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 depth of the mip-level specified by <span class="monospaced">lod</span>.</p></div>
<div class="paragraph"><p>Method is present in the non-multisample image types if <em>cl_khr_mipmap_image</em> extension is enabled.</p></div>
</div>
<div class="sect4">
<h5 id="imagearray_size">image::array_size</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">array_size</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 size of the image array.</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> <span style="font-weight: bold"><span style="color: #000000">array_size</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> lod<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 size of the image array specified by <span class="monospaced">lod</span>.</p></div>
<div class="paragraph"><p>Method is present in the non-multisample image types if <em>cl_khr_mipmap_image</em> extension is enabled.</p></div>
</div>
<div class="sect4">
<h5 id="imagesize">image::size</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">integer_coord</span> <span style="font-weight: bold"><span style="color: #000000">size</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 appropriately sized vector, or scalar for 1 dimensional images, containing all image dimensions followed by array size.</p></div>
</div>
<div class="sect4">
<h5 id="imagedata_type">image::data_type</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">image_channel_type</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">data_type</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 format of the image as specified upon its creation on host side.</p></div>
</div>
<div class="sect4">
<h5 id="imageorder">image::order</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">image_channel_order</span> image<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">order</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 channel order of the image as specified upon its creation on host side.</p></div>
</div>
<div class="sect4">
<h5 id="imagemiplevels">image::miplevels</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">miplevels</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 number of mipmaps of image.
Method is present if <em>cl_khr_mipmap_image</em> or <em>cl_khr_mipmap_image_writes</em> extension is enabled.</p></div>
</div>
<div class="sect4">
<h5 id="imagenum_samples">image::num_samples</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">num_samples</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>
</div>
<div class="sect3">
<h4 id="sampler">3.11.9. Sampler</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">struct</span></span> <span style="color: #008080">sampler</span><span style="color: #990000">:</span> marker_type
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">sampler</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">sampler</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> sampler<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">sampler</span></span><span style="color: #990000">(</span>sampler<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
sampler<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> sampler<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
sampler<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>sampler<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
sampler<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><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="color: #008080">addressing_mode</span> A<span style="color: #990000">,</span> <span style="color: #008080">normalized_coordinates</span> C<span style="color: #990000">,</span> <span style="color: #008080">filtering_mode</span> F<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">sampler</span> <span style="font-weight: bold"><span style="color: #000000">make_sampler</span></span><span style="color: #990000">();</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>There are only two ways of acquiring a sampler inside of a kernel. One is to pass it as a kernel parameter from host using <span class="monospaced">clSetKernelArg</span>, the other one is to create one using make_sampler function in the kernel code. <span class="monospaced">make_sampler</span> function has three template parameters specifying behavior of sampler. Once acquired sampler can only be passed by reference as all other marker types. The sampler objects at non-program scope must be declared with static specifier.</p></div>
<div class="paragraph"><p>The maximum number of samplers that can be declared in a kernel can be queried using the <span class="monospaced">CL_DEVICE_MAX_SAMPLERS</span> token in <span class="monospaced">clGetDeviceInfo</span>.</p></div>
</div>
<div class="sect3">
<h4 id="sampler-modes">3.11.10. Sampler Modes</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">addressing_mode</span>
<span style="color: #FF0000">{</span>
mirrored_repeat<span style="color: #990000">,</span>
repeat<span style="color: #990000">,</span>
clamp_to_edge<span style="color: #990000">,</span>
clamp<span style="color: #990000">,</span>
none
<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">normalized_coordinates</span>
<span style="color: #FF0000">{</span>
normalized<span style="color: #990000">,</span>
unnormalized
<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">filtering_mode</span>
<span style="color: #FF0000">{</span>
nearest<span style="color: #990000">,</span>
linear
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The following tables describe the inline sampler parameters and their behavior.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 12. Addressing modes</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Addressing mode</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">mirrored_repeat</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Out of range coordinates will be flipped at every integer junction. This addressing mode can only be used with normalized coordinates. If normalized coordinates are not used, this addressing mode may generate image coordinates that are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">repeat</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Out of range image coordinates are wrapped to the valid range. This addressing mode can only be used with normalized coordinates. If normalized coordinates are not used, this addressing mode may generate image coordinates that are undefined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">clamp_to_edge</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Out of range image coordinates are clamped to the extent.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">clamp</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Out of range image coordinates will return a border color.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">none</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For this addressing mode the programmer guarantees that the image coordinates used to sample elements of the image refer to a location inside the image; otherwise the results are undefined.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>For 1D and 2D image arrays, the addressing mode applies only to the <em>x</em> and (<em>x, y</em>) coordinates. The addressing mode for the coordinate which specifies the array index is always clamp_to_edge.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 13. Normalized coordinates</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Normalized Coordinate Values</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">normalized</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Specifies whether the <em>x</em>, <em>y</em> and <em>z</em> coordinates are passed in as normalized values.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">unnormalized</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Specifies whether the <em>x</em>, <em>y</em> and <em>z</em> coordinates are passed in as unnormalized values.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>Sampling from an image with samplers that differ in specification of coordinates normalization result in undefined behavior.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 14. Coordinate filtering modes</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Filtering mode</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">nearest</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Chooses a color of nearest pixel.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">linear</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Performs a linear sampling of adjacent pixels.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>Refer to <em>section 4.2</em> in the OpenCL API specification for a description of these filter modes.</p></div>
</div>
<div class="sect3">
<h4 id="determining-the-border-color-or-value">3.11.11. Determining the border color or value</h4>
<div class="paragraph"><p>If <span class="monospaced">&lt;addressing mode&gt;</span> in sampler is clamp, then out-of-range image coordinates return the border color. The border color selected depends on the image channel order and can be one of the following values:</p></div>
<div class="ulist"><ul>
<li>
<p>
If the image channel order is <span class="monospaced">image_channel_order::a</span>, <span class="monospaced">image_channel_order::intensity</span>, <span class="monospaced">image_channel_order::rx</span>, <span class="monospaced">image_channel_order::ra</span>, <span class="monospaced">image_channel_order::rgx</span>, <span class="monospaced">image_channel_order::rgbx</span>, <span class="monospaced">image_channel_order::srgbx</span>, <span class="monospaced">image_channel_order::argb</span>, <span class="monospaced">image_channel_order::bgra</span>, <span class="monospaced">image_channel_order::abgr</span>, <span class="monospaced">image_channel_order::rgba</span>, <span class="monospaced">image_channel_order::srgba</span> or <span class="monospaced">image_channel_order::sbgra</span>, the border color is (0.0f, 0.0f, 0.0f, 0.0f).
</p>
</li>
<li>
<p>
If the image channel order is <span class="monospaced">image_channel_order::r</span>, <span class="monospaced">image_channel_order::rg</span>, <span class="monospaced">image_channel_order::rgb</span>, or <span class="monospaced">image_channel_order::luminance</span>, the border color is (0.0f, 0.0f, 0.0f, 1.0f).
</p>
</li>
<li>
<p>
If the image channel order is <span class="monospaced">image_channel_order::depth</span>, the border value is 0.0f.
</p>
</li>
</ul></div>
</div>
<div class="sect3">
<h4 id="srgb-images">3.11.12. sRGB Images</h4>
<div class="paragraph"><p>The built-in image read functions perform sRGB to linear RGB conversions if the image is an sRGB image. Writes to sRGB images from a kernel is an optional extension. The <em>cl_khr_srgb_image_writes</em> extension will be reported in the <span class="monospaced">CL_DEVICE_EXTENSIONS</span> string if a device supports writing to sRGB images using <span class="monospaced">image::write</span>. <span class="monospaced">clGetSupportedImageFormats</span> will return the supported sRGB images if <span class="monospaced">CL_MEM_READ_WRITE</span> or <span class="monospaced">CL_MEM_WRITE_ONLY</span> is specified in <span class="monospaced">flags</span> argument and the device supports writing to an sRGB image. If the <em>cl_khr_srgb_image_writes</em> extension is supported and has been enabled, the built-in image write functions perform the linear to sRGB conversion.</p></div>
<div class="paragraph"><p>Only the R, G and B components are converted from linear to sRGB and vice-versa. The alpha component is returned as is.</p></div>
</div>
<div class="sect3">
<h4 id="reading-and-writing-to-the-same-image-in-a-kernel">3.11.13. Reading and writing to the same image in a kernel</h4>
<div class="paragraph"><p>To read and write to the same image in a kernel, the image must be declared with the <span class="monospaced">image_access::read_write</span>. Only sampler-less reads and write functions can be called on an image declared with the <span class="monospaced">image_access::read_write</span> access qualifier. Calling the <span class="monospaced">image::sample</span> functions on an image declared with the <span class="monospaced">image_access::read_write</span> will result in a compilation error.</p></div>
<div class="paragraph"><p>The <span class="monospaced">atomic_fence</span> function from <em><a href="#fences">Atomic Fences</a> section</em> can be used to make sure that writes are visible to later reads by the same work-item. Without use of the <span class="monospaced">atomic_fence</span> function, write-read coherence on image objects is not guaranteed: if a work-item reads from an image to which it has previously written without an intervening atomic_fence, it is not guaranteed that those previous writes are visible to the work-item. Only a scope of <span class="monospaced">memory_order_acq_rel</span> is valid for <span class="monospaced">atomic_fence</span> when passed the <span class="monospaced">mem_fence::image</span> flag. If multiple work-items are writing to and reading from multiple locations in an image, the <span class="monospaced">work_group_barrier</span> from <em><a href="#synchronization-functions">Synchronization Functions</a> section</em> should be used.</p></div>
<div class="paragraph"><p>Consider the following 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-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_atomic&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_image&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">image2d&lt;float4, image_access::read_write&gt;</span> img<span style="color: #990000">,</span> <span style="color: #990000">...</span> <span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">int2</span> coord<span style="color: #990000">;</span>
coord<span style="color: #990000">.</span>x <span style="color: #990000">=</span> <span style="color: #990000">(</span><span style="color: #009900">int</span><span style="color: #990000">)</span><span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span>
coord<span style="color: #990000">.</span>y <span style="color: #990000">=</span> <span style="color: #990000">(</span><span style="color: #009900">int</span><span style="color: #990000">)</span><span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">);</span>
<span style="color: #008080">float4</span> clr <span style="color: #990000">=</span> img<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span>coord<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
img<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span>coord<span style="color: #990000">,</span> clr<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// required to ensure that following read from image at</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// location coord returns the latest color value.</span></span>
<span style="font-weight: bold"><span style="color: #000000">atomic_fence</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>image<span style="color: #990000">,</span>
memory_order_acq_rel<span style="color: #990000">,</span>
memory_scope_work_item<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> clr_new <span style="color: #990000">=</span> img<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span>coord<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="mapping-image-channels-to-color-values-returned-by-imagesample-imageread-and-color-values-passed-to-imagewrite-to-image-channels">3.11.14. Mapping image channels to color values returned by image::sample, image::read and color values passed to image::write to image channels</h4>
<div class="paragraph"><p>The following table describes the mapping of the number of channels of an image element to the appropriate components in the <span class="monospaced">float4</span>, <span class="monospaced">int4</span> or <span class="monospaced">uint4</span> vector data type for the color values returned by <span class="monospaced">image::sample</span>, <span class="monospaced">image::read</span> or supplied to <span class="monospaced">image::write</span>. The unmapped components will be set to 0.0 for red, green and blue channels and will be set to 1.0 for the alpha channel.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 15. Image channel mappings</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Image Channel Order</strong></th>
<th class="tableblock halign-left valign-top" ><strong>float4, int4 or uint4</strong>
<strong>components of channel data</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">r, rx</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(r, 0.0, 0.0, 1.0)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">a</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(0.0, 0.0, 0.0, a)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rg, rgx</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(r, g, 0.0, 1.0)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ra</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(r, 0.0, 0.0, a)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rgb, rgbx, srgb, srgbx</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(r, g, b, 1.0)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rgba, bgra, argb, abgr, srgba, sbgra</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(r, g, b, a)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">intensity</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(I, I, I, I)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">luminance</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">(L, L, L, 1.0)</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>For <span class="monospaced">image_channel_order::depth</span> images, a scalar value is returned by <span class="monospaced">image::sample</span>, <span class="monospaced">image::read</span> or supplied to <span class="monospaced">image::write</span>.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">A kernel that uses a sampler with the clamp addressing mode with multiple images may result in additional samplers being used internally by an implementation. If the same sampler is used with multiple images called via <span class="monospaced">image::sample</span>, then it is possible that an implementation may need to allocate an additional sampler to handle the different border color values that may be needed depending on the image formats being used. The implementation allocated samplers will count against the maximum sampler values supported by the device and given by <span class="monospaced">CL_DEVICE_MAX_SAMPLERS</span>. Enqueuing a kernel that requires more samplers than the implementation can support will result in a <span class="monospaced">CL_OUT_OF_RESOURCES</span> error being returned.</td>
</tr></table>
</div>
</div>
<div class="sect3">
<h4 id="restrictions-4">3.11.15. Restrictions</h4>
<div class="ulist"><ul>
<li>
<p>
The image and sampler types cannot be used with variables declared inside a class or union field, a pointer type, an array, global variables declared at program scope or the return type of a function.
</p>
</li>
<li>
<p>
The image and sampler types cannot be used with the <span class="monospaced">global</span>, <span class="monospaced">local</span>, <span class="monospaced">priv</span> and <span class="monospaced">constant</span> address space storage classes (<em><a href="#explicit-address-space-storage-classes">Explicit address space storage classes</a> section</em>).
</p>
</li>
<li>
<p>
The values returned by applying the <span class="monospaced">sizeof</span> operator to the image and sampler types are implementation-defined.
</p>
</li>
</ul></div>
</div>
<div class="sect3">
<h4 id="examples-5">3.11.16. Examples</h4>
<div class="sect4">
<h5 id="example-1-5">Example 1</h5>
<div class="paragraph"><p>The example how to use an image object with sampler-less reads.</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_image&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">image2d&lt;float4, image_access::read&gt;</span> img<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">int2</span> coord<span style="color: #990000">;</span>
coord<span style="color: #990000">.</span>x <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span>
coord<span style="color: #990000">.</span>y <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">);</span>
<span style="color: #008080">float4</span> val <span style="color: #990000">=</span> img<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span>coord<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-2-3">Example 2</h5>
<div class="paragraph"><p>The example how to use an image object with <span class="monospaced">image_access::read_write</span> access and <span class="monospaced">atomic_fence</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_image&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_atomic&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">image2d&lt;float4, image_access::read_write&gt;</span> img<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">int2</span> coord<span style="color: #990000">;</span>
coord<span style="color: #990000">.</span>x <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span>
coord<span style="color: #990000">.</span>y <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">);</span>
<span style="color: #008080">float4</span> val1<span style="color: #FF0000">{</span><span style="color: #993399">0</span><span style="color: #990000">.</span>5f<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
img<span style="color: #990000">[</span>coord<span style="color: #990000">]</span> <span style="color: #990000">=</span> val1<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic_fence</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>image<span style="color: #990000">,</span> memory_order_acq_rel<span style="color: #990000">,</span>
memory_scope_work_item<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> val2 <span style="color: #990000">=</span> img<span style="color: #990000">[</span>coord<span style="color: #990000">];</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-3-2">Example 3</h5>
<div class="paragraph"><p>The example how to use an image object with sampler passed by a kernel argument.</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_image&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">image2d&lt;float4, image_access::sample&gt;</span> img<span style="color: #990000">,</span> <span style="color: #008080">sampler</span> s<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">int2</span> coord<span style="color: #990000">;</span>
coord<span style="color: #990000">.</span>x <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span>
coord<span style="color: #990000">.</span>y <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">);</span>
<span style="color: #008080">float4</span> val <span style="color: #990000">=</span> img<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span>s<span style="color: #990000">,</span> coord<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-4-1">Example 4</h5>
<div class="paragraph"><p>The example how to use an image object with sampler declared at program scope.</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_image&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">sampler</span> s <span style="color: #990000">=</span> make_sampler<span style="color: #990000">&lt;</span>addressing_mode<span style="color: #990000">::</span>clamp<span style="color: #990000">,</span>
normalized_coordinates<span style="color: #990000">::</span>unnormalized<span style="color: #990000">,</span>
filtering_mode<span style="color: #990000">::</span>nearest<span style="color: #990000">&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><span style="color: #008080">image2d&lt;float4, image_access::sample&gt;</span> img<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">int2</span> coord<span style="color: #990000">;</span>
coord<span style="color: #990000">.</span>x <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span>
coord<span style="color: #990000">.</span>y <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">1</span><span style="color: #990000">);</span>
<span style="color: #008080">float4</span> val <span style="color: #990000">=</span> img<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span>s<span style="color: #990000">,</span> coord<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-5-1">Example 5</h5>
<div class="paragraph"><p>The example how to use an image object with sampler declared at non-program scope.</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_image&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">image2d&lt;float4, image_access::sample&gt;</span> img<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #008080">int2</span> coord<span style="color: #990000">;</span>
coord<span style="color: #990000">.</span>x <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span>
coord<span style="color: #990000">.</span>y <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</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">static</span></span> <span style="color: #008080">sampler</span> s <span style="color: #990000">=</span> make_sampler<span style="color: #990000">&lt;</span>addressing_mode<span style="color: #990000">::</span>clamp<span style="color: #990000">,</span>
normalized_coordinates<span style="color: #990000">::</span>unnormalized<span style="color: #990000">,</span>
filtering_mode<span style="color: #990000">::</span>nearest<span style="color: #990000">&gt;();</span>
<span style="color: #008080">float4</span> val <span style="color: #990000">=</span> img<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">sample</span></span><span style="color: #990000">(</span>s<span style="color: #990000">,</span> coord<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="pipes-library">3.12. Pipes Library</h3>
<div class="paragraph"><p>Header <em>&lt;opencl_pipe&gt;</em> defines <span class="monospaced">pipe</span> and <span class="monospaced">pipe_storage</span> template classes.
<span class="monospaced">pipe</span> and <span class="monospaced">pipe_storage</span> can be used as a communication channel between kernels.
<span class="monospaced">pipe</span>, <span class="monospaced">reservation</span> and <span class="monospaced">pipe_storage</span> template classes follow all the rules for marker types as specified in <em><a href="#marker-types">Marker Types</a> section</em>.</p></div>
<div class="sect3">
<h4 id="pipe-host-type">3.12.1. Pipe Host Type</h4>
<div class="paragraph"><p>The below describes the OpenCL pipe data type and the corresponding data type available to the application:</p></div>
<table class="tableblock frame-all grid-all" id="host_pipe_type"
style="
width:100%;
">
<caption class="title">Table 16. Host pipe type</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type in OpenCL C++</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">cl::pipe</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_pipe</span></p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="header-opencl_pipe-synopsis">3.12.2. Header &lt;opencl_pipe&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">pipe_access</span> <span style="color: #FF0000">{</span> read<span style="color: #990000">,</span> write <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="color: #008080">pipe_access</span> Access <span style="color: #990000">=</span> pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">pipe</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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">pipe_storage</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="color: #008080">pipe_access</span> Access <span style="color: #990000">=</span> pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">,</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">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">pipe&lt;T, Access&gt;</span> <span style="font-weight: bold"><span style="color: #000000">make_pipe</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> pipe_storage<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> N<span style="color: #990000">&gt;&amp;</span> ps<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="pipe-class-specializations">3.12.3. pipe class specializations</h4>
<div class="paragraph"><p><span class="monospaced">pipe</span> class has two distinct specializations depending on <span class="monospaced">pipe_access</span> parameter defined as follows:</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">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="color: #008080">pipe_access</span> Access <span style="color: #990000">=</span> pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">pipe</span><span style="color: #990000">:</span> marker_type
<span style="color: #FF0000">{</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">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">pipe_access</span> access <span style="color: #990000">=</span> Access<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="color: #008080">memory_scope</span> S<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">reservation</span><span style="color: #990000">:</span> marker_type
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">reservation</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">reservation</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reservation<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">reservation</span></span><span style="color: #990000">(</span>reservation<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
reservation<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> reservation<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
reservation<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>reservation<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
reservation<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_valid</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> index<span style="color: #990000">,</span> T<span style="color: #990000">&amp;</span> ref<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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">commit</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: #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="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">pipe</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">pipe</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> pipe<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">pipe</span></span><span style="color: #990000">(</span>pipe<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
pipe<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> pipe<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
pipe<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>pipe<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
pipe<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;</span> ref<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">reservation&lt;memory_scope_work_item&gt;</span> <span style="font-weight: bold"><span style="color: #000000">reserve</span></span><span style="color: #990000">(</span>
<span style="color: #008080">uint</span> num_packets<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">reservation&lt;memory_scope_work_group&gt;</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reserve</span></span><span style="color: #990000">(</span>
<span style="color: #008080">uint</span> num_packets<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">reservation&lt;memory_scope_sub_group&gt;</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reserve</span></span><span style="color: #990000">(</span>
<span style="color: #008080">uint</span> num_packets<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">uint</span> <span style="font-weight: bold"><span style="color: #000000">num_packets</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">uint</span> <span style="font-weight: bold"><span style="color: #000000">max_packets</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: #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">struct</span></span> <span style="color: #008080">pipe</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> pipe_access<span style="color: #990000">::</span>write<span style="color: #990000">&gt;:</span> marker_type
<span style="color: #FF0000">{</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">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">pipe_access</span> access <span style="color: #990000">=</span> pipe_access<span style="color: #990000">::</span>write<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="color: #008080">memory_scope</span> S<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">reservation</span><span style="color: #990000">:</span> marker_type
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">reservation</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">reservation</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reservation <span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">reservation</span></span><span style="color: #990000">(</span>reservation <span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
reservation<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> reservation <span style="color: #990000">&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
reservation<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>reservation <span style="color: #990000">&amp;&amp;)</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
reservation<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_valid</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> index<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</span> ref<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">commit</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: #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="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">pipe</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">pipe</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> pipe<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">pipe</span></span><span style="color: #990000">(</span>pipe<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
pipe<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> pipe<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
pipe<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>pipe<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
pipe<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</span> ref<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">reservation&lt;memory_scope_work_item&gt;</span> <span style="font-weight: bold"><span style="color: #000000">reserve</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_packets<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">reservation&lt;memory_scope_work_group&gt;</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reserve</span></span><span style="color: #990000">(</span>
<span style="color: #008080">uint</span> num_packets<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">reservation&lt;memory_scope_sub_group&gt;</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reserve</span></span><span style="color: #990000">(</span>
<span style="color: #008080">uint</span> num_packets<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">num_packets</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">uint</span> <span style="font-weight: bold"><span style="color: #000000">max_packets</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: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="pipe-class-methods">3.12.4. pipe class methods</h4>
<div class="sect4">
<h5 id="piperead">pipe::read</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;</span> ref<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>Read packet from pipe into <span class="monospaced">ref</span>.</p></div>
<div class="paragraph"><p>Returns <span class="monospaced">true</span> if read is successful and <span class="monospaced">false</span> if the pipe is empty.</p></div>
</div>
<div class="sect4">
<h5 id="pipewrite">pipe::write</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</span> ref<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Write packet specified by <span class="monospaced">ref</span> to pipe.
Returns <span class="monospaced">true</span> if write is successful and <span class="monospaced">false</span> if the pipe is full.</p></div>
</div>
<div class="sect4">
<h5 id="pipereserve">pipe::reserve</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">reservation</span> <span style="font-weight: bold"><span style="color: #000000">reserve</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_packets<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">reservation</span> <span style="font-weight: bold"><span style="color: #000000">reserve</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_packets<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Reserve <span class="monospaced">num_packets</span> entries for reading/writing from/to pipe.
Returns a valid reservation if the reservation is successful.</p></div>
<div class="paragraph"><p>The reserved pipe entries are referred to by indices that go from <span class="monospaced">0 &#8230; num_packets - 1</span>.</p></div>
</div>
<div class="sect4">
<h5 id="pipework_group_reserve">pipe::work_group_reserve</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">reservation</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reserve</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_packets<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">reservation</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reserve</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_packets<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Reserve <span class="monospaced">num_packets</span> entries for reading/writing from/to pipe.
Returns a valid reservation if the reservation is successful.</p></div>
<div class="paragraph"><p>The reserved pipe entries are referred to by indices that go from <span class="monospaced">0 &#8230; num_packets - 1</span>.</p></div>
</div>
<div class="sect4">
<h5 id="pipesub_group_reserve">pipe::sub_group_reserve</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">reservation</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reserve</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_packets<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">reservation</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reserve</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_packets<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Reserve <span class="monospaced">num_packets</span> entries for reading/writing from/to pipe.
Returns a valid reservation if the reservation is successful.</p></div>
<div class="paragraph"><p>The reserved pipe entries are referred to by indices that go from <span class="monospaced">0 &#8230; num_packets - 1</span>.</p></div>
</div>
<div class="sect4">
<h5 id="pipenum_packets">pipe::num_packets</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">uint</span> <span style="font-weight: bold"><span style="color: #000000">num_packets</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 current number of packets that have been written to the pipe, but have not yet been read from the pipe.
The number of available entries in a pipe is a dynamic value.
The value returned should be considered immediately stale.</p></div>
</div>
<div class="sect4">
<h5 id="pipemax_packets">pipe::max_packets</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">uint</span> <span style="font-weight: bold"><span style="color: #000000">max_packets</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 maximum number of packets specified when pipe was created.</p></div>
</div>
<div class="sect4">
<h5 id="pipereservationread">pipe::reservation::read</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: #009900">bool</span> pipe<span style="color: #990000">::</span>reservation<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> index<span style="color: #990000">,</span> T<span style="color: #990000">&amp;</span> ref<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>Read packet from the reserved area of the pipe referred to by <span class="monospaced">index</span> into <span class="monospaced">ref</span>.</p></div>
<div class="paragraph"><p>The reserved pipe entries are referred to by indices that go from <span class="monospaced">0 &#8230; num_packets - 1</span>.</p></div>
<div class="paragraph"><p>Returns <span class="monospaced">true</span> if read is successful and <span class="monospaced">false</span> otherwise.</p></div>
</div>
<div class="sect4">
<h5 id="pipereservationwrite">pipe::reservation::write</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: #009900">bool</span> pipe<span style="color: #990000">::</span>reservation<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> index<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;</span> ref<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Write packet specified by <span class="monospaced">ref</span> to the reserved area of the pipe referred to by <span class="monospaced">index</span>.</p></div>
<div class="paragraph"><p>The reserved pipe entries are referred to by indices that go from <span class="monospaced">0 &#8230; num_packets - 1</span>.</p></div>
<div class="paragraph"><p>Returns <span class="monospaced">true</span> if write is successful and <span class="monospaced">false</span> otherwise.</p></div>
</div>
<div class="sect4">
<h5 id="pipereservationcommit">pipe::reservation::commit</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: #009900">void</span> pipe<span style="color: #990000">::</span>reservation<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">commit</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: #009900">void</span> pipe<span style="color: #990000">::</span>reservation<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">commit</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Indicates that all reads/writes to <span class="monospaced">num_packets</span> associated with reservation are completed.</p></div>
</div>
<div class="sect4">
<h5 id="pipereservationis_valid">pipe::reservation::is_valid</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: #009900">bool</span> pipe<span style="color: #990000">::</span>reservation<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">is_valid</span></span><span style="color: #990000">();</span></tt></pre></div></div>
<div class="paragraph"><p>Return <span class="monospaced">true</span> if reservation is a valid reservation and <span class="monospaced">false</span> otherwise.</p></div>
</div>
<div class="sect4">
<h5 id="pipereservationoperator-bool">pipe::reservation::operator bool</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">explicit</span></span> pipe<span style="color: #990000">::</span>reservation<span style="color: #990000">::</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>Return <span class="monospaced">true</span> if reservation is a valid reservation and <span class="monospaced">false</span> otherwise.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="pipe_storage-class">3.12.5. pipe_storage class</h4>
<div class="paragraph"><p>The lifetime of <span class="monospaced">pipe_storage</span> objects is the same as a program where they were declared.
The variables of such type are not shared across devices.</p></div>
<div class="paragraph"><p><span class="monospaced">N</span> in the <span class="monospaced">pipe_storage</span> template class specifies the maximum number of packets which can be held by an object.</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">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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">pipe_storage</span><span style="color: #990000">:</span> marker_type
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">pipe_storage</span></span><span style="color: #990000">();</span>
<span style="font-weight: bold"><span style="color: #000000">pipe_storage</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> pipe_storage<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">pipe_storage</span></span><span style="color: #990000">(</span>pipe_storage<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
pipe_storage<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> pipe_storage<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
pipe_storage<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>pipe_storage<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
pipe_storage<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></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="color: #008080">pipe_access</span> Access <span style="color: #990000">=</span> pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="color: #008080">pipe&lt;T, Access&gt;</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: #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="color: #008080">pipe_access</span> Access <span style="color: #990000">=</span> pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">,</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">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">pipe&lt;T, Access&gt;</span> <span style="font-weight: bold"><span style="color: #000000">make_pipe</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> pipe_storage<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> N<span style="color: #990000">&gt;&amp;</span> ps<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="pipe_storage-class-methods-and-make_pipe-function">3.12.6. pipe_storage class methods and make_pipe function</h4>
<div class="sect4">
<h5 id="pipe_storageget">pipe_storage::get</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="color: #008080">pipe_access</span> Access <span style="color: #990000">=</span> pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;</span>
<span style="color: #008080">pipe&lt;T, Access&gt;</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Constructs a read only or write only pipe from <span class="monospaced">pipe_storage</span> object.
One kernel can have only one pipe accessor associated with one <span class="monospaced">pipe_storage</span> object.</p></div>
</div>
<div class="sect4">
<h5 id="make_pipe">make_pipe</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="color: #008080">pipe_access</span> Access <span style="color: #990000">=</span> pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">,</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">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">pipe&lt;T, Access&gt;</span> <span style="font-weight: bold"><span style="color: #000000">make_pipe</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> pipe_storage<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> N<span style="color: #990000">&gt;&amp;</span> ps<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Constructs a read only or write only pipe from <span class="monospaced">pipe_storage</span> object.
One kernel can have only one pipe accessor associated with one <span class="monospaced">pipe_storage</span> object.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="operations-ordering-using-reservations">3.12.7. Operations ordering using reservations</h4>
<div class="paragraph"><p>The <span class="monospaced">reservation::read</span> and <span class="monospaced">reservation::write</span> pipe functions can be used to read from or write to a packet index.
These functions can be used to read from or write to a packet index one or multiple times.
If a packet index that is reserved for writing is not written to using the <span class="monospaced">reservation::write</span> method, the contents of that packet in the pipe are undefined.
<span class="monospaced">reservation::commit</span> remove the entries reserved for reading from the pipe.
<span class="monospaced">reservation::commit</span> ensures that the entries reserved for writing are all added in-order as one contiguous set of packets to the pipe.</p></div>
<div class="paragraph"><p>There can only be <span class="monospaced">CL_DEVICE_PIPE_MAX_ACTIVE_RESERVATIONS</span> (refer to <em>Table 4.3</em>) reservations active (i.e. reservations that have been reserved but not committed) per work-item or work-group for a pipe in a kernel executing on a device.</p></div>
<div class="paragraph"><p>Work-item based reservations made by a work-item are ordered in the pipe as they are ordered in the program.
Reservations made by different work-items that belong to the same work-group can be ordered using the work-group barrier function.
The order of work-item based reservations that belong to different work-groups is implementation defined.</p></div>
<div class="paragraph"><p>Work-group based reservations made by a work-group are ordered in the pipe as they are ordered in the program.
The order of work-group based reservations by different work-groups is implementation defined.</p></div>
</div>
<div class="sect3">
<h4 id="requirements">3.12.8. Requirements</h4>
<div class="sect4">
<h5 id="data">Data</h5>
<div class="paragraph"><p>Template parameter <span class="monospaced">T</span> in <span class="monospaced">pipe</span> and <span class="monospaced">pipe_storage</span> class template denotes the data type stored in pipe.
The type <span class="monospaced">T</span> must be a POD type i.e. satisfy <span class="monospaced">is_pod&lt;T&gt;::value == true</span>.</p></div>
</div>
<div class="sect4">
<h5 id="work-group-operations">Work-group operations</h5>
<div class="paragraph"><p>All work-group specific functions must be encountered by all work items in a work-group executing the kernel with the same argument values, otherwise the behavior is undefined.</p></div>
</div>
<div class="sect4">
<h5 id="sub-group-operations">Sub-group operations</h5>
<div class="paragraph"><p>All sub-group specific functions must be encountered by all work items in a sub-group executing the kernel with the same argument values, otherwise the behavior is undefined.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="restrictions-5">3.12.9. Restrictions</h4>
<div class="sect4">
<h5 id="pipe">pipe</h5>
<div class="ulist"><ul>
<li>
<p>
The <span class="monospaced">pipe</span> type cannot be used with variables declared inside a class or union field, a pointer type, an array, global variables declared at program scope or the return type of a function.
</p>
</li>
<li>
<p>
A kernel cannot read from and write to the same pipe object.
</p>
</li>
<li>
<p>
The <span class="monospaced">pipe</span> type cannot be used with the <span class="monospaced">global</span>, <span class="monospaced">local</span>, <span class="monospaced">priv</span> and <span class="monospaced">constant</span> address space storage classes (<em><a href="#explicit-address-space-storage-classes">Explicit address space storage classes</a> section</em>).
</p>
</li>
<li>
<p>
The value returned by applying the <span class="monospaced">sizeof</span> operator to the <span class="monospaced">pipe</span> type is implementation-defined.
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="reservation">reservation</h5>
<div class="ulist"><ul>
<li>
<p>
The <span class="monospaced">reservation</span> type cannot be used with variables declared inside a class or union field, a pointer type, an array, global variables declared at program scope or the return type of a function.
</p>
</li>
<li>
<p>
The <span class="monospaced">reservation</span> type cannot be used with the <span class="monospaced">global</span>, <span class="monospaced">local</span>, <span class="monospaced">priv</span> and <span class="monospaced">constant</span> address space storage classes (<em><a href="#explicit-address-space-storage-classes">Explicit address space storage classes</a> section</em>).
</p>
</li>
<li>
<p>
The value returned by applying the <span class="monospaced">sizeof</span> operator to the <span class="monospaced">reservation</span> type is implementation-defined.
</p>
</li>
</ul></div>
<div class="paragraph"><p>The following behavior is undefined:</p></div>
<div class="ulist"><ul>
<li>
<p>
A kernel calls <span class="monospaced">reservation::read</span> or <span class="monospaced">reservation::write</span> with a valid reservation but with an index that is not a value from <span class="monospaced">0 &#8230; num_packets - 1</span> specified to the corresponding call to <span class="monospaced">pipe::reserve</span>, <span class="monospaced">pipe::work_group_reserve</span> or <span class="monospaced">pipe::sub_group_reserve</span>.
</p>
</li>
<li>
<p>
A kernel calls <span class="monospaced">reservation::read</span> or <span class="monospaced">reservation::write</span> with a reservation that has already been committed (i.e. a <span class="monospaced">reservation::commit</span> with this reservation has already been called).
</p>
</li>
<li>
<p>
The contents of the reserved data packets in the pipe are undefined if the kernel does not call <span class="monospaced">reservation::write</span> for all entries that were reserved by the corresponding call to <span class="monospaced">pipe::reserve</span>, <span class="monospaced">pipe::work_group_reserve</span> or <span class="monospaced">pipe::sub_group_reserve</span>.
</p>
</li>
<li>
<p>
Calls to <span class="monospaced">reservation::read</span> and <span class="monospaced">reservation::commit</span> or <span class="monospaced">reservation::write</span> and <span class="monospaced">reservation::commit</span> for a given reservation must be called by the same kernel that made the reservation using <span class="monospaced">pipe::reserve</span>, <span class="monospaced">pipe::work_group_reserve</span> or <span class="monospaced">pipe::sub_group_reserve</span>. The reservation cannot be passed to another kernel including child kernels.
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="pipe_storage">pipe_storage</h5>
<div class="ulist"><ul>
<li>
<p>
Variables of type <span class="monospaced">pipe_storage</span> can only be declared at program scope or with the static specifier.
</p>
</li>
<li>
<p>
The <span class="monospaced">pipe_storage</span> type cannot be used as a class or union field, a pointer type, an array or the return type of a function.
</p>
</li>
<li>
<p>
The <span class="monospaced">pipe_storage</span> type cannot be used with the <span class="monospaced">global</span>, <span class="monospaced">local</span>, <span class="monospaced">priv</span> and <span class="monospaced">constant</span> address space storage classes (<em><a href="#explicit-address-space-storage-classes">Explicit address space storage classes</a> section</em>).
</p>
</li>
<li>
<p>
The value returned by applying the <span class="monospaced">sizeof</span> operator to the <span class="monospaced">pipe_storage</span> type is implementation-defined.
</p>
</li>
<li>
<p>
Variables of type <span class="monospaced">pipe</span> created from <span class="monospaced">pipe_storage</span> can only be declared inside a kernel function at kernel scope.
</p>
</li>
</ul></div>
<div class="paragraph"><p>The following behavior is undefined:</p></div>
<div class="ulist"><ul>
<li>
<p>
A kernel cannot contain more than one <span class="monospaced">pipe</span> accessor made from one <span class="monospaced">pipe_storage</span> object. Otherwise behavior is undefined.
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect3">
<h4 id="examples-6">3.12.10. Examples</h4>
<div class="sect4">
<h5 id="example-1-6">Example 1</h5>
<div class="paragraph"><p>Example of reading from a pipe object.</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_pipe&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">reader</span></span><span style="color: #990000">(</span><span style="color: #008080">pipe&lt;int&gt;</span> p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> val<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>p<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span>val<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>
<div class="sect4">
<h5 id="example-2-4">Example 2</h5>
<div class="paragraph"><p>Example of writing to a pipe object.</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_pipe&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">writer</span></span><span style="color: #990000">(</span><span style="color: #008080">pipe&lt;int, pipe_access::write&gt;</span> p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #009900">int</span> val<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>p<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><span style="color: #990000">(</span>val<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>
<div class="sect4">
<h5 id="example-3-3">Example 3</h5>
<div class="paragraph"><p>Example of reading from a pipe object using reservations.</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_pipe&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">reader</span></span><span style="color: #990000">(</span><span style="color: #008080">pipe&lt;int, pipe_access::read&gt;</span> p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> val<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> rid <span style="color: #990000">=</span> p<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">reserve</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">if</span></span><span style="color: #990000">(</span>rid<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">,</span> val<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>
rid<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">commit</span></span><span style="color: #990000">();</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-4-2">Example 4</h5>
<div class="paragraph"><p>Example of using a pipe_storage object and how to create the pipe objects/accessors from it.</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_pipe&gt;</span>
cl<span style="color: #990000">::</span>pipe_storage <span style="color: #990000">&lt;</span><span style="color: #009900">int</span><span style="color: #990000">,</span> <span style="color: #993399">100</span><span style="color: #990000">&gt;</span> myProgramPipe0<span style="color: #990000">;</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">producer</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
cl<span style="color: #990000">::</span><span style="color: #008080">pipe&lt;int, cl::pipe_access::write&gt;</span> p <span style="color: #990000">=</span>
myProgramPipe0<span style="color: #990000">.</span>get<span style="color: #990000">&lt;</span>cl<span style="color: #990000">::</span>pipe_access<span style="color: #990000">::</span>write<span style="color: #990000">&gt;();</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
p<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><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">consumer</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
cl<span style="color: #990000">::</span><span style="color: #008080">pipe&lt;int, cl::pipe_access::read&gt;</span> p <span style="color: #990000">=</span>
myProgramPipe0<span style="color: #990000">.</span>get<span style="color: #990000">&lt;</span>cl<span style="color: #990000">::</span>pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;();</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>p<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</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>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-5-2">Example 5</h5>
<div class="paragraph"><p>Example of using more than one pipe_storage object.</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_pipe&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">pipe_storage&lt;int2, 20&gt;</span> myProgramPipe2<span style="color: #990000">;</span>
<span style="color: #008080">pipe_storage&lt;float, 40&gt;</span> myProgramPipe3<span style="color: #990000">;</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">input</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> p <span style="color: #990000">=</span> make_pipe<span style="color: #990000">&lt;</span>pipe_access<span style="color: #990000">::</span>write<span style="color: #990000">&gt;(</span>myProgramPipe2<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
p<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><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">processor</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> p_in <span style="color: #990000">=</span> make_pipe<span style="color: #990000">&lt;</span>pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;(</span>myProgramPipe2<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> p_out <span style="color: #990000">=</span> make_pipe<span style="color: #990000">&lt;</span>pipe_access<span style="color: #990000">::</span>write<span style="color: #990000">&gt;(</span>myProgramPipe3<span style="color: #990000">);</span>
<span style="color: #990000">...</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>p_in<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</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>
p_out<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">write</span></span><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">output</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> p <span style="color: #990000">=</span> make_pipe<span style="color: #990000">&lt;</span>pipe_access<span style="color: #990000">::</span>read<span style="color: #990000">&gt;(</span>myProgramPipe3<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">if</span></span><span style="color: #990000">(</span>p<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">read</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>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="device-enqueue-library">3.13. Device Enqueue Library</h3>
<div class="paragraph"><p>OpenCL C++ device enqueue functionality allows a kernel to enqueue the same device, without host interaction.
A kernel may enqueue code represented by lambda syntax, and control execution order with event dependencies including user events and markers.
<span class="monospaced">device_queue</span> follows all the rules for marker types as specified in <em><a href="#marker-types">Marker Types</a> section</em>.</p></div>
<div class="sect3">
<h4 id="queue-host-type">3.13.1. Queue Host Type</h4>
<div class="paragraph"><p>The below table describes the OpenCL queue data type and the corresponding data type available to the application:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 17. Host queue type</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Type in OpenCL C++</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">cl::device_queue</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">cl_queue</span></p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="header-opencl_device_queue-synopsis">3.13.2. Header &lt;opencl_device_queue&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">enqueue_status</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">enqueue_policy</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">event_status</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">event_profiling_info</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">event</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">event</span></span><span style="color: #990000">();</span>
<span style="font-weight: bold"><span style="color: #000000">event</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> event<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">event</span></span><span style="color: #990000">(</span>event<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
event<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> event<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
event<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>event<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_valid</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">retain</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">release</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: #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="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">set_status</span></span><span style="color: #990000">(</span><span style="color: #008080">event_status</span> status<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">profiling_info</span></span><span style="color: #990000">(</span><span style="color: #008080">event_profiling_info</span> name<span style="color: #990000">,</span>
<span style="color: #008080">global_ptr&lt;long&gt;</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #008080">event</span> <span style="font-weight: bold"><span style="color: #000000">make_user_event</span></span><span style="color: #990000">();</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">ndrange</span>
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">explicit</span></span> <span style="font-weight: bold"><span style="color: #000000">ndrange</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> global_work_size<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">ndrange</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> global_work_size<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_work_size<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">ndrange</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> global_work_offset<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> global_work_size<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_work_size<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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #000000">ndrange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #000000">size_t</span></span> <span style="color: #990000">(&amp;</span>global_work_size<span style="color: #990000">)[</span>N<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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #000000">ndrange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #000000">size_t</span></span> <span style="color: #990000">(&amp;</span>global_work_size<span style="color: #990000">)[</span>N<span style="color: #990000">],</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #000000">size_t</span></span> <span style="color: #990000">(&amp;</span>local_work_size<span style="color: #990000">)[</span>N<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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #000000">ndrange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #000000">size_t</span></span> <span style="color: #990000">(&amp;</span>global_work_offset<span style="color: #990000">)[</span>N<span style="color: #990000">],</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #000000">size_t</span></span> <span style="color: #990000">(&amp;</span>global_work_size<span style="color: #990000">)[</span>N<span style="color: #990000">],</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #000000">size_t</span></span> <span style="color: #990000">(&amp;</span>local_work_size<span style="color: #990000">)[</span>N<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">struct</span></span> <span style="color: #008080">device_queue</span><span style="color: #990000">:</span> marker_type
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">device_queue</span></span><span style="color: #990000">()</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">device_queue</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> device_queue<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">device_queue</span></span><span style="color: #990000">(</span>device_queue<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
device_queue<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> device_queue<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
device_queue<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>device_queue<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
device_queue<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">enqueue_status</span> <span style="font-weight: bold"><span style="color: #000000">enqueue_kernel</span></span><span style="color: #990000">(</span><span style="color: #008080">enqueue_policy</span> flag<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">ndrange</span> <span style="color: #990000">&amp;</span>ndrange<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">enqueue_status</span> <span style="font-weight: bold"><span style="color: #000000">enqueue_kernel</span></span><span style="color: #990000">(</span><span style="color: #008080">enqueue_policy</span> flag<span style="color: #990000">,</span>
<span style="color: #008080">uint</span> num_events_in_wait_list<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">event</span> <span style="color: #990000">*</span>event_wait_list<span style="color: #990000">,</span>
<span style="color: #008080">event</span> <span style="color: #990000">*</span>event_ret<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">ndrange</span> <span style="color: #990000">&amp;</span>ndrange<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">enqueue_status</span> <span style="font-weight: bold"><span style="color: #000000">enqueue_marker</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_events_in_wait_list<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">event</span> <span style="color: #990000">*</span>event_wait_list<span style="color: #990000">,</span>
<span style="color: #008080">event</span> <span style="color: #990000">*</span>event_ret<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #008080">device_queue</span> <span style="font-weight: bold"><span style="color: #000000">get_default_device_queue</span></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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_work_group_size</span></span><span style="color: #990000">(</span><span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span> Args<span style="color: #990000">...</span> args<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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_preferred_work_group_size_multiple</span></span><span style="color: #990000">(</span><span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_sub_group_count_for_ndrange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">ndrange</span> <span style="color: #990000">&amp;</span>ndrange<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_max_sub_group_size_for_ndrange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">ndrange</span> <span style="color: #990000">&amp;</span>ndrange<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_local_size_for_sub_group_count</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_sub_groups<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_max_num_sub_groups</span></span><span style="color: #990000">(</span><span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span> Args<span style="color: #990000">...</span> args<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="device_queue-class-methods">3.13.3. device_queue class methods</h4>
<div class="paragraph"><p><span class="monospaced">device_queue</span> object represents work queue of the device.
Device queue meets all requirements of the marker types as in <em><a href="#marker-types">Marker Types</a> section</em>.</p></div>
<div class="sect4">
<h5 id="enqueue_kernel">device_queue::enqueue_kernel</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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">enqueue_status</span> <span style="font-weight: bold"><span style="color: #000000">enqueue_kernel</span></span><span style="color: #990000">(</span><span style="color: #008080">enqueue_policy</span> policy<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">ndrange</span> <span style="color: #990000">&amp;</span>ndrange<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>This method allows to enqueue functor or lambda <span class="monospaced">fun</span> on the device with specified <span class="monospaced">policy</span> over the specified <span class="monospaced">ndrange</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">args</span> are the arguments that will be passed to <span class="monospaced">fun</span> when kernel will be enqueued with the exception for <span class="monospaced">local_ptr</span> parameters.
For local pointers user must supply the size of local memory that will be allocated using <span class="monospaced">local_ptr&lt;T&gt;::size_type{num elements}</span>.
Please see examples how to use <span class="monospaced">enqueue_kernel</span> are in <em><a href="#examples-7">Examples</a> section</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="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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">enqueue_status</span> <span style="font-weight: bold"><span style="color: #000000">enqueue_kernel</span></span><span style="color: #990000">(</span><span style="color: #008080">enqueue_policy</span> policy<span style="color: #990000">,</span>
<span style="color: #008080">uint</span> num_events_in_wait_list<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">event</span> <span style="color: #990000">*</span>event_wait_list<span style="color: #990000">,</span>
<span style="color: #008080">event</span> <span style="color: #990000">*</span>event_ret<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">ndrange</span> <span style="color: #990000">&amp;</span>ndrange<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>This method enqueues functor or lambda <span class="monospaced">fun</span> in the same way as the overload above with the exception for the passed event list.
If an event is returned, <span class="monospaced">enqueue_kernel</span> performs an implicit retain on the returned event.</p></div>
</div>
<div class="sect4">
<h5 id="enqueue_marker">device_queue::enqueue_marker</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">enqueue_status</span> <span style="font-weight: bold"><span style="color: #000000">enqueue_marker</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_events_in_wait_list<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">event</span> <span style="color: #990000">*</span>event_wait_list<span style="color: #990000">,</span>
<span style="color: #008080">event</span> <span style="color: #990000">*</span>event_ret<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>This method enqueues a marker to device queue.
The marker command waits for a list of events specified by <span class="monospaced">event_wait_list</span> to complete before the marker completes.
<span class="monospaced">event_ret</span> must not be <span class="monospaced">nullptr</span> as otherwise this is a no-op.</p></div>
<div class="paragraph"><p>If an event is returned, <span class="monospaced">enqueue_marker</span> performs an implicit retain on the returned event.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="event-class-methods">3.13.4. event class methods</h4>
<div class="sect4">
<h5 id="is_valid">event::is_valid</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_valid</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">true</span> if event object is a valid event.
Otherwise returns <span class="monospaced">false</span>.</p></div>
</div>
<div class="sect4">
<h5 id="operator-bool">event::operator bool</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">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">true</span> if event object is a valid event.
Otherwise returns <span class="monospaced">false</span>.</p></div>
</div>
<div class="sect4">
<h5 id="retain">event::retain</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">retain</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Increments the event reference count.
Event must be an event returned by <span class="monospaced">enqueue_kernel</span> or <span class="monospaced">enqueue_marker</span> or a user event.</p></div>
</div>
<div class="sect4">
<h5 id="release">event::release</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: #009900">void</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>Decrements the event reference count.
The event object is deleted once the event reference count is zero, the specific command identified by this event has completed (or terminated) and there are no commands in any device command queue that require a wait for this event to complete.
Event must be an event returned by <span class="monospaced">enqueue_kernel</span>, <span class="monospaced">enqueue_marker</span> or a user event.</p></div>
</div>
<div class="sect4">
<h5 id="set_status">event::set_status</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">set_status</span></span><span style="color: #990000">(</span><span style="color: #008080">event_status</span> status<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Sets the execution status of a user event.
Event must be a user event.
<span class="monospaced">status</span> can be either <span class="monospaced">event_status::complete</span> or <span class="monospaced">event_status::error</span> value indicating an error.</p></div>
</div>
<div class="sect4">
<h5 id="profiling_info">event::profiling_info</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">profiling_info</span></span><span style="color: #990000">(</span><span style="color: #008080">event_profiling_info</span> name<span style="color: #990000">,</span>
<span style="color: #008080">global_ptr&lt;long&gt;</span> value<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Captures the profiling information for functions that are enqueued as commands.
The specific function being referred to is: <span class="monospaced">enqueue_kernel</span>.
These enqueued commands are identified by unique event objects.
The profiling information will be available in <span class="monospaced">value</span> once the command identified by event has completed.
Event must be an event returned by <span class="monospaced">enqueue_kernel</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">name</span> identifies which profiling information is to be queried and can be:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">event_profiling_info::exec_time</span>
</p>
<div class="paragraph"><p><span class="monospaced">value</span> is a pointer to two 64-bit values.</p></div>
<div class="paragraph"><p>The first 64-bit value describes the elapsed time <span class="monospaced">CL_PROFILING_COMMAND_END - CL_PROFILING_COMMAND_START</span> for the command identified by event in nanoseconds.</p></div>
<div class="paragraph"><p>The second 64-bit value describes the elapsed time <span class="monospaced">CL_PROFILING_COMMAND_COMPLETE - CL_PROFILING_COMMAND_START</span> for the command identified by event in nanoseconds.</p></div>
</li>
</ul></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content"><span class="monospaced">profiling_info</span> when called multiple times for the same event is undefined.</td>
</tr></table>
</div>
</div>
</div>
<div class="sect3">
<h4 id="other-operations">3.13.5. Other operations</h4>
<div class="sect4">
<h5 id="get_default_device_queue">get_default_device_queue</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">device_queue</span> <span style="font-weight: bold"><span style="color: #000000">get_default_device_queue</span></span><span style="color: #990000">();</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the default device queue.
If a default device queue has not been created, <span class="monospaced">device_queue::is_valid()</span> will return <span class="monospaced">false</span>.</p></div>
</div>
<div class="sect4">
<h5 id="make_user_event">make_user_event</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">event</span> <span style="font-weight: bold"><span style="color: #000000">make_user_event</span></span><span style="color: #990000">();</span></tt></pre></div></div>
<div class="paragraph"><p>Creates a user event.
Returns the user event.
The execution status of the user event created is set to <span class="monospaced">event_status::submitted</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_kernel_work_group_size">get_kernel_work_group_size</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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_work_group_size</span></span><span style="color: #990000">(</span><span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span> Args<span style="color: #990000">...</span> args<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>This provides a mechanism to query the maximum work-group size that can be used to execute a functor on the current device.</p></div>
<div class="paragraph"><p><span class="monospaced">fun</span> specifies the functor representing the kernel code that would be enqueued.</p></div>
<div class="paragraph"><p><span class="monospaced">args</span> are the arguments that will be passed to <span class="monospaced">fun</span> when kernel will be enqueued with the exception for <span class="monospaced">local_ptr</span> parameters.
For local pointers user must supply the size of local memory that will be allocated.</p></div>
</div>
<div class="sect4">
<h5 id="get_kernel_preferred_work_group_size_multiple">get_kernel_preferred_work_group_size_multiple</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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_preferred_work_group_size_multiple</span></span><span style="color: #990000">(</span><span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the preferred multiple of work-group size for launch.
This is a performance hint.
Specifying a work-group size that is not a multiple of the value returned by this query as the value of the local work size argument to enqueue will not fail to enqueue the functor for execution unless the work-group size specified is larger than the device maximum.</p></div>
<div class="paragraph"><p><span class="monospaced">fun</span> specifies the functor representing the kernel code that would be enqueued.</p></div>
<div class="paragraph"><p><span class="monospaced">args</span> are the arguments that will be passed to <span class="monospaced">fun</span> when kernel will be enqueued with the exception for <span class="monospaced">local_ptr</span> parameters.
For local pointers user must supply the size of local memory that will be allocated.</p></div>
</div>
<div class="sect4">
<h5 id="get_kernel_sub_group_count_for_ndrange">get_kernel_sub_group_count_for_ndrange</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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_sub_group_count_for_ndrange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">ndrange</span> <span style="color: #990000">&amp;</span>ndrange<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the number of sub-groups in each work-group of the dispatch (except for the last in cases where the global size does not divide cleanly into work-groups) given the combination of the passed ndrange and functor.</p></div>
<div class="paragraph"><p><span class="monospaced">fun</span> specifies the functor representing the kernel code that would be enqueued.</p></div>
<div class="paragraph"><p><span class="monospaced">args</span> are the arguments that will be passed to <span class="monospaced">fun</span> when kernel will be enqueued with the exception for <span class="monospaced">local_ptr</span> parameters.
For local pointers user must supply the size of local memory that will be allocated.</p></div>
</div>
<div class="sect4">
<h5 id="get_kernel_max_sub_group_size_for_ndrange">get_kernel_max_sub_group_size_for_ndrange</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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_max_sub_group_size_for_ndrange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">ndrange</span> <span style="color: #990000">&amp;</span>ndrange<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the maximum sub-group size for a functor.</p></div>
<div class="paragraph"><p><span class="monospaced">fun</span> specifies the functor representing the kernel code that would be enqueued.</p></div>
<div class="paragraph"><p><span class="monospaced">args</span> are the arguments that will be passed to <span class="monospaced">fun</span> when kernel will be enqueued with the exception for <span class="monospaced">local_ptr</span> parameters.
For local pointers user must supply the size of local memory that will be allocated.</p></div>
</div>
<div class="sect4">
<h5 id="get_kernel_local_size_for_sub_group_count">get_kernel_local_size_for_sub_group_count</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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_local_size_for_sub_group_count</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> num_sub_groups<span style="color: #990000">,</span>
<span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span>
Args<span style="color: #990000">...</span> args<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns a valid local size that would produce the requested number of sub-groups such that each sub-group is complete with no partial sub-groups.</p></div>
<div class="paragraph"><p><span class="monospaced">fun</span> specifies the functor representing the kernel code that would be enqueued.</p></div>
<div class="paragraph"><p><span class="monospaced">args</span> are the arguments that will be passed to <span class="monospaced">fun</span> when kernel will be enqueued with the exception for <span class="monospaced">local_ptr</span> parameters.
For local pointers user must supply the size of local memory that will be allocated.</p></div>
</div>
<div class="sect4">
<h5 id="get_kernel_max_num_sub_groups">get_kernel_max_num_sub_groups</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">Fun</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Args<span style="color: #990000">&gt;</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_kernel_max_num_sub_groups</span></span><span style="color: #990000">(</span><span style="color: #008080">Fun</span> fun<span style="color: #990000">,</span> Args<span style="color: #990000">...</span> args<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Provides a mechanism to query the maximum number of sub-groups that can be used to execute the passed functor on the current device.</p></div>
<div class="paragraph"><p><span class="monospaced">fun</span> specifies the functor representing the kernel code that would be enqueued.</p></div>
<div class="paragraph"><p><span class="monospaced">args</span> are the arguments that will be passed to <span class="monospaced">fun</span> when kernel will be enqueued with the exception for <span class="monospaced">local_ptr</span> parameters.
For local pointers user must supply the size of local memory that will be allocated.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="ndrange">3.13.6. ndrange</h4>
<div class="paragraph"><p><span class="monospaced">ndrange</span> type is used to represent the size of the enqueued workload.
The dimension of the workload ranges from 1 to 3.
User can specify global work size, local work size and global work offset.
Unspecified parameters are defaulted to 0.</p></div>
</div>
<div class="sect3">
<h4 id="enqueue-policy">3.13.7. Enqueue policy</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">enum</span></span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">enqueue_policy</span>
<span style="color: #FF0000">{</span>
no_wait<span style="color: #990000">,</span>
wait_kernel<span style="color: #990000">,</span>
wait_work_group
<span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Enqueue policy enumerable is used to specify launch policy of enqueued kernel.
It is defined as follows:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 18. Enqueue policy</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Policy</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">no_wait</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Indicates that the enqueued kernels do not need to wait for the parent kernel to finish execution before they begin execution.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">wait_kernel</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Indicates that all work-items of the parent kernel must finish executing and all immediate <a href="#ftn14">[14</a>] side effects committed before the enqueued child kernel may begin execution.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">wait_work_group</span> <a href="#ftn15">[15</a>]</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Indicates that the enqueued kernels wait only for the work-group that enqueued the kernels to finish before they begin execution.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="enqueue-status">3.13.8. Enqueue status</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">enum</span></span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">enqueue_status</span>
<span style="color: #FF0000">{</span>
success<span style="color: #990000">,</span>
failure<span style="color: #990000">,</span>
invalid_queue<span style="color: #990000">,</span>
invalid_ndrange<span style="color: #990000">,</span>
invalid_event_wait_list<span style="color: #990000">,</span>
queue_full<span style="color: #990000">,</span>
invalid_arg_size<span style="color: #990000">,</span>
event_allocation_failure<span style="color: #990000">,</span>
out_of_resources
<span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>The <span class="monospaced">enqueue_kernel</span> and <span class="monospaced">enqueue_marker</span> methods return <span class="monospaced">enqueue_status::success</span> if the command is enqueued successfully and return <span class="monospaced">enqueue_status::failure</span> otherwise.
If the <em>-g</em> compile option is specified in compiler options passed to <span class="monospaced">clBuildProgram</span>, the other errors may be returned instead of <span class="monospaced">enqueue_status::failure</span> to indicate why <span class="monospaced">enqueue_kernel</span> or <span class="monospaced">enqueue_marker</span> failed.
Enqueue status is defined as follows:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 19. Enqueue status</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Status</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">success</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">failure</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">invalid_queue</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>queue</em> is not a valid device queue.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">invalid_ndrange</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If <span class="monospaced">ndrange</span> is not a valid ND-range descriptor or if the program was compiled with <em>-cl-uniform-work-group-size</em> and the local work size is specified in <span class="monospaced">ndrange</span> but the global work size specified in <span class="monospaced">ndrange</span> is not a multiple of the local work size.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">invalid_event_wait_list</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If <span class="monospaced">event_wait_list</span> is <span class="monospaced">nullptr</span> and <span class="monospaced">num_events_in_wait_list</span> &gt; 0, or if <span class="monospaced">event_wait_list</span> is not <span class="monospaced">nullptr</span> and <span class="monospaced">num_events_in_wait_list</span> is 0, or if <span class="monospaced">event</span> objects in <span class="monospaced">event_wait_list</span> are not valid events.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">queue_full</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If <em>queue</em> is full.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">invalid_arg_size</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If size of local memory arguments is 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">event_allocation_failure</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If <span class="monospaced">event_ret</span> is not <span class="monospaced">nullptr</span> and an event could not be allocated.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">out_of_resources</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If there is a failure to queue the kernel in <em>queue</em> because of insufficient resources needed to execute the kernel.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="event-status">3.13.9. Event status</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">enum</span></span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">event_status</span>
<span style="color: #FF0000">{</span>
submitted<span style="color: #990000">,</span>
complete<span style="color: #990000">,</span>
error<span style="color: #990000">,</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Event status enumerable is used to set a user event status.
It is defined as follows:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 20. Event status</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Status</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">submitted</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Initial status of a user event</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">complete</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">error</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Status indicating an error</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="determining-when-a-parent-kernel-has-finished-execution">3.13.10. Determining when a parent kernel has finished execution</h4>
<div class="paragraph"><p>A parent kernel&#8217;s execution status is considered to be complete when it and all its child kernels have finished execution.
The execution status of a parent kernel will be <span class="monospaced">event_status::complete</span> if this kernel and all its child kernels finish execution successfully.
The execution status of the kernel will be <span class="monospaced">event_status::error</span> if it or any of its child kernels encounter an error, or are abnormally terminated.</p></div>
<div class="paragraph"><p>For example, assume that the host enqueues a kernel <span class="monospaced">k</span> for execution on a device.
Kernel <span class="monospaced">k</span> when executing on the device enqueues kernels <span class="monospaced">A</span> and <span class="monospaced">B</span> to a device queue(s).
The <span class="monospaced">enqueue_kernel</span> call to enqueue kernel <span class="monospaced">B</span> specifies the event associated with kernel <span class="monospaced">A</span> in the <span class="monospaced">event_wait_list</span> argument i.e. wait for kernel <span class="monospaced">A</span> to finish execution before kernel <span class="monospaced">B</span> can begin execution.
Let&#8217;s assume kernel <span class="monospaced">A</span> enqueues kernels <span class="monospaced">X</span>, <span class="monospaced">Y</span> and <span class="monospaced">Z</span>.
Kernel <span class="monospaced">A</span> is considered to have finished execution i.e. its execution status is <span class="monospaced">event_status::complete</span> only after <span class="monospaced">A</span> and the kernels <span class="monospaced">A</span> enqueued (and any kernels these enqueued kernels enqueue and so on) have finished execution.</p></div>
</div>
<div class="sect3">
<h4 id="event-profiling-info">3.13.11. Event profiling info</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">enum</span></span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">event_profiling_info</span>
<span style="color: #FF0000">{</span>
exec_time<span style="color: #990000">,</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Event profiling info enumerable is used to determine the outcome of <span class="monospaced">event::profiling_info</span> function.
It is defined as follows:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 21. Event profiling info</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Status</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">exec_time</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Identifies profiling information to be queried.
If specified, the two 64-bit values are returned</p>
<p class="tableblock">The first 64-bit value describes the elapsed time: <span class="monospaced">CL_PROFILING_COMMAND_END - CL_PROFILING_COMMAND_START</span> for the command identified by event in nanoseconds.</p>
<p class="tableblock">The second 64-bit value describes the elapsed time <span class="monospaced">CL_PROFILING_COMMAND_COMPLETE - CL_PROFILING_COMMAND_START</span> for the command identified by event in nanoseconds.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="requirements-1">3.13.12. Requirements</h4>
<div class="paragraph"><p>Functor and lambda objects passed to <span class="monospaced">enqueue_kernel</span> method of device queue has to follow specific restrictions:</p></div>
<div class="ulist"><ul>
<li>
<p>
It has to be trivially copyable.
</p>
</li>
<li>
<p>
It has to be trivially copy constructible.
</p>
</li>
<li>
<p>
It has to be trivially destructible.
</p>
</li>
</ul></div>
<div class="paragraph"><p>Code enqueuing function objects that do not meet this criteria is ill-formed.</p></div>
<div class="sect4">
<h5 id="pointers-references-and-marker-types">Pointers, references and marker types</h5>
<div class="paragraph"><p>Functors that are enqueued cannot have any reference and pointer fields, nor can have fields of marker types.
If object containing such fields is enqueued the behavior is undefined.</p></div>
<div class="paragraph"><p>The same restrictions apply to <em>capture-list</em> variables in lambda.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">This requirements are caused by the fact that kernel may be enqueued after parent kernel terminated all pointers and references will be invalidated by then.</td>
</tr></table>
</div>
</div>
<div class="sect4">
<h5 id="events">Events</h5>
<div class="paragraph"><p>Events can be used to identify commands enqueued to a command-queue from the host.
These events created by the OpenCL runtime can only be used on the host i.e. as events passed in <span class="monospaced">event_wait_list</span> argument to various <span class="monospaced">clEnqueue</span>* APIs or runtime APIs that take events as arguments such as <span class="monospaced">clRetainEvent</span>, <span class="monospaced">clReleaseEvent</span>, <span class="monospaced">clGetEventProfilingInfo</span>.</p></div>
<div class="paragraph"><p>Similarly, events can be used to identify commands enqueued to a device queue (from a kernel).
These event objects cannot be passed to the host or used by OpenCL runtime APIs such as the <span class="monospaced">clEnqueue</span>* APIs or runtime APIs that take event arguments.</p></div>
<div class="paragraph"><p><span class="monospaced">clRetainEvent</span> and <span class="monospaced">clReleaseEvent</span> will return <span class="monospaced">CL_INVALID_OPERATION</span> if event specified is an event that refers to any kernel enqueued to a device queue using <span class="monospaced">enqueue_kernel</span> or <span class="monospaced">enqueue_marker</span> or is a user event created by <span class="monospaced">make_user_event</span>.</p></div>
<div class="paragraph"><p>Similarly, <span class="monospaced">clSetUserEventStatus</span> can only be used to set the execution status of events created using <span class="monospaced">clCreateUserEvent</span>.
User events created on the device can be set using <span class="monospaced">event::set_status</span> method.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="restrictions-6">3.13.13. Restrictions</h4>
<div class="ulist"><ul>
<li>
<p>
The <span class="monospaced">device_queue</span> type cannot be used with variables declared inside a class or union field, a pointer type, an array, global variables declared at program scope or the return type of a function.
</p>
</li>
<li>
<p>
The <span class="monospaced">event</span> type cannot be used with variables declared inside a class or union field, global variables declared at program scope or the return type of a function.
</p>
</li>
<li>
<p>
The <span class="monospaced">event</span> and <span class="monospaced">device_queue</span> type cannot be used with the <span class="monospaced">global</span>, <span class="monospaced">local</span>, <span class="monospaced">priv</span> and <span class="monospaced">constant</span> address space storage classes (<em><a href="#explicit-address-space-storage-classes">Explicit address space storage classes</a> section</em>).
</p>
</li>
<li>
<p>
The values returned by applying the <span class="monospaced">sizeof</span> operator to the <span class="monospaced">device_queue</span> and <span class="monospaced">event</span> types is implementation-defined.
</p>
</li>
</ul></div>
</div>
<div class="sect3">
<h4 id="examples-7">3.13.14. Examples</h4>
<div class="sect4">
<h5 id="example-1-7">Example 1</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: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_device_queue&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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="font-weight: bold"><span style="color: #0000FF">auto</span></span> q <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_default_device_queue</span></span><span style="color: #990000">();</span>
q<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">enqueue_kernel</span></span><span style="color: #990000">(</span>enqueue_policy<span style="color: #990000">::</span>no_wait<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #000000">ndrange</span></span><span style="color: #990000">(</span> <span style="color: #993399">1</span> <span style="color: #990000">),</span>
<span style="color: #990000">[]()</span><span style="color: #FF0000">{</span> <span style="color: #008080">uint</span> tid <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><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 class="sect4">
<h5 id="example-2-5">Example 2</h5>
<div class="paragraph"><p>Example of using the explicit local pointer class with <span class="monospaced">enqueue_kernel</span> method.</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_device_queue&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">device_queue</span> q<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> lambda <span style="color: #990000">=</span> <span style="color: #990000">[](</span><span style="color: #008080">local_ptr&lt;ushort16&gt;</span> p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="color: #008080">uint</span> tid <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span> <span style="color: #FF0000">}</span><span style="color: #990000">;</span>
q<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">enqueue_kernel</span></span><span style="color: #990000">(</span>enqueue_policy<span style="color: #990000">::</span>no_wait<span style="color: #990000">,</span>
ndrange<span style="color: #FF0000">{</span><span style="color: #993399">1</span><span style="color: #FF0000">}</span><span style="color: #990000">,</span>
lambda<span style="color: #990000">,</span>
local_ptr<span style="color: #990000">&lt;</span>ushort16<span style="color: #990000">&gt;::</span>size_type<span style="color: #FF0000">{</span><span style="color: #993399">1</span><span style="color: #FF0000">}</span><span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="example-3-4">Example 3</h5>
<div class="paragraph"><p>Example of enqueuing a functor to a <span class="monospaced">device_queue</span> object.</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_device_queue&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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">Lambda</span> <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">typename</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: #0000FF">operator</span></span> <span style="color: #990000">()(</span><span style="color: #008080">T</span> t<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #FF0000">{</span> <span style="color: #008080">uint</span> tid <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">);</span> <span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span><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">device_queue</span> q<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> lambda <span style="color: #990000">=</span> Lambda<span style="color: #FF0000">{}</span><span style="color: #990000">;</span>
q<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">enqueue_kernel</span></span><span style="color: #990000">(</span>enqueue_policy<span style="color: #990000">::</span>no_wait<span style="color: #990000">,</span>
ndrange<span style="color: #FF0000">{</span><span style="color: #993399">1</span><span style="color: #FF0000">}</span><span style="color: #990000">,</span>
lambda<span style="color: #990000">,</span>
local_ptr<span style="color: #990000">&lt;</span>ushort16<span style="color: #990000">&gt;::</span>size_type<span style="color: #FF0000">{</span><span style="color: #993399">1</span><span style="color: #FF0000">}</span><span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="work-item-functions">3.14. Work-Item Functions</h3>
<div class="paragraph"><p>This section describes the library of work-item functions that can be used to query the number of dimensions, the global and local work size specified to <span class="monospaced">clEnqueueNDRangeKernel</span>, and the global and local identifier of each work-item when this kernel is being executed on a device.</p></div>
<div class="sect3">
<h4 id="header-opencl_work_item-synopsis">3.14.1. Header &lt;opencl_work_item&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="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_work_dim</span></span><span style="color: #990000">();</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_global_size</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">);</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">);</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_local_size</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">);</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_enqueued_local_size</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">);</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">);</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_num_groups</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">);</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_group_id</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">);</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_global_offset</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">);</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_global_linear_id</span></span><span style="color: #990000">();</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_local_linear_id</span></span><span style="color: #990000">();</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_sub_group_size</span></span><span style="color: #990000">();</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_max_sub_group_size</span></span><span style="color: #990000">();</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_num_sub_groups</span></span><span style="color: #990000">();</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_enqueued_num_sub_groups</span></span><span style="color: #990000">();</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_sub_group_id</span></span><span style="color: #990000">();</span>
<span style="color: #008080">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_sub_group_local_id</span></span><span style="color: #990000">();</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="work-item-operations">3.14.2. Work item operations</h4>
<div class="sect4">
<h5 id="get_work_dim">get_work_dim</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">uint</span> <span style="font-weight: bold"><span style="color: #000000">get_work_dim</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the number of dimensions in use.
This is the value given to the <span class="monospaced">work_dim</span> argument specified in <span class="monospaced">clEnqueueNDRangeKernel</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_global_size">get_global_size</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_global_size</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the number of global work-items specified for dimension identified by <span class="monospaced">dimindx</span>.
This value is given by the <span class="monospaced">global_work_size</span> argument to <span class="monospaced">clEnqueueNDRangeKernel</span>.
Valid values of dimindx are <span class="monospaced">0</span> to <span class="monospaced">get_work_dim()-1</span>.
For other values of <span class="monospaced">dimindx</span>, <span class="monospaced">get_global_size()</span> returns <span class="monospaced">1</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_global_id">get_global_id</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_global_id</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the unique global work-item ID value for dimension identified by <span class="monospaced">dimindx</span>.
The global work-item ID specifies the work-item ID based on the number of global work-items specified to execute the kernel.
Valid values of <span class="monospaced">dimindx</span> are <span class="monospaced">0</span> to <span class="monospaced">get_work_dim()-1</span>.
For other values of <span class="monospaced">dimindx</span>, <span class="monospaced">get_global_id()</span> returns <span class="monospaced">0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_local_size">get_local_size</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_local_size</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the number of local work-items specified in dimension identified by <span class="monospaced">dimindx</span>.
This value is at most the value given by the <span class="monospaced">local_work_size</span> argument to <span class="monospaced">clEnqueueNDRangeKernel</span> if <span class="monospaced">local_work_size</span> is not <span class="monospaced">NULL</span>; otherwise the OpenCL implementation chooses an appropriate <span class="monospaced">local_work_size</span> value which is returned by this function.
If the kernel is executed with a non-uniform work-group size <a href="#ftn19">[19</a>], calls to this built-in from some work-groups may return different values than calls to this built-in from other work-groups.</p></div>
<div class="paragraph"><p>Valid values of <span class="monospaced">dimindx</span> are <span class="monospaced">0</span> to <span class="monospaced">get_work_dim()-1</span>.
For other values of <span class="monospaced">dimindx</span>, <span class="monospaced">get_local_size()</span> returns <span class="monospaced">1</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_enqueued_local_size">get_enqueued_local_size</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_enqueued_local_size</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the same value as that returned by <span class="monospaced">get_local_size(dimindx)</span> if the kernel is executed with a uniform work-group size.</p></div>
<div class="paragraph"><p>If the kernel is executed with a non-uniform work-group size, returns the number of local work-items in each of the work-groups that make up the uniform region of the global range in the dimension identified by <span class="monospaced">dimindx</span>.
If the <span class="monospaced">local_work_size</span> argument to <span class="monospaced">clEnqueueNDRangeKernel</span> is not <span class="monospaced">NULL</span>, this value will match the value specified in <span class="monospaced">local_work_size[dimindx]</span>.
If <span class="monospaced">local_work_size</span> is <span class="monospaced">NULL</span>, this value will match the local size that the implementation determined would be most efficient at implementing the uniform region of the global range.</p></div>
<div class="paragraph"><p>Valid values of <span class="monospaced">dimindx</span> are <span class="monospaced">0</span> to <span class="monospaced">get_work_dim()-1</span>.
For other values of <span class="monospaced">dimindx</span>, <span class="monospaced">get_enqueued_local_size()</span> returns <span class="monospaced">1</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_local_id">get_local_id</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the unique local work-item ID i.e. a work-item within a specific work-group for dimension identified by <span class="monospaced">dimindx</span>.
Valid values of <span class="monospaced">dimindx</span> are <span class="monospaced">0</span> to <span class="monospaced">get_work_dim()-1</span>.
For other values of <span class="monospaced">dimindx</span>, <span class="monospaced">get_local_id()</span> returns <span class="monospaced">0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_num_groups">get_num_groups</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_num_groups</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the number of work-groups that will execute a kernel for dimension identified by <span class="monospaced">dimindx</span>.
Valid values of <span class="monospaced">dimindx</span> are <span class="monospaced">0</span> to <span class="monospaced">get_work_dim()-1</span>.
For other values of <span class="monospaced">dimindx</span>, <span class="monospaced">get_num_groups()</span> returns <span class="monospaced">1</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_group_id">get_group_id</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_group_id</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p><span class="monospaced">get_group_id</span> returns the work-group ID which is a number from <span class="monospaced">0 &#8230; get_num_groups(dimindx)-1</span>.
Valid values of <span class="monospaced">dimindx</span> are <span class="monospaced">0</span> to <span class="monospaced">get_work_dim()-1</span>.
For other values, <span class="monospaced">get_group_id()</span> returns <span class="monospaced">0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_global_offset">get_global_offset</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_global_offset</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> dimindx<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p><span class="monospaced">get_global_offset</span> returns the offset values specified in <span class="monospaced">global_work_offset</span> argument to <span class="monospaced">clEnqueueNDRangeKernel</span>.
Valid values of <span class="monospaced">dimindx</span> are <span class="monospaced">0</span> to <span class="monospaced">get_work_dim()-1</span>.
For other values, <span class="monospaced">get_global_offset()</span> returns <span class="monospaced">0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_global_linear_id">get_global_linear_id</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_global_linear_id</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the work-items 1-dimensional global ID.</p></div>
<div class="paragraph"><p>For 1D work-groups, it is computed as:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">get_global_id(0) - get_global_offset(0)</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>For 2D work-groups, it is computed as:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">( get_global_id(1) - get_global_offset(1)) * get_global_size(0) + (get_global_id(0) - get_global_offset(0) )</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>For 3D work-groups, it is computed as:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">( (get_global_id(2) - get_global_offset(2) ) * get_global_size(1) * get_global_size(0)) + ( (get_global_id(1) - get_global_offset(1) ) * get_global_size (0) ) + ( get_global_id(0) - get_global_offset(0) )</span>.
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="get_local_linear_id">get_local_linear_id</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_local_linear_id</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the work-items 1-dimensional local ID.</p></div>
<div class="paragraph"><p>For 1D work-groups, it is the same value as:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">get_local_id(0)</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>For 2D work-groups, it is computed as:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">get_local_id(1) * get_local_size(0) + get_local_id(0)</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>For 3D work-groups, it is computed as:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">(get_local_id(2) * get_local_size(1) * get_local_size(0)) + (get_local_id(1) * get_local_size(0)) + get_local_id(0)</span>
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="get_sub_group_size">get_sub_group_size</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_sub_group_size</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the number of work-items in the sub-group.
This value is no more than the maximum sub-group size and is implementation-defined based on a combination of the compiled kernel and the dispatch dimensions.
This will be a constant value for the lifetime of the sub-group.</p></div>
</div>
<div class="sect4">
<h5 id="get_max_sub_group_size">get_max_sub_group_size</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_max_sub_group_size</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the maximum size of a sub-group within the dispatch.
This value will be invariant for a given set of dispatch dimensions and a kernel object compiled for a given device.</p></div>
</div>
<div class="sect4">
<h5 id="get_num_sub_groups">get_num_sub_groups</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_num_sub_groups</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the number of sub-groups that the current work-group is divided into.</p></div>
<div class="paragraph"><p>This number will be constant for the duration of a work-group&#8217;s execution.
If the kernel is executed with a non-uniform work-group size <a href="#ftn17">[17</a>] values for any dimension, calls to this built-in from some work-groups may return different values than calls to this built-in from other work-groups.</p></div>
</div>
<div class="sect4">
<h5 id="get_enqueued_num_sub_groups">get_enqueued_num_sub_groups</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_enqueued_num_sub_groups</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the same value as that returned by <span class="monospaced">get_num_sub_groups()</span> if the kernel is executed with a uniform work-group size.</p></div>
<div class="paragraph"><p>If the kernel is executed with a non-uniform work-group size, returns the number of sub groups in each of the work groups that make up the uniform region of the global range.</p></div>
</div>
<div class="sect4">
<h5 id="get_sub_group_id">get_sub_group_id</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_sub_group_id</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p><span class="monospaced">get_sub_group_id()</span> returns the sub-group ID which is a number from <span class="monospaced">0 &#8230; get_num_sub_groups()-1</span>.</p></div>
<div class="paragraph"><p>For <span class="monospaced">clEnqueueTask</span>, this returns <span class="monospaced">0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="get_sub_group_local_id">get_sub_group_local_id</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">size_t</span> <span style="font-weight: bold"><span style="color: #000000">get_sub_group_local_id</span></span><span style="color: #990000">()</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the unique work-item ID within the current sub-group.
The mapping from <span class="monospaced">get_local_id(dimindx)</span> to <span class="monospaced">get_sub_group_local_id()</span> will be invariant for the lifetime of the work-group.</p></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="work-group-functions">3.15. Work-group Functions</h3>
<div class="paragraph"><p>The OpenCL C++ library implements the following functions that operate on a work-group level.
These built-in functions must be encountered by all work-items in a work-group executing the kernel.</p></div>
<div class="paragraph"><p>Here <span class="monospaced">gentype</span> matches: <span class="monospaced">int</span>, <span class="monospaced">uint</span>, <span class="monospaced">long</span>, <span class="monospaced">ulong</span>, <span class="monospaced">float</span>, <span class="monospaced">half</span> <a href="#ftn4">[4</a>] or <span class="monospaced">double</span> <a href="#ftn18">[18</a>].</p></div>
<div class="sect3">
<h4 id="header-opencl_work_group-synopsis">3.15.1. Header &lt;opencl_work_group&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">work_group_op</span> <span style="color: #FF0000">{</span> add<span style="color: #990000">,</span> min<span style="color: #990000">,</span> max <span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//logical operations</span></span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">work_group_all</span></span><span style="color: #990000">(</span><span style="color: #009900">bool</span> predicate<span style="color: #990000">);</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">work_group_any</span></span><span style="color: #990000">(</span><span style="color: #009900">bool</span> predicate<span style="color: #990000">);</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_all</span></span><span style="color: #990000">(</span><span style="color: #009900">bool</span> predicate<span style="color: #990000">);</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_any</span></span><span style="color: #990000">(</span><span style="color: #009900">bool</span> predicate<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//broadcast functions</span></span>
<span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id<span style="color: #990000">);</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id<span style="color: #990000">);</span>
<span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id<span style="color: #990000">);</span>
<span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id<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="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">);</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">);</span>
<span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">);</span>
<span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<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="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_z<span style="color: #990000">);</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_z<span style="color: #990000">);</span>
<span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_z<span style="color: #990000">);</span>
<span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_z<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_z<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_z<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="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_z<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> sub_group_local_id<span style="color: #990000">);</span>
<span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> sub_group_local_id<span style="color: #990000">);</span>
<span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> sub_group_local_id<span style="color: #990000">);</span>
<span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> sub_group_local_id<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> sub_group_local_id<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> sub_group_local_id<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="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> a<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> sub_group_local_id<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-style: italic"><span style="color: #9A1900">//numeric operations</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reduce</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_exclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">uint</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">long</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">long</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">ulong</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> x<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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> x<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">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span> <span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_inclusive</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> x<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="logical-operations">3.15.2. Logical operations</h4>
<div class="sect4">
<h5 id="work_group_all">work_group_all</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">work_group_all</span></span><span style="color: #990000">(</span><span style="color: #009900">bool</span> predicate<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Evaluates <span class="monospaced">predicate</span> for all work-items in the work-group and returns <span class="monospaced">true</span> if <span class="monospaced">predicate</span> evaluates to <span class="monospaced">true</span> for all work-items in the work-group.</p></div>
</div>
<div class="sect4">
<h5 id="work_group_any">work_group_any</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">work_group_any</span></span><span style="color: #990000">(</span><span style="color: #009900">bool</span> predicate<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Evaluates <span class="monospaced">predicate</span> for all work-items in the work-group and returns <span class="monospaced">true</span> if <span class="monospaced">predicate</span> evaluates to <span class="monospaced">true</span> for any work-items in the work-group.</p></div>
</div>
<div class="sect4">
<h5 id="sub_group_all">sub_group_all</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_all</span></span><span style="color: #990000">(</span><span style="color: #009900">bool</span> predicate<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Evaluates <span class="monospaced">predicate</span> for all work-items in the sub-group and returns <span class="monospaced">true</span> value if <span class="monospaced">predicate</span> evaluates to <span class="monospaced">true</span> for all work-items in the sub-group.</p></div>
</div>
<div class="sect4">
<h5 id="sub_group_any">sub_group_any</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_any</span></span><span style="color: #990000">(</span><span style="color: #009900">bool</span> predicate<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>Evaluates <span class="monospaced">predicate</span> for all work-items in the sub-group and returns <span class="monospaced">true</span> value if <span class="monospaced">predicate</span> evaluates to <span class="monospaced">true</span> for any work-items in the sub-group.</p></div>
<div class="paragraph"><p>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-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_group&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: #009900">int</span> <span style="color: #990000">*</span>p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #009900">bool</span> check <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">work_group_all</span></span><span style="color: #990000">(</span>p<span style="color: #990000">[</span><span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)]</span> <span style="color: #990000">==</span> <span style="color: #993399">0</span><span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>In this case <span class="monospaced">work_group_all</span> would return <span class="monospaced">true</span> for all work-items in work-group if all elements in <span class="monospaced">p</span>, in range specified by work-group&#8217;s size, are <span class="monospaced">true</span>.</p></div>
<div class="paragraph"><p>One could achieve similar result by using analogical call to <span class="monospaced">work_group_any</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: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_group&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: #009900">int</span> <span style="color: #990000">*</span>p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #009900">bool</span> check <span style="color: #990000">=</span> <span style="color: #990000">!</span><span style="font-weight: bold"><span style="color: #000000">work_group_any</span></span><span style="color: #990000">(</span>p<span style="color: #990000">[</span><span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)]</span> <span style="color: #990000">!=</span> <span style="color: #993399">0</span><span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
<div class="sect3">
<h4 id="broadcast-functions">3.15.3. Broadcast functions</h4>
<div class="sect4">
<h5 id="work_group_broadcast">work_group_broadcast</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_x<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_y<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> local_id_z<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Broadcast the value of <span class="monospaced">a</span> for work-item identified by <span class="monospaced">local_id</span> to all work-items in the work-group.</p></div>
<div class="paragraph"><p><span class="monospaced">local_id</span> must be the same value for all work-items in the work-group.</p></div>
</div>
<div class="sect4">
<h5 id="sub_group_broadcast">sub_group_broadcast</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_broadcast</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span>
<span style="color: #008080">size_t</span> sub_group_local_id<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Broadcast the value of <span class="monospaced">a</span> for work-item identified by <span class="monospaced">sub_group_local_id</span> (value returned by <span class="monospaced">get_sub_group_local_id</span>) to all work-items in the sub-group.</p></div>
<div class="paragraph"><p><span class="monospaced">sub_group_local_id</span> must be the same value for all work-items in the sub-group.</p></div>
<div class="paragraph"><p>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-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_group&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: #009900">int</span> <span style="color: #990000">*</span>p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #009900">int</span> broadcasted_value <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span>p<span style="color: #990000">[</span><span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)],</span> <span style="color: #993399">0</span><span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>Here we are broadcasting value passed to <span class="monospaced">work_group_broadcast</span> function by work-item with <span class="monospaced">local_id = 0</span> (which is <span class="monospaced">p[0]</span>).
This function will return <span class="monospaced">p[0]</span> for all callers.
Please note that <span class="monospaced">local_id</span> must be the same for all work-items, therefore something like this is 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="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_group&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: #009900">int</span> <span style="color: #990000">*</span>p<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">//...</span></span>
<span style="color: #009900">int</span> broadcasted_value <span style="color: #990000">=</span>
<span style="font-weight: bold"><span style="color: #000000">work_group_broadcast</span></span><span style="color: #990000">(</span>p<span style="color: #990000">[</span><span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)],</span> <span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">));</span>
<span style="font-style: italic"><span style="color: #9A1900">//invalid: second argument has different value</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// for different work-items in work-group</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
<div class="sect3">
<h4 id="numeric-operations">3.15.4. Numeric operations</h4>
<div class="sect4">
<h5 id="work_group_reduce">work_group_reduce</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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">work_group_reduce</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>Return result of reduction operation specified by <span class="monospaced">op</span> for all values of <span class="monospaced">x</span> specified by work-items in a work-group.</p></div>
</div>
<div class="sect4">
<h5 id="work_group_scan_exclusive">work_group_scan_exclusive</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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_exclusive</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>Do an exclusive scan operation specified by <span class="monospaced">op</span> of all values specified by work-items in the work-group.
The scan results are returned for each work-item.</p></div>
<div class="paragraph"><p>The scan order is defined by increasing 1D linear global ID within the work-group.</p></div>
</div>
<div class="sect4">
<h5 id="work_group_scan_inclusive">work_group_scan_inclusive</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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">work_group_scan_inclusive</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>Do an inclusive scan operation specified by <span class="monospaced">op</span> of all values specified by work-items in the work-group.
The scan results are returned for each work-item.</p></div>
<div class="paragraph"><p>The scan order is defined by increasing 1D linear global ID within the work-group.</p></div>
</div>
<div class="sect4">
<h5 id="sub_group_reduce">sub_group_reduce</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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_reduce</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>Return result of reduction operation specified by <span class="monospaced">op</span> for all values of <span class="monospaced">x</span> specified by work-items in a sub-group.</p></div>
</div>
<div class="sect4">
<h5 id="sub_group_scan_exclusive">sub_group_scan_exclusive</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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_exclusive</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>Do an exclusive scan operation specified by <span class="monospaced">op</span> of all values specified by work-items in a sub-group.
The scan results are returned for each work-item.</p></div>
<div class="paragraph"><p>The scan order is defined by increasing 1D linear global ID within the sub-group.</p></div>
</div>
<div class="sect4">
<h5 id="sub_group_scan_inclusive">sub_group_scan_inclusive</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="color: #008080">work_group_op</span> op<span style="color: #990000">&gt;</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_scan_inclusive</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>Do an inclusive scan operation specified by <span class="monospaced">op</span> of all values specified by work-items in a sub-group.
The scan results are returned for each work-item.</p></div>
<div class="paragraph"><p>The scan order is defined by increasing 1D linear global ID within the sub-group.</p></div>
<div class="paragraph"><p>The inclusive scan operation takes a binary operator <span class="monospaced">op</span> with an identity I and n (where n is the size of the work-group) elements [a<sub>0</sub>, a<sub>1</sub>, &#8230; a<sub>n-1</sub>] and returns [a<sub>0</sub>, (a<sub>0</sub> <em>op</em> a<sub>1</sub>), &#8230; (a<sub>0</sub> <em>op</em> a<sub>1</sub> <em>op</em> &#8230; <em>op</em> a<sub>n-1</sub>)].
If <span class="monospaced">op</span> is <span class="monospaced">work_group_op::add</span>, the identity I is 0.
If <span class="monospaced">op</span> is <span class="monospaced">work_group_op::min</span>, the identity I is <span class="monospaced">INT_MAX</span>, <span class="monospaced">UINT_MAX</span>, <span class="monospaced">LONG_MAX</span>, <span class="monospaced">ULONG_MAX</span>, for <span class="monospaced">int</span>, <span class="monospaced">uint</span>, <span class="monospaced">long</span>, <span class="monospaced">ulong</span> types and is <span class="monospaced">+INF</span> for floating-point types.
Similarly if <span class="monospaced">op</span> is <span class="monospaced">work_group_op::max</span>, the identity I is <span class="monospaced">INT_MIN</span>, <span class="monospaced">0</span>, <span class="monospaced">LONG_MIN</span>, <span class="monospaced">0</span> and <span class="monospaced">-INF</span>.</p></div>
<div class="paragraph"><p>Consider the following 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-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_group&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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">foo</span></span><span style="color: #990000">(</span><span style="color: #009900">int</span> <span style="color: #990000">*</span>p<span style="color: #990000">)</span>
<span style="color: #FF0000">{</span>
<span style="color: #009900">int</span> prefix_sum_val <span style="color: #990000">=</span>
work_group_scan_inclusive<span style="color: #990000">&lt;</span>work_group_op<span style="color: #990000">::</span>add<span style="color: #990000">&gt;(</span>
p<span style="color: #990000">[</span><span style="font-weight: bold"><span style="color: #000000">get_local_id</span></span><span style="color: #990000">(</span><span style="color: #993399">0</span><span style="color: #990000">)]);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>For the example above, let&#8217;s assume that the work-group size is 8 and p points to the following elements [3 1 7 0 4 1 6 3].
Work-item 0 calls <span class="monospaced">work_group_scan_inclusive&lt;work_group_op::add&gt;</span> with 3 and returns 3.
Work-item 1 calls <span class="monospaced">work_group_scan_inclusive&lt;work_group_op::add&gt;</span> with 1 and returns 4.
The full set of values returned by <span class="monospaced">work_group_scan_inclusive&lt;work_group_op::add&gt;</span> for work-items 0 &#8230; 7 is [3 4 11 11 15 16 22 25].</p></div>
<div class="paragraph"><p>The exclusive scan operation takes a binary associative operator <span class="monospaced">op</span> with an identity I and n (where n is the size of the work-group) elements [a<sub>0</sub>, a<sub>1</sub>, &#8230; a<sub>n-1</sub>] and returns [I, a<sub>0</sub>, (a<sub>0</sub> <em>op</em> a<sub>1</sub>), &#8230; (a<sub>0</sub> <em>op</em> a<sub>1</sub> <em>op</em> &#8230; <em>op</em> a<sub>n-2</sub>)].
For the example above, the exclusive scan add operation on the ordered set [3 1 7 0 4 1 6 3] would return [0 3 4 11 11 15 16 22].</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">The order of floating-point operations is not guaranteed for the <span class="monospaced">work_group_reduce&lt;op&gt;</span>, <span class="monospaced">work_group_scan_inclusive&lt;op&gt;</span> and <span class="monospaced">work_group_scan_exclusive&lt;op&gt;</span> built-in functions that operate on <span class="monospaced">half</span>, <span class="monospaced">float</span> and <span class="monospaced">double</span> data types.
The order of these floating-point operations is also non-deterministic for a given work-group.</td>
</tr></table>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="synchronization-functions">3.16. Synchronization Functions</h3>
<div class="paragraph"><p>The OpenCL C++ library implements the following synchronization functions.</p></div>
<div class="sect3">
<h4 id="header-opencl_synchronization-synopsis">3.16.1. Header &lt;opencl_synchronization&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="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">work_group_barrier</span></span><span style="color: #990000">(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">,</span>
<span style="color: #008080">memory_scope</span> scope <span style="color: #990000">=</span> memory_scope_work_group<span style="color: #990000">);</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_barrier</span></span><span style="color: #990000">(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">,</span>
<span style="color: #008080">memory_scope</span> scope <span style="color: #990000">=</span> memory_scope_work_group<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_subgroup_named_barrier
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">work_group_named_barrier</span><span style="color: #990000">:</span> marker_type
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #000000">work_group_named_barrier</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> sub_group_count<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000000">work_group_named_barrier</span></span><span style="color: #990000">()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">work_group_named_barrier</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> work_group_named_barrier<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">work_group_named_barrier</span></span><span style="color: #990000">(</span>work_group_named_barrier<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
work_group_named_barrier<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> work_group_named_barrier<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
work_group_named_barrier<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>work_group_named_barrier<span style="color: #990000">&amp;&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
work_group_named_barrier<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;()</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">wait</span></span><span style="color: #990000">(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">,</span>
<span style="color: #008080">memory_scope</span> scope <span style="color: #990000">=</span> memory_scope_work_group<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: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="synchronization-operations">3.16.2. Synchronization operations</h4>
<div class="sect4">
<h5 id="work_group_barrier">work_group_barrier</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">work_group_barrier</span></span><span style="color: #990000">(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">,</span>
<span style="color: #008080">memory_scope</span> scope <span style="color: #990000">=</span> memory_scope_work_group<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>All work-items in a work-group executing the kernel on a processor must execute this function before any are allowed to continue execution beyond the <span class="monospaced">work_group_barrier</span>.
This function must be encountered by all work-items in a work-group executing the kernel.
These rules apply to ND-ranges implemented with uniform and non-uniform work-groups.</p></div>
<div class="paragraph"><p>If <span class="monospaced">work_group_barrier</span> is inside a conditional statement, then all work-items must enter the conditional if any work-item enters the conditional statement and executes the <span class="monospaced">work_group_barrier</span>.</p></div>
<div class="paragraph"><p>If <span class="monospaced">work_group_barrier</span> is inside a loop, all work-items must execute the <span class="monospaced">work_group_barrier</span> for each iteration of the loop before any are allowed to continue execution beyond the <span class="monospaced">work_group_barrier</span>.</p></div>
<div class="paragraph"><p>The <span class="monospaced">scope</span> argument specifies whether the memory accesses of work-items in the work-group to memory address space(s) identified by <span class="monospaced">flags</span> become visible to all work-items in the work-group, the device or all SVM devices.</p></div>
<div class="paragraph"><p>The <span class="monospaced">work_group_barrier</span> function can also be used to specify which memory operations i.e. to global memory, local memory or images become visible to the appropriate memory scope identified by <span class="monospaced">scope</span>.
The <span class="monospaced">flags</span> argument specifies the memory address spaces.
This is a bitfield and can be set to 0 or a combination of the following values ORed together.
When these flags are ORed together the <span class="monospaced">work_group_barrier</span> acts as a combined barrier for all address spaces specified by the flags ordering memory accesses both within and across the specified address spaces.</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">mem_fence::local</span> - The <span class="monospaced">work_group_barrier</span> function will ensure that all local memory accesses become visible to all work-items in the work-group.
Note that the value of <span class="monospaced">scope</span> is ignored as the memory scope is always <span class="monospaced">memory_scope_work_group</span>.
</p>
</li>
<li>
<p>
<span class="monospaced">mem_fence::global</span> - The <span class="monospaced">work_group_barrier</span> function ensure that all global memory accesses become visible to the appropriate scope as given by <span class="monospaced">scope</span>.
</p>
</li>
<li>
<p>
<span class="monospaced">mem_fence::image</span> - The <span class="monospaced">work_group_barrier</span> function will ensure that all image memory accesses become visible to the appropriate scope as given by <span class="monospaced">scope</span>.
The value of <span class="monospaced">scope</span> must be <span class="monospaced">memory_scope_work_group</span> or <span class="monospaced">memory_scope_device</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p><span class="monospaced">mem_fence::image</span> cannot be used together with <span class="monospaced">mem_fence::local</span> or <span class="monospaced">mem_fence::global</span>.</p></div>
<div class="paragraph"><p>The values of <span class="monospaced">flags</span> and <span class="monospaced">scope</span> must be the same for all work-items in the work-group.</p></div>
</div>
<div class="sect4">
<h5 id="sub_group_barrier">sub_group_barrier</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">sub_group_barrier</span></span><span style="color: #990000">(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">,</span>
<span style="color: #008080">memory_scope</span> scope <span style="color: #990000">=</span> memory_scope_work_group<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>All work-items in a sub-group executing the kernel on a processor must execute this function before any are allowed to continue execution beyond the sub-group barrier.
This function must be encountered by all work-items in a sub-group executing the kernel.
These rules apply to ND-ranges implemented with uniform and non-uniform work-groups.</p></div>
<div class="paragraph"><p>If <span class="monospaced">sub_group_barrier</span> is inside a conditional statement, then all work-items within the sub-group must enter the conditional if any work-item in the sub-group enters the conditional statement and executes the <span class="monospaced">sub_group_barrier</span>.</p></div>
<div class="paragraph"><p>If <span class="monospaced">sub_group_barrier</span> is inside a loop, all work-items within the sub-group must execute the <span class="monospaced">sub_group_barrier</span> for each iteration of the loop before any are allowed to continue execution beyond the <span class="monospaced">sub_group_barrier</span>.</p></div>
<div class="paragraph"><p>The <span class="monospaced">sub_group_barrier</span> function also queues a memory fence (reads and writes) to ensure correct ordering of memory operations to local or global memory.</p></div>
<div class="paragraph"><p>The <span class="monospaced">flags</span> argument specifies the memory address spaces.
This is a bitfield and can be set to 0 or a combination of the following values ORed together.
When these flags are ORed together the <span class="monospaced">sub_group_barrier</span> acts as a combined barrier for all address spaces specified by the flags ordering memory accesses both within and across the specified address spaces.</p></div>
<div class="paragraph"><p><span class="monospaced">mem_fence::local</span> - The <span class="monospaced">sub_group_barrier</span> function will ensure that all local memory accesses become visible to all work-items in the sub-group.
Note that the value of <span class="monospaced">scope</span> is ignored as the memory scope is always <span class="monospaced">memory_scope_work_group</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">mem_fence::global</span> - The <span class="monospaced">sub_group_barrier</span> function ensure that all global memory accesses become visible to the appropriate scope as given by <span class="monospaced">scope</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">mem_fence::image</span> - The <span class="monospaced">sub_group_barrier</span> function will ensure that all image memory accesses become visible to the appropriate scope as given by <span class="monospaced">scope</span>.
The value of <span class="monospaced">scope</span> must be <span class="monospaced">memory_scope_work_group</span> or <span class="monospaced">memory_scope_device</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">mem_fence::image</span> cannot be used together with <span class="monospaced">mem_fence::local</span> or <span class="monospaced">mem_fence::global</span>.</p></div>
<div class="paragraph"><p>The values of <span class="monospaced">flags</span> and <span class="monospaced">scope</span> must be the same for all work-items in the sub-group.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="named-barriers">3.16.3. Named barriers</h4>
<div class="paragraph"><p>This section describes optional <em>cl_khr_sub_group_named_barrier</em> extension which exposes the ability to perform barrier synchronization on flexible portions of an execution domain.</p></div>
<div class="paragraph"><p>If <em>cl_khr_sub_group_named_barrier</em> is supported by a device, an application that wants to use it will need to define <span class="monospaced">cl_khr_sub_group_named_barrier</span> macro before including the OpenCL C++ standard library headers or using <em>-D</em> compiler option (<em><a href="#preprocessor_options">Preprocessor options</a> section</em>).</p></div>
<div class="paragraph"><p>An implementation shall support at least 8 named barriers per work-group.
The exact maximum number can be queried using <span class="monospaced">clGetDeviceInfo</span> with <span class="monospaced">CL_DEVICE_MAX_NAMED_BARRIER_COUNT_KHR</span> from the OpenCL 2.2 Extension Specification.</p></div>
<div class="paragraph"><p>Restrictions:</p></div>
<div class="ulist"><ul>
<li>
<p>
The <span class="monospaced">work_group_named_barrier</span> type cannot be used with variables declared inside a class or union field, a pointer type, an array, global variables declared at program scope or the return type of a function.
</p>
</li>
<li>
<p>
The <span class="monospaced">work_group_named_barrier</span> type cannot be used with the <span class="monospaced">global</span>, <span class="monospaced">priv</span> and <span class="monospaced">constant</span> address space storage classes (<em><a href="#explicit-address-space-storage-classes">Explicit address space storage classes</a> section</em>).
</p>
</li>
<li>
<p>
The value returned by applying the <span class="monospaced">sizeof</span> operator to the <span class="monospaced">work_group_named_barrier</span> type is implementation-defined.
</p>
</li>
</ul></div>
<div class="sect4">
<h5 id="work_group_named_barrier">work_group_named_barrier</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: #000000">work_group_named_barrier</span></span><span style="color: #990000">(</span><span style="color: #008080">uint</span> sub_group_count<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Initialize a new named barrier object to synchronize <span class="monospaced">sub_group_count</span> sub-groups in the current work-group.
Construction of a named-barrier object is a work-group operation and hence must be called uniformly across the work-group.
<span class="monospaced">sub_group_count</span> must be uniform across the work-group.</p></div>
<div class="paragraph"><p>Named barrier objects can be reconstructed and assigned to underlying entities by the compiler, or reused.
Reused barriers will always be the same size and act in phases such that when each participating sub-group has waited the wait count is set to 0 and the entire process can start again.
The internal wait count will cycle through the range from <span class="monospaced">0</span> to <span class="monospaced">sub_group_count</span> in each phase of use of the barrier.</p></div>
<div class="paragraph"><p>Named barrier objects can only be constructed within kernels, not within arbitrary functions.</p></div>
</div>
<div class="sect4">
<h5 id="wait">wait</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">wait</span></span><span style="color: #990000">(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">,</span>
<span style="color: #008080">memory_scope</span> scope <span style="color: #990000">=</span> memory_scope_work_group<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>All work-items in a sub-group executing the kernel on a processor must execute this method before any are allowed to continue execution beyond the barrier.
This function must be encountered by all work-items in a sub-group executing the kernel.</p></div>
<div class="paragraph"><p>These rules apply to ND-ranges implemented with uniform and non-uniform work-groups.</p></div>
<div class="paragraph"><p>If <span class="monospaced">wait</span> is called inside a conditional statement, then all work-items within the sub-group must enter the conditional if any work-item in the sub-group enters the conditional statement and executes the call to wait.</p></div>
<div class="paragraph"><p>If <span class="monospaced">wait</span> is called inside a loop, all work-items within the sub-group must execute the wait operation for each iteration of the loop before any are allowed to continue execution beyond the call to wait.
The wait function causes the entire sub-group to wait until <span class="monospaced">sub_group_count</span> sub-groups have waited on the named barrier, where <span class="monospaced">sub_group_count</span> is the initialization value passed to the call to the constructor of the named barrier.
Once the wait count equals <span class="monospaced">sub_group_count</span>, any sub-groups waiting at the named barrier will be released and the barrier&#8217;s wait count reset to 0.</p></div>
<div class="paragraph"><p>The <span class="monospaced">flags</span> argument specifies the memory address spaces.
This is a bitfield and can be set to 0 or a combination of the following values ORed together.
When these flags are ORed together the wait acts as a combined wait operation for all address spaces specified by the flags ordering memory accesses both within and across the specified address spaces.</p></div>
<div class="paragraph"><p><span class="monospaced">mem_fence::local</span> - The wait function will ensure that all local memory accesses become visible to all work-items in the sub-group.
Note that the value of <span class="monospaced">scope</span> is ignored as the memory scope is always <span class="monospaced">memory_scope_work_group</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">mem_fence::global</span> - The wait function ensure that all global memory accesses become visible to the appropriate scope as given by <span class="monospaced">scope</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">mem_fence::image</span> cannot be specified as a flag for this function.</p></div>
<div class="paragraph"><p>The values of <span class="monospaced">flags</span> and <span class="monospaced">scope</span> must be the same for all work-items in the sub-group.</p></div>
<div class="paragraph"><p>The below example shows how to use the named barriers:</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_synchronization&gt;</span>
<span style="font-weight: bold"><span style="color: #000080">#include</span></span> <span style="color: #FF0000">&lt;opencl_work_item&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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">aFunction</span></span><span style="color: #990000">(</span><span style="color: #008080">work_group_named_barrier</span> <span style="color: #990000">&amp;</span>b<span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">while</span></span><span style="color: #990000">(...)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// Do something in first set</span></span>
b<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">wait</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>global<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span>
kernel <span style="color: #008080">void</span> <span style="font-weight: bold"><span style="color: #000000">aKernel</span></span><span style="color: #990000">()</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// Initialize a set of named barriers</span></span>
<span style="color: #008080">local&lt;work_group_named_barrier&gt;</span> <span style="font-weight: bold"><span style="color: #000000">a</span></span><span style="color: #990000">(</span><span style="color: #993399">4</span><span style="color: #990000">);</span>
<span style="color: #008080">local&lt;work_group_named_barrier&gt;</span> <span style="font-weight: bold"><span style="color: #000000">b</span></span><span style="color: #990000">(</span><span style="color: #993399">2</span><span style="color: #990000">);</span>
<span style="color: #008080">local&lt;work_group_named_barrier&gt;</span> <span style="font-weight: bold"><span style="color: #000000">c</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">if</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">get_sub_group_id</span></span><span style="color: #990000">()</span> <span style="color: #990000">&lt;</span> <span style="color: #993399">4</span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
a<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">wait</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>local<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-weight: bold"><span style="color: #000000">get_sub_group_id</span></span><span style="color: #990000">()</span> <span style="color: #990000">&lt;</span> <span style="color: #993399">2</span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// Pass one of the named barriers to a function by reference</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// Barrier cannot be constructed in a non-kernel function</span></span>
<span style="font-weight: bold"><span style="color: #000000">aFunction</span></span><span style="color: #990000">(</span>b<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span> <span style="font-weight: bold"><span style="color: #0000FF">else</span></span> <span style="color: #FF0000">{</span>
<span style="font-style: italic"><span style="color: #9A1900">// Do something else</span></span>
c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">wait</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>local<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// Continue</span></span>
<span style="color: #FF0000">}</span>
<span style="font-style: italic"><span style="color: #9A1900">// Wait a second time on the first barrier</span></span>
a<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">wait</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>global<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span>
<span style="font-style: italic"><span style="color: #9A1900">// Back to work-group uniform control flow,</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// we can synchronize the entire group if necessary</span></span>
<span style="font-weight: bold"><span style="color: #000000">work_group_barrier</span></span><span style="color: #990000">(</span>mem_fence<span style="color: #990000">::</span>global<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="common-functions">3.17. Common Functions</h3>
<div class="paragraph"><p>This section describes the OpenCL C++ library common functions that take scalar or vector arguments.
Vector versions of common functions operate component-wise.
Descriptions are always per-component.</p></div>
<div class="paragraph"><p>The built-in common functions are implemented using the round to nearest even rounding mode.</p></div>
<div class="paragraph"><p>Here <span class="monospaced">gentype</span> matches: <span class="monospaced">half</span><em>n</em> <a href="#ftn4">[4</a>], <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> <a href="#ftn18">[18</a>]</p></div>
<div class="sect3">
<h4 id="header-opencl_common-synopsis">3.17.1. Header &lt;opencl_common&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: #000080">#ifdef</span></span> cl_khr_fp16
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> min<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> max<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">degrees</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">mix</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> a<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">radians</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">step</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> edge<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">smoothstep</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> edge0<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> edge1<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">sign</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> 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: #000080">#ifdef</span></span> cl_khr_fp64
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> min<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> max<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">degrees</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> t<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">mix</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> a<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">radians</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> t<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">step</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> edge<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> x<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">smoothstep</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> edge0<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> edge1<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> x<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">sign</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> t<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> min<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> max<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">degrees</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">mix</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> a<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">radians</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">step</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> edge<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">smoothstep</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> edge0<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> edge1<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">sign</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> t<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="common-operations">3.17.2. Common operations</h4>
<div class="sect4">
<h5 id="clamp-1">clamp</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> minval<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> maxval<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">fmin(fmax(x, minval), maxval)</span>.</p></div>
<div class="paragraph"><p>Results are undefined if <span class="monospaced">minval &gt; maxval</span>.</p></div>
</div>
<div class="sect4">
<h5 id="degrees">degrees</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">degrees</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> radians<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Converts radians to degrees, i.e. <span class="monospaced">(180 / π) * radians</span>.</p></div>
</div>
<div class="sect4">
<h5 id="max-1">max</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">y</span> if <span class="monospaced">x &lt; y</span>, otherwise it returns <span class="monospaced">x</span>.
If <span class="monospaced">x</span> or <span class="monospaced">y</span> are <span class="monospaced">infinite</span> or <span class="monospaced">NaN</span>, the return values are undefined.</p></div>
</div>
<div class="sect4">
<h5 id="min-1">min</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">y</span> if <span class="monospaced">y &lt; x</span>, otherwise it returns <span class="monospaced">x</span>.
If <span class="monospaced">x</span> or <span class="monospaced">y</span> are <span class="monospaced">infinite</span> or <span class="monospaced">NaN</span>, the return values are undefined.</p></div>
</div>
<div class="sect4">
<h5 id="mix">mix</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mix</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> a<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the linear blend of <span class="monospaced">x</span> and <span class="monospaced">y</span> implemented as:</p></div>
<div class="paragraph"><p><span class="monospaced">x + (y - x) * a</span></p></div>
<div class="paragraph"><p><span class="monospaced">a</span> must be a value in the range 0.0 &#8230; 1.0.
If <span class="monospaced">a</span> is not in the range 0.0 &#8230; 1.0, the return values are undefined.</p></div>
</div>
<div class="sect4">
<h5 id="radians">radians</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">radians</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> degrees<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Converts degrees to radians, i.e. <span class="monospaced">(π / 180) * degrees</span>.</p></div>
</div>
<div class="sect4">
<h5 id="step">step</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">step</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> edge<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>Returns <span class="monospaced">0.0</span> if <span class="monospaced">x &lt; edge</span>, otherwise it returns <span class="monospaced">1.0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="smoothstep">smoothstep</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">smoothstep</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> edge0<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> edge1<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>Returns <span class="monospaced">0.0</span> if <span class="monospaced">x &lt;= edge0</span> and <span class="monospaced">1.0</span> if <span class="monospaced">x &gt;= edge1</span> and performs smooth Hermite interpolation between <span class="monospaced">0</span> and <span class="monospaced">1</span> when <span class="monospaced">edge0 &lt; x &lt; edge1</span>.
This is useful in cases where you would want a threshold function with a smooth transition.</p></div>
<div class="paragraph"><p>This is equivalent to:</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> t<span style="color: #990000">;</span>
t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">((</span>x <span style="color: #990000">-</span> edge0<span style="color: #990000">)</span> <span style="color: #990000">/</span> <span style="color: #990000">(</span>edge1 <span style="color: #990000">-</span> edge0<span style="color: #990000">),</span> <span style="color: #993399">0</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">return</span></span> t <span style="color: #990000">*</span> t <span style="color: #990000">*</span> <span style="color: #990000">(</span><span style="color: #993399">3</span> <span style="color: #990000">-</span> <span style="color: #993399">2</span> <span style="color: #990000">*</span> t<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Results are undefined if <span class="monospaced">edge0 &gt;= edge1</span> or if <span class="monospaced">x</span>, <span class="monospaced">edge0</span> or <span class="monospaced">edge1</span> is a <span class="monospaced">NaN</span>.</p></div>
</div>
<div class="sect4">
<h5 id="sign">sign</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sign</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>Returns <span class="monospaced">1.0</span> if <span class="monospaced">x &gt; 0</span>, <span class="monospaced">-0.0</span> if <span class="monospaced">x = -0.0</span>, <span class="monospaced">+0.0</span> if <span class="monospaced">x = +0.0</span>, or <span class="monospaced">-1.0</span> if <span class="monospaced">x &lt; 0</span>.
Returns <span class="monospaced">0.0</span> if <span class="monospaced">x</span> is a <span class="monospaced">NaN</span>.</p></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="geometric-functions">3.18. Geometric Functions</h3>
<div class="paragraph"><p>This section describes the OpenCL C++ library geometric functions that take scalar or vector arguments.
Vector versions of geometric functions operate component-wise.
Descriptions are always per-component.
The geometric functions are implemented using the round to nearest even rounding mode.</p></div>
<div class="paragraph"><p><span class="monospaced">float</span><em>n</em> is <span class="monospaced">float</span>, <span class="monospaced">float2</span>, <span class="monospaced">float3</span> or <span class="monospaced">float4</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">half</span><em>n</em> <a href="#ftn4">[4</a>] is <span class="monospaced">half</span>, <span class="monospaced">half2</span>, <span class="monospaced">half3</span> or <span class="monospaced">half4</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">double</span><em>n</em> <a href="#ftn18">[18</a>] is <span class="monospaced">double</span>, <span class="monospaced">double2</span>, <span class="monospaced">double3</span> or <span class="monospaced">double4</span>.</p></div>
<div class="sect3">
<h4 id="header-opencl_geometric-synopsis">3.18.1. Header &lt;opencl_geometric&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: #000080">#ifdef</span></span> cl_khr_fp16
<span style="color: #008080">half3</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">half3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half3</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half4</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">half4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half4</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">half2</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half2</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">half3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half3</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">half4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half4</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">half2</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half2</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">half3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half3</span> p1<span style="color: #990000">;</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">half4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half4</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> t<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">half2</span> t<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">half3</span> t<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">half4</span> t<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">half</span> t<span style="color: #990000">);</span>
<span style="color: #008080">half2</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">half2</span> t<span style="color: #990000">);</span>
<span style="color: #008080">half3</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">half3</span> t<span style="color: #990000">);</span>
<span style="color: #008080">half4</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">half4</span> 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: #000080">#ifdef</span></span> cl_khr_fp64
<span style="color: #008080">double3</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">double3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double3</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">double4</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">double4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double4</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> p0<span style="color: #990000">,</span> <span style="color: #009900">double</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">double2</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double2</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">double3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double3</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">double4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double4</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> p0<span style="color: #990000">,</span> <span style="color: #009900">double</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">double2</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double2</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">double3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double3</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">double4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double4</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> t<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">double2</span> t<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">double3</span> t<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">double4</span> t<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #009900">double</span> t<span style="color: #990000">);</span>
<span style="color: #008080">double2</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">double2</span> t<span style="color: #990000">);</span>
<span style="color: #008080">double3</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">double3</span> t<span style="color: #990000">);</span>
<span style="color: #008080">double4</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">double4</span> t<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #008080">float3</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float3</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float4</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> p0<span style="color: #990000">,</span> <span style="color: #009900">float</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">float2</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float2</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float3</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float4</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> p0<span style="color: #990000">,</span> <span style="color: #009900">float</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">float2</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float2</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float3</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float4</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">float2</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> t<span style="color: #990000">);</span>
<span style="color: #008080">float2</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">float2</span> t<span style="color: #990000">);</span>
<span style="color: #008080">float3</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> t<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_distance</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> p0<span style="color: #990000">,</span> <span style="color: #009900">float</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_distance</span></span><span style="color: #990000">(</span><span style="color: #008080">float2</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float2</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_distance</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float3</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_distance</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float4</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_length</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_length</span></span><span style="color: #990000">(</span><span style="color: #008080">float2</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_length</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_length</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> t<span style="color: #990000">);</span>
<span style="color: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_normalize</span></span><span style="color: #990000">(</span><span style="color: #009900">float</span> t<span style="color: #990000">);</span>
<span style="color: #008080">float2</span> <span style="font-weight: bold"><span style="color: #000000">fast_normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">float2</span> t<span style="color: #990000">);</span>
<span style="color: #008080">float3</span> <span style="font-weight: bold"><span style="color: #000000">fast_normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> t<span style="color: #990000">);</span>
<span style="color: #008080">float4</span> <span style="font-weight: bold"><span style="color: #000000">fast_normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> t<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="geometric-operations">3.18.2. Geometric operations</h4>
<div class="sect4">
<h5 id="cross">cross</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">float4</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">float4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float4</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">float3</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">float3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">float3</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">double4</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">double4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double4</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">double3</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">double3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">double3</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half4</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">half4</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half4</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half3</span> <span style="font-weight: bold"><span style="color: #000000">cross</span></span><span style="color: #990000">(</span><span style="color: #008080">half3</span> p0<span style="color: #990000">,</span> <span style="color: #008080">half3</span> p1<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the cross product of <span class="monospaced">p0.xyz</span> and <span class="monospaced">p1.xyz</span>.
The <span class="monospaced">w</span> component of <span class="monospaced">float4</span> result returned will be <span class="monospaced">0.0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="dot">dot</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: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> p0<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> p0<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">dot</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> p0<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> p1<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute dot product.</p></div>
</div>
<div class="sect4">
<h5 id="distance">distance</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: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> p0<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> p1<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> p0<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> p1<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> p0<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> p1<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the distance between <span class="monospaced">p0</span> and <span class="monospaced">p1</span>.</p></div>
<div class="paragraph"><p>This is calculated as <span class="monospaced">length(p0 - p1)</span>.</p></div>
</div>
<div class="sect4">
<h5 id="length">length</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: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> p<span style="color: #990000">);</span>
<span style="color: #009900">double</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> p<span style="color: #990000">);</span>
<span style="color: #008080">half</span> <span style="font-weight: bold"><span style="color: #000000">length</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Return the length of vector <span class="monospaced">p</span>, i.e.,</p></div>
<div class="mathblock">
<div class="content">\[
\sqrt{p.x^2 + p.y^2 + \ldots}
\]</div></div>
</div>
<div class="sect4">
<h5 id="normalize">normalize</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">floatn</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> p<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> p<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns a vector in the same direction as <span class="monospaced">p</span> but with a length of <span class="monospaced">1</span>.</p></div>
</div>
<div class="sect4">
<h5 id="fast_distance">fast_distance</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: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_distance</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> p0<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> p1<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">fast_length(p0 - p1)</span>.</p></div>
</div>
<div class="sect4">
<h5 id="fast_length">fast_length</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: #009900">float</span> <span style="font-weight: bold"><span style="color: #000000">fast_length</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the length of vector <span class="monospaced">p</span> computed 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: #000000">half_sqrt</span></span><span style="color: #990000">(</span>p<span style="color: #990000">.</span>x<span style="color: #990000">^</span><span style="color: #993399">2</span> <span style="color: #990000">+</span> p<span style="color: #990000">.</span>y<span style="color: #990000">^</span><span style="color: #993399">2</span> <span style="color: #990000">+</span> <span style="color: #990000">...)</span></tt></pre></div></div>
</div>
<div class="sect4">
<h5 id="fast_normalize">fast_normalize</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">floatn</span> <span style="font-weight: bold"><span style="color: #000000">fast_normalize</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns a vector in the same direction as <span class="monospaced">p</span> but with a length of 1.
<span class="monospaced">fast_normalize</span> is computed 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>p <span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">half_rsqrt</span></span><span style="color: #990000">(</span>p<span style="color: #990000">.</span>x<span style="color: #990000">^</span><span style="color: #993399">2</span> <span style="color: #990000">+</span> p<span style="color: #990000">.</span>y<span style="color: #990000">^</span><span style="color: #993399">2</span> <span style="color: #990000">+</span> <span style="color: #990000">...)</span></tt></pre></div></div>
<div class="paragraph"><p>The result shall be within 8192 ulps error from the infinitely precise result of</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">if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">all</span></span><span style="color: #990000">(</span>p <span style="color: #990000">==</span> <span style="color: #993399">0</span><span style="color: #990000">.</span>0f<span style="color: #990000">))</span>
result <span style="color: #990000">=</span> p<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">else</span></span>
result <span style="color: #990000">=</span> p <span style="color: #990000">/</span> <span style="font-weight: bold"><span style="color: #000000">sqrt</span></span><span style="color: #990000">(</span>p<span style="color: #990000">.</span>x<span style="color: #990000">^</span><span style="color: #993399">2</span> <span style="color: #990000">+</span> p<span style="color: #990000">.</span>y<span style="color: #990000">^</span><span style="color: #993399">2</span> <span style="color: #990000">+</span> <span style="color: #990000">...</span> <span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>with the following exceptions:</p></div>
<div class="ulist"><ul>
<li>
<p>
If the sum of squares is greater than <span class="monospaced">FLT_MAX</span> then the value of the floating-point values in the result vector are undefined.
</p>
</li>
<li>
<p>
If the sum of squares is less than <span class="monospaced">FLT_MIN</span> then the implementation may return back <span class="monospaced">p</span>.
</p>
</li>
<li>
<p>
If the device is in “denorms are flushed to zero” mode, individual operand elements with magnitude less than <span class="monospaced">sqrt(FLT_MIN)</span> may be flushed to zero before proceeding with the calculation.
</p>
</li>
</ul></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="math-functions">3.19. Math Functions</h3>
<div class="paragraph"><p>The list of the OpenCL C++ library math functions is described in <em><a href="#trigonometric-functions">Trigonometric functions</a></em>, <em><a href="#logarithmic-functions">Logarithmic functions</a></em>, <em><a href="#exponential-functions">Exponential functions</a></em>, <em><a href="#floating-point-functions">Floating-point functions</a></em>, <em><a href="#comparison-functions">Comparison functions</a></em> and <em><a href="#other-functions-1">Other functions</a> sections</em>.</p></div>
<div class="paragraph"><p>The built-in math functions are categorized into the following:</p></div>
<div class="ulist"><ul>
<li>
<p>
A list of built-in functions that have scalar or vector argument versions.
</p>
</li>
<li>
<p>
A list of built-in functions that only take scalar float arguments.
</p>
</li>
</ul></div>
<div class="paragraph"><p>The vector versions of the math functions operate component-wise.
The description is per-component.</p></div>
<div class="paragraph"><p>The built-in math functions are not affected by the prevailing rounding mode in the calling environment, and always return the same value as they would if called with the round to nearest even rounding mode.</p></div>
<div class="paragraph"><p>Here <span class="monospaced">gentype</span> matches: <span class="monospaced">half</span><em>n</em> <a href="#ftn4">[4</a>], <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> <a href="#ftn18">[18</a>]</p></div>
<div class="sect3">
<h4 id="header-opencl_math-synopsis">3.19.1. Header &lt;opencl_math&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-style: italic"><span style="color: #9A1900">//trigonometric functions</span></span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">acos</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">acosh</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">acospi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">asin</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">asinh</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">asinpi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atan</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atanh</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atanpi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atan2</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> y<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atan2pi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> y<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">cos</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">cosh</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">cospi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sin</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sincos</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> gentype <span style="color: #990000">*</span> cosval<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sinh</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sinpi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">tan</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">tanh</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">tanpi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//power functions</span></span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">cbrt</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">pow</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">pown</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">powr</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rootn</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rsqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//logarithmic functions</span></span>
<span style="color: #008080">intn</span> <span style="font-weight: bold"><span style="color: #000000">ilogb</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">lgamma</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">lgamma_r</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> intn<span style="color: #990000">*</span> signp<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">log</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">logb</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">log2</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">log10</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">log1p</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//exponential functions</span></span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">exp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">expm1</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">exp2</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">exp10</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">ldexp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> k<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//floating-point functions</span></span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">ceil</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">copysign</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">floor</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fma</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fmod</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fract</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> gentype<span style="color: #990000">*</span> iptr<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">frexp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> intn<span style="color: #990000">*</span> exp<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">modf</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> gentype<span style="color: #990000">*</span> iptr<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">nan</span></span><span style="color: #990000">(</span><span style="color: #008080">ushortn</span> nancode<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">nan</span></span><span style="color: #990000">(</span><span style="color: #008080">uintn</span> nancode<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp64
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">nan</span></span><span style="color: #990000">(</span><span style="color: #008080">ulong</span> nancode<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">nextafter</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">remainder</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">remquo</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">,</span> intn<span style="color: #990000">*</span> quo<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rint</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">round</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">trunc</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//comparison functions</span></span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fdim</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fmax</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fmin</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">maxmag</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">minmag</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//other functions</span></span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">erf</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">erfc</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fabs</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">hypot</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mad</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">tgamma</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//native functions</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> native
<span style="color: #FF0000">{</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">cos</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">exp</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">exp2</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">exp10</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">log</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">log2</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">log10</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">recip</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">rsqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">sin</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">sqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">tan</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">divide</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">powr</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span>
<span style="font-style: italic"><span style="color: #9A1900">//half_math functions</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">namespace</span></span> half_math
<span style="color: #FF0000">{</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">cos</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">exp</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">exp2</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">exp10</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">log</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">log2</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">log10</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">recip</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">rsqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">sin</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">sqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">tan</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">divide</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">floatn</span> <span style="font-weight: bold"><span style="color: #000000">powr</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="trigonometric-functions">3.19.2. Trigonometric functions</h4>
<div class="sect4">
<h5 id="acos">acos</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">acos</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>Arc cosine function.
Returns an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="acosh">acosh</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">acosh</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>Inverse hyperbolic cosine.
Returns an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="acospi">acospi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">acospi</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>Compute acos(<span class="monospaced">x</span>) / π.</p></div>
</div>
<div class="sect4">
<h5 id="asin">asin</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">asin</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>Arc sine function.
Returns an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="asinh">asinh</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">asinh</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>Inverse hyperbolic sine.
Returns an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="asinpi">asinpi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">asinpi</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>Compute asin(<span class="monospaced">x</span>) / π.</p></div>
</div>
<div class="sect4">
<h5 id="atan">atan</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atan</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> y_over_x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Arc tangent function.
Returns an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="atan2">atan2</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atan2</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> y<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>Arc tangent of <span class="monospaced">y / x</span>.
Returns an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="atanh">atanh</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atanh</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>Hyperbolic arc tangent.
Returns an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="atanpi">atanpi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atanpi</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>Compute atan(<span class="monospaced">x</span>) / π.</p></div>
</div>
<div class="sect4">
<h5 id="atan2pi">atan2pi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">atan2pi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> y<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>Compute atan2(<span class="monospaced">y</span>, <span class="monospaced">x</span>) / π.</p></div>
</div>
<div class="sect4">
<h5 id="cos">cos</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">cos</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>Compute cosine, where <span class="monospaced">x</span> is an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="cosh">cosh</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">cosh</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>Compute hyperbolic consine, where <span class="monospaced">x</span> is an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="cospi">cospi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">cospi</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>Compute cos(π x).</p></div>
</div>
<div class="sect4">
<h5 id="sin">sin</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sin</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>Compute sine, where <span class="monospaced">x</span> is an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="sincos">sincos</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sincos</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> <span style="color: #990000">*</span>cosval<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute sine and cosine of <span class="monospaced">x</span>.
The computed sine is the return value and computed cosine is returned in <span class="monospaced">cosval</span>, where <span class="monospaced">x</span> is an angle in radians</p></div>
</div>
<div class="sect4">
<h5 id="sinh">sinh</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sinh</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>Compute hyperbolic sine, where <span class="monospaced">x</span> is an angle in radians</p></div>
</div>
<div class="sect4">
<h5 id="sinpi">sinpi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sinpi</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>Compute sin(π <span class="monospaced">x</span>).</p></div>
</div>
<div class="sect4">
<h5 id="tan">tan</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">tan</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>Compute tangent, where <span class="monospaced">x</span> is an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="tanh">tanh</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">tanh</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>Compute hyperbolic tangent, where <span class="monospaced">x</span> is an angle in radians.</p></div>
</div>
<div class="sect4">
<h5 id="tanpi">tanpi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">tanpi</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>Compute tan(π <span class="monospaced">x</span>).</p></div>
</div>
</div>
<div class="sect3">
<h4 id="power-functions">3.19.3. Power function</h4>
<div class="sect4">
<h5 id="cbrt">cbrt</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">cbrt</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>Compute cube-root.</p></div>
</div>
<div class="sect4">
<h5 id="pow">pow</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">pow</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute <span class="monospaced">x</span> to the power <span class="monospaced">y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="pown">pown</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">floatn</span> <span style="font-weight: bold"><span style="color: #000000">pown</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute <span class="monospaced">x</span> to the power <span class="monospaced">y</span>, where <span class="monospaced">y</span> is an integer.</p></div>
</div>
<div class="sect4">
<h5 id="powr">powr</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">powr</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute <span class="monospaced">x</span> to the power <span class="monospaced">y</span>, where <span class="monospaced">x</span> is <span class="monospaced">&gt;= 0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="rootn">rootn</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">powr</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute <span class="monospaced">x</span> to the power <span class="monospaced">1/y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="rsqrt">rsqrt</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rsqrt</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>Compute inverse square root.</p></div>
</div>
<div class="sect4">
<h5 id="sqrt">sqrt</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sqrt</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>Compute square root.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="logarithmic-functions">3.19.4. Logarithmic functions</h4>
<div class="sect4">
<h5 id="ilogb">ilogb</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">intn</span> <span style="font-weight: bold"><span style="color: #000000">ilogb</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>Return the exponent as an integer value.</p></div>
</div>
<div class="sect4">
<h5 id="lgamma">lgamma</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">lgamma</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">lgamma_r</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> <span style="color: #990000">*</span>signp<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Log gamma function.
Returns the natural logarithm of the absolute value of the gamma function.
The sign of the gamma function is returned in the signp argument of <span class="monospaced">lgamma_r</span>.</p></div>
</div>
<div class="sect4">
<h5 id="log">log</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">log</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>Compute natural logarithm.</p></div>
</div>
<div class="sect4">
<h5 id="log2">log2</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">log2</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>Compute a base 2 logarithm.</p></div>
</div>
<div class="sect4">
<h5 id="log10">log10</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">log10</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>Compute a base 10 logarithm.</p></div>
</div>
<div class="sect4">
<h5 id="log1p">log1p</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">log1p</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>Compute log<sub>e</sub>(1.0 + x).</p></div>
</div>
<div class="sect4">
<h5 id="logb">logb</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">logb</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>Compute the exponent of <span class="monospaced">x</span>, which is the integral part of log<sub>r</sub>|<span class="monospaced">x</span>|.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="exponential-functions">3.19.5. Exponential functions</h4>
<div class="sect4">
<h5 id="exp">exp</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">exp</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>Compute the base e exponential of <span class="monospaced">x</span>.</p></div>
</div>
<div class="sect4">
<h5 id="exp2">exp2</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">exp2</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>Exponential base 2 function.</p></div>
</div>
<div class="sect4">
<h5 id="exp10">exp10</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">exp10</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>Exponential base 10 function.</p></div>
</div>
<div class="sect4">
<h5 id="expm1">expm1</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">expm1</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>Compute e<sup>x</sup>- 1.0.</p></div>
</div>
<div class="sect4">
<h5 id="ldexp">ldexp</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">ldexp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> k<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Multiply <span class="monospaced">x</span> by 2 to the power <span class="monospaced">k</span>.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="floating-point-functions">3.19.6. Floating-point functions</h4>
<div class="sect4">
<h5 id="ceil">ceil</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">ceil</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>Round to integral value using the round to positive infinity rounding mode.</p></div>
</div>
<div class="sect4">
<h5 id="copysign">copysign</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">copysign</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns x with its sign changed to match the sign of y.</p></div>
</div>
<div class="sect4">
<h5 id="floor">floor</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">floor</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>Round to integral value using the round to negative infinity rounding mode.</p></div>
</div>
<div class="sect4">
<h5 id="fma">fma</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fma</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the correctly rounded floating-point representation of the sum of <span class="monospaced">c</span> with the infinitely precise product of <span class="monospaced">a</span> and <span class="monospaced">b</span>.
Rounding of intermediate products shall not occur.
Edge case behavior is per the IEEE 754-2008 standard.</p></div>
</div>
<div class="sect4">
<h5 id="fmod">fmod</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fmod</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Modulus. Returns <span class="monospaced">x - y * trunc (x/y)</span>.</p></div>
</div>
<div class="sect4">
<h5 id="fract">fract</h5>
<div class="paragraph"><p><span class="monospaced">fract</span> <a href="#ftn20">[20</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="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fract</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> <span style="color: #990000">*</span>iptr<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">fmin(x - floor(x), 0x1.fffffep-1f)</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">floor(x)</span> is returned in <span class="monospaced">iptr</span>.</p></div>
</div>
<div class="sect4">
<h5 id="frexp">frexp</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">frexp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> <span style="color: #990000">*</span>exp<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Extract mantissa and exponent from <span class="monospaced">x</span>.
For each component the mantissa returned is a half with magnitude in the interval [1/2, 1) or 0.
Each component of <span class="monospaced">x</span> equals mantissa returned <span class="monospaced">* 2<sup>exp</sup></span>.</p></div>
</div>
<div class="sect4">
<h5 id="modf">modf</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">modf</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> <span style="color: #990000">*</span>iptr<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Decompose a floating-point number.
The modf function breaks the argument <span class="monospaced">x</span> into integral and fractional parts, each of which has the same sign as the argument.
It stores the integral part in the object pointed to by <span class="monospaced">iptr</span>.</p></div>
</div>
<div class="sect4">
<h5 id="nan">nan</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">floatn</span> <span style="font-weight: bold"><span style="color: #000000">nan</span></span><span style="color: #990000">(</span><span style="color: #008080">uintn</span> nancode<span style="color: #990000">);</span>
<span style="color: #008080">doublen</span> <span style="font-weight: bold"><span style="color: #000000">nan</span></span><span style="color: #990000">(</span><span style="color: #008080">ulongn</span> nancode<span style="color: #990000">);</span>
<span style="color: #008080">halfn</span> <span style="font-weight: bold"><span style="color: #000000">nan</span></span><span style="color: #990000">(</span><span style="color: #008080">ushortn</span> nancode<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns a quiet <span class="monospaced">NaN</span>.
The nancode may be placed in the significand of the resulting <span class="monospaced">NaN</span>.</p></div>
</div>
<div class="sect4">
<h5 id="nextafter">nextafter</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">nextafter</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Computes the next representable single-precision floating-point value following <span class="monospaced">x</span> in the direction of <span class="monospaced">y</span>.
Thus, if <span class="monospaced">y</span> is less than <span class="monospaced">x</span>.
<span class="monospaced">nextafter()</span> returns the largest representable floating-point number less than <span class="monospaced">x</span>.</p></div>
</div>
<div class="sect4">
<h5 id="remainder">remainder</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">remainder</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute the value <span class="monospaced">r</span> such that <span class="monospaced">r = x - n*y</span>, where <span class="monospaced">n</span> is the integer nearest the exact value of <span class="monospaced">x/y</span>.
If there are two integers closest to <span class="monospaced">x/y</span>, <span class="monospaced">n</span> shall be the even one.
If <span class="monospaced">r</span> is zero, it is given the same sign as <span class="monospaced">x</span>.</p></div>
</div>
<div class="sect4">
<h5 id="remquo">remquo</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">remquo</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">,</span> <span style="color: #008080">intn</span> <span style="color: #990000">*</span>quo<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>The remquo function computes the value <span class="monospaced">r</span> such that <span class="monospaced">r = x - k*y</span>, where <span class="monospaced">k</span> is the integer nearest the exact value of <span class="monospaced">x/y</span>.
If there are two integers closest to <span class="monospaced">x/y</span>, <span class="monospaced">k</span> shall be the even one.
If <span class="monospaced">r</span> is zero, it is given the same sign as <span class="monospaced">x</span>.
This is the same value that is returned by the remainder function.
<span class="monospaced">remquo</span> also calculates at least the seven lower bits of the integral quotient <span class="monospaced">x/y</span>, and gives that value the same sign as <span class="monospaced">x/y</span>.
It stores this signed value in the object pointed to by <span class="monospaced">quo</span>.</p></div>
</div>
<div class="sect4">
<h5 id="rint">rint</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rint</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>Round to integral value (using round to nearest even rounding mode) in floating-point format.
Refer to <em><a href="#rounding-modes">Rounding Modes</a> section</em> for description of rounding modes.</p></div>
</div>
<div class="sect4">
<h5 id="round">round</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">round</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>Return the integral value nearest to <span class="monospaced">x</span> rounding halfway cases away from zero, regardless of the current rounding direction.</p></div>
</div>
<div class="sect4">
<h5 id="trunc">trunc</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">trunc</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>Round to integral value using the round to zero rounding mode.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="comparison-functions">3.19.7. Comparison functions</h4>
<div class="sect4">
<h5 id="fdim">fdim</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fdim</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p><span class="monospaced">x - y</span> if <span class="monospaced">x &gt; y</span>, <span class="monospaced">+0</span> if <span class="monospaced">x</span> is less than or equal to <span class="monospaced">y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="fmax">fmax</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fmax</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">y</span> if <span class="monospaced">x &lt; y</span>, otherwise it returns <span class="monospaced">x</span>.
If one argument is a <span class="monospaced">NaN</span>, <span class="monospaced">fmax()</span> returns the other argument.
If both arguments are NaNs, <span class="monospaced">fmax()</span> returns a <span class="monospaced">NaN</span>.</p></div>
</div>
<div class="sect4">
<h5 id="fmin">fmin</h5>
<div class="paragraph"><p><span class="monospaced">fmin</span> <a href="#ftn21">[21</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="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fmin</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">y</span> if <span class="monospaced">y &lt; x</span>, otherwise it returns <span class="monospaced">x</span>.
If one argument is a NaN, <span class="monospaced">fmin()</span> returns the other argument.
If both arguments are NaNs, <span class="monospaced">fmin()</span> returns a <span class="monospaced">NaN</span>.</p></div>
</div>
<div class="sect4">
<h5 id="fmod-1">fmod</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fmod</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Modulus.
Returns <span class="monospaced">x - y * trunc (x/y)</span>.</p></div>
</div>
<div class="sect4">
<h5 id="maxmag">maxmag</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">maxmag</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">x</span> if <span class="monospaced">|x| &gt; |y|</span>, <span class="monospaced">y</span> if <span class="monospaced">|y| &gt; |x|</span>, otherwise <span class="monospaced">fmax(x, y)</span>.</p></div>
</div>
<div class="sect4">
<h5 id="minmag">minmag</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">minmag</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">x</span> if <span class="monospaced">|x| &lt; |y|</span>, <span class="monospaced">y</span> if <span class="monospaced">|y| &lt; |x|</span>, otherwise <span class="monospaced">fmin(x, y)</span>.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="other-functions-1">3.19.8. Other functions</h4>
<div class="sect4">
<h5 id="erfc">erfc</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">erfc</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>Complementary error function.</p></div>
</div>
<div class="sect4">
<h5 id="erf">erf</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">erf</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>Error function encountered in integrating the <a href="http://mathworld.wolfram.com/NormalDistribution.html">normal distribution</a>.</p></div>
</div>
<div class="sect4">
<h5 id="fabs">fabs</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">fabs</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>Compute absolute value of a floating-point number.</p></div>
</div>
<div class="sect4">
<h5 id="hypot">hypot</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">hypot</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute the value of the square root of <span class="monospaced">x<sup>2</sup> + y<sup>2</sup></span> without undue overflow or underflow.</p></div>
</div>
<div class="sect4">
<h5 id="mad">mad</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mad</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p><span class="monospaced">mad</span> approximates <span class="monospaced">a*b+c</span>.
Whether or how the product of <span class="monospaced">a * b</span> is rounded and how supernormal or subnormal intermediate products are handled is not defined.
<span class="monospaced">mad</span> is intended to be used where speed is preferred over accuracy <a href="#ftn22">[22</a>].</p></div>
</div>
<div class="sect4">
<h5 id="tgamma">tgamma</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">tgamma</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>Compute the gamma function.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="native-functions">3.19.9. Native functions</h4>
<div class="paragraph"><p>This section describes the following functions:</p></div>
<div class="ulist"><ul>
<li>
<p>
A subset of functions from previous sections that are defined in the <span class="monospaced">cl::native_math</span> namespace.
These functions may map to one or more native device instructions and will typically have better performance compared to the corresponding functions (without the native_math namespace) described in <em><a href="#trigonometric-functions">Trigonometric functions</a></em>, <em><a href="#logarithmic-functions">Logarithmic functions</a></em>, <em><a href="#exponential-functions">Exponential functions</a></em>, <em><a href="#floating-point-functions">Floating-point functions</a></em>, <em><a href="#comparison-functions">Comparison functions</a></em> and <em><a href="#other-functions-1">Other functions</a> sections</em>.
The accuracy (and in some cases the input range(s)) of these functions is implementation-defined.
</p>
</li>
<li>
<p>
Native functions for following basic operations: divide and reciprocal.
</p>
</li>
<li>
<p>
Support for denormal values is implementation-defined for native functions.
</p>
</li>
</ul></div>
<div class="sect4">
<h5 id="native_mathcos">native_math::cos</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">cos</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute cosine over an implementation-defined range, where <span class="monospaced">x</span> is an angle in radians.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathdivide">native_math::divide</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">divide</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute <span class="monospaced">x / y</span> over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathexp">native_math::exp</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">exp</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute the base e exponential of <span class="monospaced">x</span> over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathexp2">native_math::exp2</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">exp2</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute the base 2 exponential of <span class="monospaced">x</span> over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathexp10">native_math::exp10</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">exp10</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute the base 10 exponential of <span class="monospaced">x</span> over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathlog">native_math::log</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">log</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute natural logarithm over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathlog2">native_math::log2</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">log2</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute a base 2 logarithm over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathlog10">native_math::log10</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">log10</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute a base 10 logarithm over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathpowr">native_math::powr</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">powr</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute <span class="monospaced">x</span> to the power <span class="monospaced">y</span>, where <span class="monospaced">x</span> is <span class="monospaced">&gt;= 0</span>.
The range of <span class="monospaced">x</span> and <span class="monospaced">y</span> are implementation-defined.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathrecip">native_math::recip</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">recip</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute reciprocal over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathrsqrt">native_math::rsqrt</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">rsqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute inverse square root over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathsin">native_math::sin</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sin</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute sine over an implementation-defined range, where <span class="monospaced">x</span> is an angle in radians.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathsqrt">native_math::sqrt</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute square root over an implementation-defined range.
The maximum error is implementation-defined.</p></div>
</div>
<div class="sect4">
<h5 id="native_mathtan">native_math::tan</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">floatn</span> native_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">tan</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute tangent over an implementation-defined range, where <span class="monospaced">x</span> is an angle in radians.
The maximum error is implementation-defined.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="half-functions">3.19.10. Half functions</h4>
<div class="paragraph"><p>This section describes the following functions:</p></div>
<div class="ulist"><ul>
<li>
<p>
A subset of functions from previous sections that are defined in the <span class="monospaced">cl::half_math</span> namespace.
These functions are implemented with a minimum of 10-bits of accuracy i.e. an ULP value &lt;= 8192 ulp.
</p>
</li>
<li>
<p>
half functions for following basic operations: divide and reciprocal.
</p>
</li>
<li>
<p>
Support for denormal values is optional for half_math:: functions. The <span class="monospaced">half_math::</span> functions may return any result allowed by <em><a href="#edge-case-behavior-in-flush-to-zero-mode">Edge Case Behavior in Flush To Zero Mode</a> section</em>, even when <em>-cl-denorms-are-zero</em> is not in force.
</p>
</li>
</ul></div>
<div class="sect4">
<h5 id="half_mathcos">half_math::cos</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">cos</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute cosine.
<span class="monospaced">x</span> is an angle in radians and it must be in the range -2<sup>16</sup> &#8230; +2<sup>16</sup>.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathdivide">half_math::divide</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">divide</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute <span class="monospaced">x / y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathexp">half_math::exp</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">exp</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute the base e exponential of <span class="monospaced">x</span>.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathexp2">half_math::exp2</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">exp2</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute the base 2 exponential of <span class="monospaced">x</span>.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathexp10">half_math::exp10</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">exp10</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute the base 10 exponential of <span class="monospaced">x</span>.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathlog">half_math::log</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">log</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute natural logarithm.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathlog2">half_math::log2</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">log2</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute a base 2 logarithm.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathlog10">half_math::log10</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">log10</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute a base 10 logarithm.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathpowr">half_math::powr</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">powr</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute <span class="monospaced">x</span> to the power <span class="monospaced">y</span>, where <span class="monospaced">x</span> is <span class="monospaced">&gt;= 0</span>.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathrecip">half_math::recip</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">recip</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute reciprocal.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathrsqrt">half_math::rsqrt</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">rsqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute inverse square root.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathsin">half_math::sin</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sin</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute sine.
<span class="monospaced">x</span> is an angle in radians and it must be in the range -2<sup>16</sup> &#8230; +2<sup>16</sup>.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathsqrt">half_math::sqrt</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">sqrt</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute square root.</p></div>
</div>
<div class="sect4">
<h5 id="half_mathtan">half_math::tan</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">floatn</span> half_math<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">tan</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Compute tangent.
<span class="monospaced">x</span> is an angle in radians and it must be in the range -2<sup>16</sup> &#8230; +2<sup>16</sup>.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="floating-point-pragmas">3.19.11. Floating-point pragmas</h4>
<div class="paragraph"><p>The <span class="monospaced">FP_CONTRACT</span> pragma can be used to allow (if the state is on) or disallow (if the state is off) the implementation to contract expressions.
Each pragma can occur either outside external declarations or preceding all explicit declarations and statements inside a compound statement.
When outside external declarations, the pragma takes effect from its occurrence until another <span class="monospaced">FP_CONTRACT</span> pragma is encountered, or until the end of the translation unit.
When inside a compound statement, the pragma takes effect from its occurrence until another <span class="monospaced">FP_CONTRACT</span> pragma is encountered (including within a nested compound statement), or until the end of the compound statement; at the end of a compound statement the state for the pragma is restored to its condition just before the compound statement.
If this pragma is used in any other context, the behavior is undefined.</p></div>
<div class="paragraph"><p>The pragma definition to set <span class="monospaced">FP_CONTRACT</span> is:</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 is one of: ON, OFF or DEFAULT.</span></span></tt></pre></div></div>
<div class="paragraph"><p>The <span class="monospaced">DEFAULT</span> value is <span class="monospaced">ON</span>.</p></div>
</div>
</div>
<div class="sect2">
<h3 id="integer-functions">3.20. Integer Functions</h3>
<div class="paragraph"><p>This section describes the OpenCL C++ library integer functions that take scalar or vector arguments.
Vector versions of integer functions operate component-wise.
Descriptions are always per-component.</p></div>
<div class="paragraph"><p>Here <span class="monospaced">gentype</span> matches: <span class="monospaced">char</span><em>n</em>, <span class="monospaced">uchar</span><em>n</em>, <span class="monospaced">short</span><em>n</em>, <span class="monospaced">ushort</span><em>n</em>, <span class="monospaced">int</span><em>n</em>, <span class="monospaced">uint</span><em>n</em>, <span class="monospaced">long</span><em>n</em> and <span class="monospaced">ulong</span><em>n</em>.</p></div>
<div class="sect3">
<h4 id="header-opencl_integer-synopsis">3.20.1. Header &lt;opencl_integer&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-style: italic"><span style="color: #9A1900">//bitwise functions</span></span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">clz</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">ctz</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">popcount</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rotate</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> v<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> i<span style="color: #990000">);</span>
<span style="color: #008080">shortn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">charn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">ucharn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">ushortn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">ucharn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">ucharn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">intn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">shortn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">ushortn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">uintn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">ushortn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">ushortn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">longn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">intn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">ulongn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">uintn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> lo<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//numeric functions</span></span>
<span style="color: #008080">ugentype</span> <span style="font-weight: bold"><span style="color: #000000">abs</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">);</span>
<span style="color: #008080">ugentype</span> <span style="font-weight: bold"><span style="color: #000000">abs_diff</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">add_sat</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">hadd</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rhadd</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> minval<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> maxval<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">sgentype</span> minval<span style="color: #990000">,</span> <span style="color: #008080">sgentype</span> maxval<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mad_hi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mad_sat</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">sgentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">sgentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mul_hi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sub_sat</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//24-bits functions</span></span>
<span style="color: #008080">intn</span> <span style="font-weight: bold"><span style="color: #000000">mad24</span></span><span style="color: #990000">(</span><span style="color: #008080">intn</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> y<span style="color: #990000">,</span> <span style="color: #008080">intn</span> z<span style="color: #990000">);</span>
<span style="color: #008080">uintn</span> <span style="font-weight: bold"><span style="color: #000000">mad24</span></span><span style="color: #990000">(</span><span style="color: #008080">uintn</span> x<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> y<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> z<span style="color: #990000">);</span>
<span style="color: #008080">intn</span> <span style="font-weight: bold"><span style="color: #000000">mul24</span></span><span style="color: #990000">(</span><span style="color: #008080">intn</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">uintn</span> <span style="font-weight: bold"><span style="color: #000000">mul24</span></span><span style="color: #990000">(</span><span style="color: #008080">uintn</span> x<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> y<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="bitwise-operations">3.20.2. Bitwise operations</h4>
<div class="sect4">
<h5 id="clz">clz</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">clz</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>Returns the number of leading 0-bits in <span class="monospaced">x</span>, starting at the most significant bit position.
If <span class="monospaced">x</span> is <span class="monospaced">0</span>, returns the size in bits of the type of <span class="monospaced">x</span> or component type of <span class="monospaced">x</span>, if <span class="monospaced">x</span> is a vector.</p></div>
</div>
<div class="sect4">
<h5 id="ctz">ctz</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">ctz</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>Returns the count of trailing 0-bits in <span class="monospaced">x</span>.
If <span class="monospaced">x</span> is <span class="monospaced">0</span>, returns the size in bits of the type of <span class="monospaced">x</span> or component type of <span class="monospaced">x</span>, if <span class="monospaced">x</span> is a vector.</p></div>
</div>
<div class="sect4">
<h5 id="rotate">rotate</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rotate</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> v<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> i<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>For each element in <span class="monospaced">v</span>, the bits are shifted left by the number of bits given by the corresponding element in <span class="monospaced">i</span> (subject to usual shift modulo rules described in <em><a href="#expressions">Expressions</a> section</em>).
Bits shifted off the left side of the element are shifted back in from the right.</p></div>
</div>
<div class="sect4">
<h5 id="upsample">upsample</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">shortn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">charn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">ucharn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">ushortn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">ucharn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">ucharn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">intn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">shortn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">ushortn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">uintn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">ushortn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">ushortn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">longn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">intn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> lo<span style="color: #990000">);</span>
<span style="color: #008080">ulongn</span> <span style="font-weight: bold"><span style="color: #000000">upsample</span></span><span style="color: #990000">(</span><span style="color: #008080">uintn</span> hi<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> lo<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p><span class="monospaced">result[i] = ((short)hi[i] &lt;&lt; 8) | lo[i]</span></p></div>
<div class="paragraph"><p><span class="monospaced">result[i] = ((ushort)hi[i] &lt;&lt; 8) | lo[i]</span></p></div>
<div class="paragraph"><p><span class="monospaced">result[i] = ((int)hi[i] &lt;&lt; 16) | lo[i]</span></p></div>
<div class="paragraph"><p><span class="monospaced">result[i] = ((uint)hi[i] &lt;&lt; 16) | lo[i]</span></p></div>
<div class="paragraph"><p><span class="monospaced">result[i] = ((long)hi[i] &lt;&lt; 32) | lo[i]</span></p></div>
<div class="paragraph"><p><span class="monospaced">result[i] = ((ulong)hi[i] &lt;&lt; 32) | lo[i]</span></p></div>
</div>
<div class="sect4">
<h5 id="popcount">popcount</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">popcount</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>Returns the number of non-zero bits in <span class="monospaced">x</span>.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="numeric-functions">3.20.3. Numeric functions</h4>
<div class="sect4">
<h5 id="abs">abs</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">ugentype</span> <span style="font-weight: bold"><span style="color: #000000">abs</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>Returns <span class="monospaced">|x|</span>.</p></div>
</div>
<div class="sect4">
<h5 id="abs_diff">abs_diff</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">ugentype</span> <span style="font-weight: bold"><span style="color: #000000">abs_diff</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">|x - y|</span> without modulo overflow.</p></div>
</div>
<div class="sect4">
<h5 id="add_sat">add_sat</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">add_sat</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">x + y</span> and saturates the result.</p></div>
</div>
<div class="sect4">
<h5 id="hadd">hadd</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">hadd</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">(x + y) &gt;&gt; 1</span>.
The intermediate sum does not modulo overflow.</p></div>
</div>
<div class="sect4">
<h5 id="rhadd">rhadd</h5>
<div class="paragraph"><p><span class="monospaced">rhadd</span> <a href="#ftn23">[23</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="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">rhadd</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">(x + y + 1) &gt;&gt; 1</span>.
The intermediate sum does not modulo overflow.</p></div>
</div>
<div class="sect4">
<h5 id="clamp">clamp</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> minval<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> maxval<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">clamp</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">sgentype</span> minval<span style="color: #990000">,</span> <span style="color: #008080">sgentype</span> maxval<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">min(max(x, minval), maxval)</span>.</p></div>
<div class="paragraph"><p>Results are undefined if <span class="monospaced">minval &gt; maxval</span>.</p></div>
</div>
<div class="sect4">
<h5 id="mad_hi">mad_hi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mad_hi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">mul_hi(a, b) + c</span>.</p></div>
</div>
<div class="sect4">
<h5 id="mad_sat">mad_sat</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mad_sat</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">a * b + c</span> and saturates the result.</p></div>
</div>
<div class="sect4">
<h5 id="max">max</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">sgentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">y</span> if <span class="monospaced">x &lt; y</span>, otherwise it returns <span class="monospaced">x</span>.</p></div>
</div>
<div class="sect4">
<h5 id="min">min</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">sgentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">y</span> if <span class="monospaced">y &lt; x</span>, otherwise it returns <span class="monospaced">x</span>.</p></div>
</div>
<div class="sect4">
<h5 id="mul_hi">mul_hi</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">mul_hi</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Computes <span class="monospaced">x * y</span> and returns the high half of the product of <span class="monospaced">x</span> and <span class="monospaced">y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="sub_sat">sub_sat</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">sub_sat</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">x - y</span> and saturates the result.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="bits-operations">3.20.4. 24-bits operations</h4>
<div class="paragraph"><p>In this section fast integer functions are described that can be used for optimizing performance of kernels.</p></div>
<div class="sect4">
<h5 id="mad24">mad24</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">intn</span> <span style="font-weight: bold"><span style="color: #000000">mad24</span></span><span style="color: #990000">(</span><span style="color: #008080">intn</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> y<span style="color: #990000">,</span> <span style="color: #008080">intn</span> z<span style="color: #990000">);</span>
<span style="color: #008080">uintn</span> <span style="font-weight: bold"><span style="color: #000000">mad24</span></span><span style="color: #990000">(</span><span style="color: #008080">uintn</span> x<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> y<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> z<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Multiply two 24-bit integer values <span class="monospaced">x</span> and <span class="monospaced">y</span> and add the 32-bit integer result to the 32-bit integer <span class="monospaced">z</span>.
Refer to definition of mul24 to see how the 24-bit integer multiplication is performed.</p></div>
<div class="listingblock">
<a id="mul24"></a>
<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">intn</span> <span style="font-weight: bold"><span style="color: #000000">mul24</span></span><span style="color: #990000">(</span><span style="color: #008080">intn</span> x<span style="color: #990000">,</span> <span style="color: #008080">intn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">uintn</span> <span style="font-weight: bold"><span style="color: #000000">mul24</span></span><span style="color: #990000">(</span><span style="color: #008080">uintn</span> x<span style="color: #990000">,</span> <span style="color: #008080">uintn</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Multiply two 24-bit integer values <span class="monospaced">x</span> and <span class="monospaced">y</span>.
<span class="monospaced">x</span> and <span class="monospaced">y</span> are 32-bit integers but only the low 24-bits are used to perform the multiplication.
<span class="monospaced">mul24</span> should only be used when values in <span class="monospaced">x</span> and <span class="monospaced">y</span> are in the range [-2<sup>23</sup>, 2<sup>23</sup>-1] if <span class="monospaced">x</span> and <span class="monospaced">y</span> are signed integers and in the range [0, 2<sup>24</sup>-1] if <span class="monospaced">x</span> and <span class="monospaced">y</span> are unsigned integers.
If <span class="monospaced">x</span> and <span class="monospaced">y</span> are not in this range, the multiplication result is implementation-defined.</p></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="relational-functions">3.21. Relational Functions</h3>
<div class="paragraph"><p>The relational and equality operators (<span class="monospaced">&lt;</span>, <span class="monospaced">&lt;=</span>, <span class="monospaced">&gt;</span>, <span class="monospaced">&gt;=</span>, <span class="monospaced">!=</span>, <span class="monospaced">==</span>) can be used with scalar and vector built-in types and produce a scalar or vector boolean result respectively as described in <em><a href="#expressions">Expressions</a> section</em>.</p></div>
<div class="paragraph"><p>Here <span class="monospaced">gentype</span> matches: <span class="monospaced">char</span><em>n</em>, <span class="monospaced">uchar</span><em>n</em>, <span class="monospaced">short</span><em>n</em>, <span class="monospaced">ushort</span><em>n</em>, <span class="monospaced">int</span><em>n</em>, <span class="monospaced">uint</span><em>n</em>, <span class="monospaced">long</span><em>n</em>, <span class="monospaced">ulong</span><em>n</em>, <span class="monospaced">half</span><em>n</em> <a href="#ftn4">[4</a>], <span class="monospaced">float</span><em>n</em> and <span class="monospaced">double</span><em>n</em> <a href="#ftn18">[18</a>].</p></div>
<div class="paragraph"><p>The relational functions <span class="monospaced">isequal</span>, <span class="monospaced">isgreater</span>, <span class="monospaced">isgreaterequal</span>, <span class="monospaced">isless</span>, <span class="monospaced">islessequal</span>, and <span class="monospaced">islessgreater</span> always return <span class="monospaced">false</span> if either argument is not a number (NaN).
<span class="monospaced">isnotequal</span> returns <span class="monospaced">true</span> if one or both arguments are not a number (NaN).</p></div>
<div class="sect3">
<h4 id="header-opencl_relational-synopsis">3.21.1. Header &lt;opencl_relational&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: #000080">#ifdef</span></span> cl_khr_fp16
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isequal</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnotequal</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isgreater</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isgreaterequal</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isless</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">islessequal</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">islessgreater</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isordered</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isunordered</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> x<span style="color: #990000">,</span> <span style="color: #008080">halfn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isfinite</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isinf</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnan</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnormal</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">signbit</span></span><span style="color: #990000">(</span><span style="color: #008080">halfn</span> 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: #000080">#ifdef</span></span> cl_khr_fp64
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isequal</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnotequal</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isgreater</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isgreaterequal</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isless</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">islessequal</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">islessgreater</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isordered</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isunordered</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> x<span style="color: #990000">,</span> <span style="color: #008080">doublen</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isfinite</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isinf</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnan</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnormal</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">signbit</span></span><span style="color: #990000">(</span><span style="color: #008080">doublen</span> t<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span> <span style="font-style: italic"><span style="color: #9A1900">//cl_khr_fp64</span></span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isequal</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnotequal</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isgreater</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isgreaterequal</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isless</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">islessequal</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">islessgreater</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isordered</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isunordered</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> x<span style="color: #990000">,</span> <span style="color: #008080">floatn</span> y<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isfinite</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isinf</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnan</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnormal</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> t<span style="color: #990000">);</span>
<span style="color: #008080">booln</span> <span style="font-weight: bold"><span style="color: #000000">signbit</span></span><span style="color: #990000">(</span><span style="color: #008080">floatn</span> t<span style="color: #990000">);</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">any</span></span><span style="color: #990000">(</span><span style="color: #008080">booln</span> t<span style="color: #990000">);</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">all</span></span><span style="color: #990000">(</span><span style="color: #008080">booln</span> t<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">bitselect</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span>
<span style="color: #008080">gentype</span> <span style="font-weight: bold"><span style="color: #000000">select</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">booln</span> c<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="comparison-operations">3.21.2. Comparison operations</h4>
<div class="sect4">
<h5 id="isequal">isequal</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isequal</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the component-wise compare of <span class="monospaced">x == y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="isnotequal">isnotequal</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnotequal</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the component-wise compare of <span class="monospaced">x != y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="isgreater">isgreater</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isgreater</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the component-wise compare of <span class="monospaced">x &gt; y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="isgreaterequal">isgreaterequal</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isgreaterequal</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the component-wise compare of <span class="monospaced">x &gt;= y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="isless">isless</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isless</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the component-wise compare of <span class="monospaced">x &lt; y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="islessequal">islessequal</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">islessequal</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the component-wise compare of <span class="monospaced">x &lt;= y</span>.</p></div>
</div>
<div class="sect4">
<h5 id="islessgreater">islessgreater</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">islessgreater</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns the component-wise compare of <span class="monospaced">(x &lt; y) || (x &gt; y)</span>.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="test-operations">3.21.3. Test operations</h4>
<div class="sect4">
<h5 id="isfinite">isfinite</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isfinite</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> t<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Test for finite value.</p></div>
</div>
<div class="sect4">
<h5 id="isinf">isinf</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isinf</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> t<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Test for infinity value (positive or negative) .</p></div>
</div>
<div class="sect4">
<h5 id="isnan">isnan</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnan</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> t<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Test for a NaN.</p></div>
</div>
<div class="sect4">
<h5 id="isnormal">isnormal</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isnormal</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> t<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Test for a normal value.</p></div>
</div>
<div class="sect4">
<h5 id="isordered">isordered</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isordered</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Test if arguments are ordered.
<span class="monospaced">isordered()</span> takes arguments <span class="monospaced">x</span> and <span class="monospaced">y</span>, and returns the result of <span class="monospaced">isequal(x, x) &amp;&amp; isequal(y, y)</span>.</p></div>
</div>
<div class="sect4">
<h5 id="isunordered">isunordered</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">isunordered</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> x<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> y<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Test if arguments are unordered.
<span class="monospaced">isunordered()</span> takes arguments <span class="monospaced">x</span> and <span class="monospaced">y</span>, returning <span class="monospaced">true</span> if <span class="monospaced">x</span> or <span class="monospaced">y</span> is NaN, and <span class="monospaced">false</span> otherwise.</p></div>
</div>
<div class="sect4">
<h5 id="signbit">signbit</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">booln</span> <span style="font-weight: bold"><span style="color: #000000">signbit</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> t<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Test for sign bit.
Returns a <span class="monospaced">true</span> if the sign bit in the float is set else returns <span class="monospaced">false</span>.</p></div>
</div>
<div class="sect4">
<h5 id="any">any</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">any</span></span><span style="color: #990000">(</span><span style="color: #008080">booln</span> t<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">true</span> if any component of <span class="monospaced">t</span> is <span class="monospaced">true</span>; otherwise returns <span class="monospaced">false</span>.</p></div>
</div>
<div class="sect4">
<h5 id="all">all</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">all</span></span><span style="color: #990000">(</span><span style="color: #008080">booln</span> t<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Returns <span class="monospaced">true</span> if all components of <span class="monospaced">t</span> are <span class="monospaced">true</span>; otherwise returns <span class="monospaced">false</span>.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="select-operations">3.21.4. Select operations</h4>
<div class="sect4">
<h5 id="bitselect">bitselect</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">bitselect</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> c<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Each bit of the result is the corresponding bit of <span class="monospaced">a</span> if the corresponding bit of <span class="monospaced">c</span> is <span class="monospaced">0</span>.
Otherwise it is the corresponding bit of <span class="monospaced">b</span>.</p></div>
</div>
<div class="sect4">
<h5 id="select">select</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">gentype</span> <span style="font-weight: bold"><span style="color: #000000">select</span></span><span style="color: #990000">(</span><span style="color: #008080">gentype</span> a<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> b<span style="color: #990000">,</span> <span style="color: #008080">booln</span> c<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>For each component of a vector type,</p></div>
<div class="paragraph"><p><span class="monospaced">result[i] = c[i] ? b[i] : a[i]</span>.</p></div>
<div class="paragraph"><p>For a scalar type, <span class="monospaced">result = c ? b : a</span>.</p></div>
<div class="paragraph"><p><span class="monospaced">booln</span> must have the same number of elements as <span class="monospaced">gentype</span>.</p></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="vector-data-load-and-store-functions">3.22. Vector Data Load and Store Functions</h3>
<div class="paragraph"><p>Functions described in this section allow user to read and write vector types from a pointer to memory.
The results of these functions are undefined if the address being read from or written to is not correctly aligned as described in following subsections.</p></div>
<div class="paragraph"><p>Here <span class="monospaced">gentype</span> matches: <span class="monospaced">char</span><em>n</em>, <span class="monospaced">uchar</span><em>n</em>, <span class="monospaced">short</span><em>n</em>, <span class="monospaced">ushort</span><em>n</em>, <span class="monospaced">int</span><em>n</em>, <span class="monospaced">uint</span><em>n</em>, <span class="monospaced">long</span><em>n</em>, <span class="monospaced">ulong</span><em>n</em>, <span class="monospaced">half</span><em>n</em> <a href="#ftn4">[4</a>], <span class="monospaced">float</span><em>n</em> and <span class="monospaced">double</span><em>n</em> <a href="#ftn18">[18</a>].</p></div>
<div class="sect3">
<h4 id="header-opencl_vector_load_store">3.22.1. Header &lt;opencl_vector_load_store&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-style: italic"><span style="color: #9A1900">//basic load &amp; store</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> N<span style="color: #990000">,</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">make_vector_t&lt;T, N&gt;</span> <span style="font-weight: bold"><span style="color: #000000">vload</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">*</span> p<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="color: #008080">size_t</span> N<span style="color: #990000">,</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">make_vector_t&lt;T, N&gt; vload(size_t offset, const constant_ptr&lt;T&gt;</span> p<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">vstore</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> data<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> vector_element_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> p<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//half load &amp; store</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;float, N&gt;</span> <span style="font-weight: bold"><span style="color: #000000">vload_half</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> half<span style="color: #990000">*</span> p<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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;float, N&gt; vload_half(size_t offset, const constant_ptr&lt;half&gt;</span> p<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="color: #008080">rounding_mode</span> rmode <span style="color: #990000">=</span> rounding_mode<span style="color: #990000">::</span>rte<span style="color: #990000">,</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">vstore_half</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> data<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> half<span style="color: #990000">*</span> p<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">//half array load &amp; store</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;float, N&gt;</span> <span style="font-weight: bold"><span style="color: #000000">vloada_half</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> half<span style="color: #990000">*</span> p<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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;float, N&gt; vloada_half(size_t offset, const constant_ptr&lt;half&gt;</span> p<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="color: #008080">rounding_mode</span> rmode <span style="color: #990000">=</span> rounding_mode<span style="color: #990000">::</span>rte<span style="color: #990000">,</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">vstorea_half</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> data<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> half<span style="color: #990000">*</span> p<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="basic-load-store">3.22.2. Basic load &amp; store</h4>
<div class="sect4">
<h5 id="vload">vload</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="color: #008080">size_t</span> N<span style="color: #990000">,</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">make_vector_t&lt;T, N&gt;</span> <span style="font-weight: bold"><span style="color: #000000">vload</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">*</span> p<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="color: #008080">size_t</span> N<span style="color: #990000">,</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">make_vector_t&lt;T, N&gt; vload(size_t offset, const constant_ptr&lt;T&gt;</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Return <span class="monospaced">sizeof(make_vector_t&lt;T, N&gt;)</span> bytes of data read from address <span class="monospaced">(p + (offset * n))</span>.</p></div>
<div class="paragraph"><p>Requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
The address computed as <span class="monospaced">(p+(offset*n))</span> must be 8-bit aligned if <span class="monospaced">T</span> is <span class="monospaced">char</span>, <span class="monospaced">uchar</span>; 16-bit aligned if <span class="monospaced">T</span> is <span class="monospaced">short</span>, <span class="monospaced">ushort</span>, <span class="monospaced">half</span> <a href="#ftn4">[4</a>]; 32-bit aligned if <span class="monospaced">T</span> is <span class="monospaced">int</span>, <span class="monospaced">uint</span>, <span class="monospaced">float</span>; 64-bit aligned if <span class="monospaced">T</span> is <span class="monospaced">long</span>, <span class="monospaced">ulong</span>, <span class="monospaced">double</span> <a href="#ftn18">[18</a>].
</p>
</li>
<li>
<p>
<span class="monospaced">vload</span> function is only defined for n = 2, 3, 4, 8, 16.
</p>
</li>
<li>
<p>
half version is only defined if <em>cl_khr_fp16</em> is supported.
</p>
</li>
<li>
<p>
double version is only defined if double precision is supported.
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="vstore">vstore</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">vstore</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> data<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> vector_element_t<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Write <span class="monospaced">sizeof(T)</span> bytes given by data to address <span class="monospaced">(p+(offset*n))</span>.</p></div>
<div class="paragraph"><p>Requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
The address computed as <span class="monospaced">(p+(offset*n))</span> must be 8-bit aligned if <span class="monospaced">T</span> is <span class="monospaced">char</span>, <span class="monospaced">uchar</span>; 16-bit aligned if <span class="monospaced">T</span> is <span class="monospaced">short</span>, <span class="monospaced">ushort</span>, <span class="monospaced">half</span> <a href="#ftn4">[4</a>]; 32-bit aligned if <span class="monospaced">T</span> is <span class="monospaced">int</span>, <span class="monospaced">uint</span>, <span class="monospaced">float</span>; 64-bit aligned if <span class="monospaced">T</span> is <span class="monospaced">long</span>, <span class="monospaced">ulong</span>, <span class="monospaced">double</span> <a href="#ftn18">[18</a>].
</p>
</li>
<li>
<p>
<span class="monospaced">vstore</span> function is only defined for n = 2, 3, 4, 8, 16.
</p>
</li>
<li>
<p>
half version is only defined if <em>cl_khr_fp16</em> is supported.
</p>
</li>
<li>
<p>
double version is only defined if double precision is supported.
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect3">
<h4 id="half-vload-vstore">3.22.3. half vload &amp; vstore</h4>
<div class="sect4">
<h5 id="vload_half">vload_half</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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;float, N&gt;</span> <span style="font-weight: bold"><span style="color: #000000">vload_half</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> half<span style="color: #990000">*</span> p<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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;float, N&gt; vload_half(size_t offset, const constant_ptr&lt;half&gt;</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>Read <span class="monospaced">sizeof(halfn)</span> bytes of data from address <span class="monospaced">(p+(offset*n))</span>.
The data read is interpreted as a <span class="monospaced">halfn</span> value.
The <span class="monospaced">halfn</span> value read is converted to a <span class="monospaced">float</span> value and the <span class="monospaced">floatn</span> value is returned.</p></div>
<div class="paragraph"><p>Requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
The read address computed as <span class="monospaced">(p+(offset*n))</span> must be 16-bit aligned.
</p>
</li>
<li>
<p>
<span class="monospaced">vload_half</span> function is only defined for n = 1, 2, 3, 4, 8, 16.
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="vstore_half">vstore_half</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="color: #008080">rounding_mode</span> rmode <span style="color: #990000">=</span> rounding_mode<span style="color: #990000">::</span>rte<span style="color: #990000">,</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">vstore_half</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> data<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> half<span style="color: #990000">*</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>The <span class="monospaced">T</span> value given by data is first converted to a <span class="monospaced">halfn</span> value using the appropriate rounding mode.
The <span class="monospaced">half</span> value is then written to address computed as <span class="monospaced">(p+offset)</span>.</p></div>
<div class="paragraph"><p>Requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
The address computed as <span class="monospaced">(p+offset)</span> must be 16-bit aligned.
</p>
</li>
<li>
<p>
<span class="monospaced">T</span> can be <span class="monospaced">floatn</span> or <span class="monospaced">doublen</span> <a href="#ftn18">[18</a>].
</p>
</li>
<li>
<p>
double version is only defined if double precision is supported.
</p>
</li>
<li>
<p>
<span class="monospaced">vstore_half</span> function is only defined for n = 1, 2, 3, 4, 8, 16.
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect3">
<h4 id="half-array-vload-vstore">3.22.4. half array vload &amp; vstore</h4>
<div class="sect4">
<h5 id="vloada_half">vloada_half</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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;float, N&gt;</span> <span style="font-weight: bold"><span style="color: #000000">vloada_half</span></span><span style="color: #990000">(</span><span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> half<span style="color: #990000">*</span> p<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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">make_vector_t&lt;float, N&gt; vloada_half(size_t offset, const constant_ptr&lt;half&gt;</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>For <span class="monospaced">N</span> = 2, 4, 8 and 16 read <span class="monospaced">sizeof(halfn)</span> bytes of data from address <span class="monospaced">(p+(offset*n))</span>.
The data read is interpreted as a <span class="monospaced">halfn</span> value.
The <span class="monospaced">halfn</span> value read is converted to a <span class="monospaced">floatn</span> value and the <span class="monospaced">floatn</span> value is returned.</p></div>
<div class="paragraph"><p>Requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
The address computed as <span class="monospaced">(p+(offset*n))</span> must be aligned to <span class="monospaced">sizeof(halfn)</span> bytes.
</p>
</li>
<li>
<p>
For n = 3, <span class="monospaced">vloada_half</span> reads a <span class="monospaced">half3</span> from address <span class="monospaced">(p+(offset*4))</span> and returns a <span class="monospaced">float3</span>.
The address computed as <span class="monospaced">(p+(offset*4))</span> must be aligned to <span class="monospaced">sizeof(half)*4</span> bytes.
</p>
</li>
<li>
<p>
<span class="monospaced">vloada_half</span> function is only defined for <span class="monospaced">N</span> = 2, 3, 4, 8, 16.
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="vstorea_half">vstorea_half</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="color: #008080">rounding_mode</span> rmode <span style="color: #990000">=</span> rounding_mode<span style="color: #990000">::</span>rte<span style="color: #990000">,</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">vstorea_half</span></span><span style="color: #990000">(</span><span style="color: #008080">T</span> data<span style="color: #990000">,</span> <span style="color: #008080">size_t</span> offset<span style="color: #990000">,</span> half<span style="color: #990000">*</span> p<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>The <span class="monospaced">T</span> value is converted to a <span class="monospaced">halfn</span> value using the appropriate rounding mode.
For n = 2, 4, 8 or 16, the halfn value is written to the address computed as <span class="monospaced">(p+(offset*n))</span>.
For n = 3, the <span class="monospaced">half3</span> value is written to the address computed as <span class="monospaced">(p+(offset*4))</span>.
The address computed as <span class="monospaced">(p+(offset*4))</span> must be aligned to <span class="monospaced">sizeof(half)*4</span> bytes.</p></div>
<div class="paragraph"><p>Requirements:</p></div>
<div class="ulist"><ul>
<li>
<p>
The address computed as <span class="monospaced">(p+(offset* n))</span> must be aligned to <span class="monospaced">sizeof(halfn)</span> bytes.
</p>
</li>
<li>
<p>
For n = 3, the address computed as <span class="monospaced">(p+(offset*4))</span> must be aligned to <span class="monospaced">sizeof(half)*4</span> bytes.
</p>
</li>
<li>
<p>
<span class="monospaced">T</span> can be <span class="monospaced">floatn</span> or <span class="monospaced">doublen</span> <a href="#ftn18">[18</a>].
</p>
</li>
<li>
<p>
double version is only defined if double precision is supported.
</p>
</li>
<li>
<p>
<span class="monospaced">vstorea_half</span> function is only defined for n = 2, 3, 4, 8, 16.
</p>
</li>
</ul></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="printf">3.23. printf</h3>
<div class="paragraph"><p>The OpenCL C++ programming language implements the <span class="monospaced">printf</span> <a href="#ftn24">[24</a>] function.
This function is defined in header <em>&lt;opencl_printf&gt;</em>.</p></div>
<div class="sect3">
<h4 id="header-opencl_printf-synopsis">3.23.1. Header &lt;opencl_printf&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="color: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">printf</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #009900">char</span> <span style="color: #990000">*</span>format<span style="color: #990000">,</span> <span style="color: #990000">...);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="printf-function">3.23.2. printf function</h4>
<div class="sect4">
<h5 id="printf-1">printf</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: #009900">int</span> <span style="font-weight: bold"><span style="color: #000000">printf</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #009900">char</span> <span style="color: #990000">*</span>format<span style="color: #990000">,</span> <span style="color: #990000">...);</span></tt></pre></div></div>
<div class="paragraph"><p>The <span class="monospaced">printf</span> built-in function writes output to an implementation-defined stream such as stdout under control of the string pointed to by <span class="monospaced">format</span> that specifies how subsequent arguments are converted for output.
If there are insufficient arguments for the format, the behavior is undefined.
If the format is exhausted while arguments remain, the excess arguments are evaluated (as always) but are otherwise ignored.
The <span class="monospaced">printf</span> function returns when the end of the format string is encountered.</p></div>
<div class="paragraph"><p><span class="monospaced">printf</span> returns 0 if it was executed successfully and -1 otherwise.</p></div>
<div class="paragraph"><p>Limitations:</p></div>
<div class="ulist"><ul>
<li>
<p>
Format must be known at compile time; otherwise it will be a compile time error.
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="printf-output-synchronization">printf output synchronization</h5>
<div class="paragraph"><p>When the event that is associated with a particular kernel invocation is completed, the output of all <span class="monospaced">printf()</span> calls executed by this kernel invocation is flushed to the implementation-defined output stream.
Calling <span class="monospaced">clFinish</span> on a host command queue flushes all pending output by <span class="monospaced">printf</span> in previously enqueued and completed commands to the implementation-defined output stream.
In the case that <span class="monospaced">printf</span> is executed from multiple work-items concurrently, there is no guarantee of ordering with respect to written data.
For example, it is valid for the output of a work-item with a global id (0,0,1) to appear intermixed with the output of a work-item with a global id (0,0,4) and so on.</p></div>
</div>
<div class="sect4">
<h5 id="printf-format-string">printf format string</h5>
<div class="paragraph"><p>The format shall be a character sequence, beginning and ending in its initial shift state.
The format is composed of zero or more directives: ordinary characters (not <strong>%</strong>), which are copied unchanged to the output stream; and conversion specifications, each of which results in fetching zero or more subsequent arguments, converting them, if applicable, according to the corresponding conversion specifier, and then writing the result to the output stream.
The format is in the <span class="monospaced">constant</span> address space and must be resolvable at compile time i.e. cannot be dynamically created by the executing program, itself.</p></div>
<div class="paragraph"><p>Each conversion specification is introduced by the character <strong>%</strong>.
After the <strong>%</strong>, the following appear in sequence:</p></div>
<div class="ulist"><ul>
<li>
<p>
Zero or more <em>flags</em> (in any order) that modify the meaning of the conversion specification.
</p>
</li>
<li>
<p>
An optional minimum <em>field width</em>.
If the converted value has fewer characters than the field width, it is padded with spaces (by default) on the left (or right, if the left adjustment flag, described later, has been given) to the field width.
The field width takes the form of a nonnegative decimal integer. <a href="#ftn25">[25</a>]
</p>
</li>
<li>
<p>
An optional <em>precision</em> that gives the minimum number of digits to appear for the <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em>, and <em>X</em> conversions, the number of digits to appear after the decimal-point character for <em>a</em>, <em>A</em>, <em>e</em>, <em>E</em>, <em>f</em>, and <em>F</em> conversions, the maximum number of significant digits for the <em>g</em> and <em>G</em> conversions, or the maximum number of bytes to be written for <em>s</em> conversions.
The precision takes the form of a period (.) followed by an optional decimal integer; if only the period is specified, the precision is taken as zero.
If a precision appears with any other conversion specifier, the behavior is undefined.
</p>
</li>
<li>
<p>
An optional <em>vector specifier</em>.
</p>
</li>
<li>
<p>
A <em>length modifier</em> that specifies the size of the argument.
The <em>length modifier</em> is required with a vector specifier and together specifies the vector type.
Implicit conversions between vector types are disallowed (as per <em><a href="#implicit-type-conversions">Implicit Type Conversions</a> section</em>).
If the <em>vector specifier</em> is not specified, the <em>length modifier</em> is optional.
</p>
</li>
<li>
<p>
A <em>conversion specifier</em> character that specifies the type of conversion to be applied.
</p>
</li>
</ul></div>
<div class="paragraph"><p>The flag characters and their meanings are:</p></div>
<div class="hdlist"><table>
<tr>
<td class="hdlist1">
<em>-</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
The result of the conversion is left-justified within the field.
(It is right-justified if this flag is not specified.)
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>+</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
The result of a signed conversion always begins with a plus or minus sign.
(It begins with a sign only when a negative value is converted if this flag is not specified.) <a href="#ftn26">[26</a>]
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>space</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
If the first character of a signed conversion is not a sign, or if a signed conversion results in no characters, a space is prefixed to the result.
If the <em>space</em> and <em>+</em> flags both appear, the <em>space</em> flag is ignored.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>#</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
The result is converted to an "alternative form".
For <em>o</em> conversion, it increases the precision, if and only if necessary, to force the first digit of the result to be a zero (if the value and precision are both 0, a single 0 is printed).
For <em>x</em> (or <em>X</em>) conversion, a nonzero result has <strong>0x</strong> (or <strong>0X</strong>) prefixed to it.
For <em>a</em>, <em>A</em>, <em>e</em>, <em>E</em>, <em>f</em>, <em>F</em>, <em>g</em> and <em>G</em> conversions, the result of converting a floating-point number always contains a decimal-point character, even if no digits follow it.
(Normally, a decimal-point character appears in the result of these conversions only if a digit follows it.) For <em>g</em> and <em>G</em> conversions, trailing zeros are <em>not</em> removed from the result.
For other conversions, the behavior is undefined.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>0</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
For <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em>, <em>X</em>, <em>a</em>, <em>A</em>, <em>e</em>, <em>E</em>, <em>f</em>, <em>F</em>, <em>g</em> and <em>G</em> conversions, leading zeros (following any indication of sign or base) are used to pad to the field width rather than performing space padding, except when converting an infinity or NaN.
If the <em>0</em> and <em>-</em> flags both appear, the <em>0</em> flag is ignored.
For <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em>, and <em>X</em> conversions, if a precision is specified, the <em>0</em> flag is ignored.
For other conversions, the behavior is undefined.
</p>
</td>
</tr>
</table></div>
<div class="paragraph"><p>The vector specifier and its meaning is:</p></div>
<div class="hdlist"><table>
<tr>
<td class="hdlist1">
<em>vn</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
Specifies that a following <em>a</em>, <em>A</em>, <em>e</em>, <em>E</em>, <em>f</em>, <em>F</em>, <em>g</em>, <em>G</em>, <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em> or <em>X</em> conversion specifier applies to a vector argument, where <em>n</em> is the size of the vector and must be 2, 3, 4, 8 or 16.
</p>
<div class="paragraph"><p>The vector value is displayed in the following general form:</p></div>
<div class="paragraph"><p>value1 <em>C</em> value2 <em>C</em> &#8230; <em>C</em> value<em>n</em></p></div>
<div class="paragraph"><p>where <em>C</em> is a separator character.
The value for this separator character is a comma.</p></div>
</td>
</tr>
</table></div>
<div class="paragraph"><p>If the vector specifier is not used, the length modifiers and their meanings are:</p></div>
<div class="hdlist"><table>
<tr>
<td class="hdlist1">
<em>hh</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
Specifies that a following <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em>, or <em>X</em> conversion specifier applies to a <span class="monospaced">char</span> or <span class="monospaced">uchar</span> argument (the argument will have been promoted according to the integer promotions, but its value shall be converted to <span class="monospaced">char</span> or <span class="monospaced">uchar</span> before printing).
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>h</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
Specifies that a following <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em> or <em>X</em> conversion specifier applies to a <span class="monospaced">short</span> or <span class="monospaced">ushort</span> argument (the argument will have been promoted according to the integer promotions, but its value shall be converted to <span class="monospaced">short</span> or <span class="monospaced">ushort</span> before printing).
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>l</em> (ell)
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
Specifies that a following <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em> or <em>X</em> conversion specifier applies to a <span class="monospaced">long</span> or <span class="monospaced">ulong</span> argument.
The <em>l</em> modifier is supported by the full profile.
For the embedded profile, the <em>l</em> modifier is supported only if 64-bit integers are supported by the device.
</p>
</td>
</tr>
</table></div>
<div class="paragraph"><p>If the vector specifier is used, the length modifiers and their meanings are:</p></div>
<div class="hdlist"><table>
<tr>
<td class="hdlist1">
<em>hh</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
Specifies that a following <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em> or <em>X</em> conversion specifier applies to a <span class="monospaced">char</span><em>n</em> or <span class="monospaced">uchar</span><em>n</em> argument (the argument will not be promoted).
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>h</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
Specifies that a following <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em> or <em>X</em> conversion specifier applies to a <span class="monospaced">short</span><em>n</em> or <span class="monospaced">ushort</span><em>n</em> argument (the argument will not be promoted); that a following <em>a</em>, <em>A</em>, <em>e</em>, <em>E</em>, <em>f</em>, <em>F</em>, <em>g</em> or <em>G</em> conversion specifier applies to a <span class="monospaced">half</span><em>n</em> argument.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>hl</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
This modifier can only be used with the vector specifier.
Specifies that a following <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em> or <em>X</em> conversion specifier applies to an <span class="monospaced">int</span><em>n</em> or <span class="monospaced">uint</span><em>n</em> argument; that a following <em>a</em>, <em>A</em>, <em>e</em>, <em>E</em>, <em>f</em>, <em>F</em>, <em>g</em> or <em>G</em> conversion specifier applies to a <span class="monospaced">float</span><em>n</em> argument.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>l</em> (ell)
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
Specifies that a following <em>d</em>, <em>i</em>, <em>o</em>, <em>u</em>, <em>x</em> or <em>X</em> conversion specifier applies to a <span class="monospaced">long</span><em>n</em> or <span class="monospaced">ulong</span><em>n</em> argument; that a following <em>a</em>, <em>A</em>, <em>e</em>, <em>E</em>, <em>f</em>, <em>F</em>, <em>g</em> or <em>G</em> conversion specifier applies to a <span class="monospaced">double</span><em>n</em> argument.
The <em>l</em> modifier is supported by the full profile.
For the embedded profile, the <em>l</em> modifier is supported only if 64-bit integers or double-precision floating-point are supported by the device.
</p>
</td>
</tr>
</table></div>
<div class="paragraph"><p>If a vector specifier appears without a length modifier, the behavior is undefined.
The vector data type described by the vector specifier and length modifier must match the data type of the argument; otherwise the behavior is undefined.</p></div>
<div class="paragraph"><p>If a length modifier appears with any conversion specifier other than as specified above, the behavior is undefined.</p></div>
<div class="paragraph"><p>The conversion specifiers and their meanings are:</p></div>
<div class="hdlist"><table>
<tr>
<td class="hdlist1">
<em>d</em>,&#160;<em>i</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
The <span class="monospaced">int</span>, <span class="monospaced">char</span><em>n</em>, <span class="monospaced">short</span><em>n</em>, <span class="monospaced">int</span><em>n</em> or <span class="monospaced">long</span><em>n</em> argument is converted to signed decimal in the style <em>[-]dddd</em>.
The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it is expanded with leading zeros.
The default precision is 1. The result of converting a zero value with a precision of zero is no characters.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>o</em>,&#160;<em>u</em>, <em>x</em>,&#160;<em>X</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
The <span class="monospaced">uint</span>, <span class="monospaced">uchar</span><em>n</em>, <span class="monospaced">ushort</span><em>n</em>, <span class="monospaced">uint</span><em>n</em> or <span class="monospaced">ulong</span><em>n</em> argument is converted to unsigned octal (<em>o</em>), unsigned decimal (<em>u</em>), or unsigned hexadecimal notation (<em>x</em> or <em>X</em>) in the style <em>dddd</em>; the letters <strong>abcdef</strong> are used for <em>x</em> conversion and the letters <strong>ABCDEF</strong> for <em>X</em> conversion.
The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it is expanded with leading zeros.
The default precision is 1.
The result of converting a zero value with a precision of zero is no characters.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>f</em>,&#160;<em>F</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing a floating-point number is converted to decimal notation in the style <em>[-]ddd</em><strong>.</strong><em>ddd</em>, where the number of digits after the decimal-point character is equal to the precision specification.
If the precision is missing, it is taken as 6; if the precision is zero and the <em>#</em> flag is not specified, no decimal-point character appears.
If a decimal-point character appears, at least one digit appears before it.
The value is rounded to the appropriate number of digits.
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing an infinity is converted in one of the styles <em>[-]</em><strong>inf</strong> or <em>[-]</em><strong>infinity</strong> - which style is implementation-defined.
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing a NaN is converted in one of the styles <em>[-]</em><strong>nan</strong> or <em>[-]</em><strong>nan</strong>(<em>n-char-sequence</em>) - which style, and the meaning of any <em>n-char-sequence</em>, is implementation-defined.
The <em>F</em> conversion specifier produces <strong>INF</strong>, <strong>INFINITY</strong>, or <strong>NAN</strong> instead of <strong>inf</strong>, <strong>infinity</strong>, or <strong>nan</strong>, respectively. <a href="#ftn27">[27</a>]
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>e</em>,&#160;<em>E</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing a floating-point number is converted in the style <em>[-]d</em><strong>.</strong><em>ddd</em><strong>e</strong><em>±dd</em>, where there is one digit (which is nonzero if the argument is nonzero) before the decimal-point character and the number of digits after it is equal to the precision; if the precision is missing, it is taken as 6; if the precision is zero and the <em>#</em> flag is not specified, no decimal-point character appears.
The value is rounded to the appropriate number of digits.
The <em>E</em> conversion specifier produces a number with <strong>E</strong> instead of <strong>e</strong> introducing the exponent.
The exponent always contains at least two digits, and only as many more digits as necessary to represent the exponent.
If the value is zero, the exponent is zero.
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing an infinity or NaN is converted in the style of an <em>f</em> or <em>F</em> conversion specifier.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>g</em>,&#160;<em>G</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing a floating-point number is converted in style <em>f</em> or <em>e</em> (or in style <em>F</em> or <em>E</em> in the case of a <em>G</em> conversion specifier), depending on the value converted and the precision.
Let <em>P</em> equal the precision if nonzero, 6 if the precision is omitted, or 1 if the precision is zero.
Then, if a conversion with style <em>E</em> would have an exponent of <em>X</em>:
</p>
<div class="ulist"><ul>
<li>
<p>
if <em>P &gt; X ≥ −4</em>, the conversion is with style <em>f</em> (or <em>F</em>) and precision <em>P − (X + 1)</em>.
</p>
</li>
<li>
<p>
otherwise, the conversion is with style <em>e</em> (or <em>E</em>) and precision <em>P − 1</em>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>Finally, unless the <em>#</em> flag is used, any trailing zeros are removed from the fractional portion of the result and the decimal-point character is removed if there is no fractional portion remaining.
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing an infinity or NaN is converted in the style of an <em>f</em> or <em>F</em> conversion specifier.</p></div>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>a</em>,&#160;<em>A</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing a floating-point number is converted in the style <em>[-]</em><strong>0x</strong><em>h</em><strong>.</strong><em>hhhh</em><strong>p</strong><em>±d</em>, where there is one hexadecimal digit (which is nonzero if the argument is a normalized floating-point number and is otherwise unspecified) before the decimal-point character <a href="#ftn28">[28</a>] and the number of hexadecimal digits after it is equal to the precision; if the precision is missing, then the precision is sufficient for an exact representation of the value; if the precision is zero and the <em>#</em> flag is not specified, no decimal point character appears.
The letters <strong>abcdef</strong> are used for <em>a</em> conversion and the letters <strong>ABCDEF</strong> for <em>A</em> conversion.
The <em>A</em> conversion specifier produces a number with <strong>X</strong> and <strong>P</strong> instead of <strong>x</strong> and <strong>p</strong>.
The exponent always contains at least one digit, and only as many more digits as necessary to represent the decimal exponent of 2.
If the value is zero, the exponent is zero.
A <span class="monospaced">double</span>, <span class="monospaced">half</span><em>n</em>, <span class="monospaced">float</span><em>n</em> or <span class="monospaced">double</span><em>n</em> argument representing an infinity or NaN is converted in the style of an <em>f</em> or <em>F</em> conversion specifier.
</p>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">The conversion specifiers <em>e</em>, <em>E</em>, <em>g</em>, <em>G</em>, <em>a</em>, <em>A</em> convert a <span class="monospaced">float</span> or <span class="monospaced">half</span> argument that is a scalar type to a <span class="monospaced">double</span> only if the <span class="monospaced">double</span> data type is supported.
If the <span class="monospaced">double</span> data type is not supported, the argument will be a <span class="monospaced">float</span> instead of a <span class="monospaced">double</span> and the <span class="monospaced">half</span> type will be converted to a <span class="monospaced">float</span>.</td>
</tr></table>
</div>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>c</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
The <span class="monospaced">int</span> argument is converted to an <span class="monospaced">uchar</span> and the resulting character is written.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>s</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
The argument shall be a literal string. <a href="#ftn29">[29</a>]
Characters from the literal string array are written up to (but not including) the terminating null character.
If the precision is specified, no more than that many bytes are written.
If the precision is not specified or is greater than the size of the array, the array shall contain a null character.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>p</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
The argument shall be a pointer to <span class="monospaced">void</span>.
The pointer can refer to a memory region in the global, constant, local, private or generic address space.
The value of the pointer is converted to a sequence of printing characters in an implementation-defined manner.
</p>
</td>
</tr>
<tr>
<td class="hdlist1">
<em>%</em>
<br>
</td>
<td class="hdlist2">
<p style="margin-top: 0;">
A <strong>%</strong> character is written.
No argument is converted. The complete conversion specification shall be <strong>%%</strong>.
</p>
</td>
</tr>
</table></div>
<div class="paragraph"><p>If a conversion specification is invalid, the behavior is undefined.
If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.</p></div>
<div class="paragraph"><p>In no case does a nonexistent or small field width cause truncation of a field; if the result of a conversion is wider than the field width, the field is expanded to contain the conversion result.</p></div>
<div class="paragraph"><p>For <em>a</em> and <em>A</em> conversions, the value is correctly rounded to a hexadecimal floating number with the given precision.</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">uchar4</span> uc <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">0xFA</span><span style="color: #990000">,</span> <span style="color: #993399">0xFB</span><span style="color: #990000">,</span> <span style="color: #993399">0xFC</span><span style="color: #990000">,</span> <span style="color: #993399">0xFD</span><span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000000">printf</span></span><span style="color: #990000">(</span><span style="color: #FF0000">"f4 = %2.2v4hlf</span><span style="color: #CC33CC">\n</span><span style="color: #FF0000">"</span><span style="color: #990000">,</span> f<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000000">printf</span></span><span style="color: #990000">(</span><span style="color: #FF0000">"uc = %#v4hhx</span><span style="color: #CC33CC">\n</span><span style="color: #FF0000">"</span><span style="color: #990000">,</span> uc<span style="color: #990000">);</span></tt></pre></div></div>
<div class="paragraph"><p>The above two <span class="monospaced">printf</span> calls print the following:</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>f4 = 1.00,2.00,3.00,4.00
uc = 0xfa,0xfb,0xfc,0xfd</pre>
</div></div>
<div class="paragraph"><p>A few examples of valid use cases of <span class="monospaced">printf</span> for the conversion specifier <em>s</em> are given below.
The argument value must be a pointer to a literal string.</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_printf&gt;</span>
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="color: #990000">...</span> <span style="color: #990000">)</span>
<span style="color: #FF0000">{</span>
cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">printf</span></span><span style="color: #990000">(</span><span style="color: #FF0000">"%s</span><span style="color: #CC33CC">\n</span><span style="color: #FF0000">"</span><span style="color: #990000">,</span> <span style="color: #FF0000">"this is a test string</span><span style="color: #CC33CC">\n</span><span style="color: #FF0000">"</span><span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>A few examples of invalid use cases of <span class="monospaced">printf</span> for the conversion specifier <em>s</em> 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_printf&gt;</span>
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="color: #009900">char</span> <span style="color: #990000">*</span>s<span style="color: #990000">,</span> <span style="color: #990000">...</span> <span style="color: #990000">)</span>
<span style="color: #FF0000">{</span>
cl<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">printf</span></span><span style="color: #990000">(</span><span style="color: #FF0000">"%s</span><span style="color: #CC33CC">\n</span><span style="color: #FF0000">"</span><span style="color: #990000">,</span> s<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>A few examples of invalid use cases of <span class="monospaced">printf</span> where data types given by the vector specifier and length modifier do not match the argument type 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_printf&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">my_kernel</span></span><span style="color: #990000">(</span> <span style="color: #990000">...</span> <span style="color: #990000">)</span>
<span style="color: #FF0000">{</span>
<span style="color: #008080">uint2</span> ui <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">uint2</span></span><span style="color: #990000">(</span><span style="color: #993399">0x12345678</span><span style="color: #990000">,</span> <span style="color: #993399">0x87654321</span><span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000000">printf</span></span><span style="color: #990000">(</span><span style="color: #FF0000">"unsigned short value = (%#v2hx)</span><span style="color: #CC33CC">\n</span><span style="color: #FF0000">"</span><span style="color: #990000">,</span> ui<span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #000000">printf</span></span><span style="color: #990000">(</span><span style="color: #FF0000">"unsigned char value = (%#v2hhx)</span><span style="color: #CC33CC">\n</span><span style="color: #FF0000">"</span><span style="color: #990000">,</span> ui<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
<div class="sect3">
<h4 id="differences-between-opencl-c-and-c14-printf">3.23.3. Differences between OpenCL C++ and C++14 printf</h4>
<div class="ulist"><ul>
<li>
<p>
The <em>l</em> modifier followed by a <em>c</em> conversion specifier or <em>s</em> conversion specifier is not supported by OpenCL C++.
</p>
</li>
<li>
<p>
The <em>ll</em>, <em>j</em>, <em>z</em>, <em>t</em>, and <em>L</em> length modifiers are not supported by OpenCL C++ but are reserved.
</p>
</li>
<li>
<p>
The <em>n</em> conversion specifier is not supported by OpenCL C++ but is reserved.
</p>
</li>
<li>
<p>
OpenCL C++ adds the optional <em>vn</em> vector specifier to support printing of vector types.
</p>
</li>
<li>
<p>
The conversion specifiers <em>f</em>, <em>F</em>, <em>e</em>, <em>E</em>, <em>g</em>, <em>G</em>, <em>a</em>, <em>A</em> convert a float argument to a double only if the double data type is supported.
Refer to the description of <span class="monospaced">CL_DEVICE_DOUBLE_FP_CONFIG</span> in <em>table 4.3</em>.
If the double data type is not supported, the argument will be a float instead of a double.
</p>
</li>
<li>
<p>
For the embedded profile, the <em>l</em> length modifier is supported only if 64-bit integers are supported.
</p>
</li>
<li>
<p>
In OpenCL C++, <span class="monospaced">printf</span> returns 0 if it was executed successfully and -1 otherwise vs. C++14 where <span class="monospaced">printf</span> returns the number of characters printed or a negative value if an output or encoding error occurred.
</p>
</li>
<li>
<p>
In OpenCL C++, the conversion specifier <em>s</em> can only be used for arguments that are literal strings.
</p>
</li>
</ul></div>
</div>
</div>
<div class="sect2">
<h3 id="atomic-operations-library">3.24. Atomic Operations Library</h3>
<div class="paragraph"><p>The OpenCL C++ programming language implements a subset of the C++14 atomics (refer to <em>chapter 29</em> of the C++14 specification) and synchronization operations.
These operations play a special role in making assignments in one work-item visible to another.
Please note that this chapter only presents synopsis of the atomics library and differences from C++14 specification.</p></div>
<div class="sect3">
<h4 id="header-opencl_atomic-synopsis">3.24.1. Header &lt;opencl_atomic&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> memory_order<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">enum</span></span> memory_scope<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">struct</span></span> <span style="color: #008080">atomic</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// specialization for scalar types T that satisfy cl::is_integral&lt;T&gt;</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">atomic</span><span style="color: #990000">&lt;</span>integral<span style="color: #990000">&gt;;</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">struct</span></span> <span style="color: #008080">atomic</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_int <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">int</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_uint <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">unsigned</span> <span style="color: #009900">int</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_long <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">long</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_ulong <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">unsigned</span> <span style="color: #009900">long</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_float <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">float</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_fp64<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_double <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">double</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
__INTPTR_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span><span style="color: #990000">)</span> <span style="color: #990000">||</span>
__INTPTR_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_intptr_t <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>intptr_t<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_uintptr_t <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>uintptr_t<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
__SIZE_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span><span style="color: #990000">)</span> <span style="color: #990000">||</span>
__SIZE_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_size_t <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>size_t<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
__PTRDIFF_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span><span style="color: #990000">)</span> <span style="color: #990000">||</span>
__PTRDIFF_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_ptrdiff_t <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>ptrdiff_t<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// Please note that all operations taking memory_order as a parameter have,</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// in addition to cpp14 specification, additional parameter for memory_scope</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: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">atomic_is_lock_free</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*)</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: #000000">atomic_is_lock_free</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*)</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">atomic_init</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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">void</span> <span style="font-weight: bold"><span style="color: #000000">atomic_init</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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">void</span> <span style="font-weight: bold"><span style="color: #000000">atomic_store</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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">void</span> <span style="font-weight: bold"><span style="color: #000000">atomic_store</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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">void</span> <span style="font-weight: bold"><span style="color: #000000">atomic_store_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_store_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_load</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*)</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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_load</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*)</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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_load_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_load_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> memory_order<span style="color: #990000">,</span> memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_exchange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_exchange</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_exchange_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_exchange_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<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: #000000">atomic_compare_exchange_weak</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">*,</span> 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: #000000">atomic_compare_exchange_weak</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">*,</span> 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: #000000">atomic_compare_exchange_strong</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">*,</span> 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: #000000">atomic_compare_exchange_strong</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">*,</span> 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: #000000">atomic_compare_exchange_weak_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">*,</span> T<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #000000">atomic_compare_exchange_weak_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<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: #000000">atomic_compare_exchange_strong_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">*,</span> T<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #000000">atomic_compare_exchange_strong_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">*,</span> T<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// Please note that all operations taking memory_order as a parameter have</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// additional overloads, in addition to cpp14 specification, taking both</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// memory_order and memory_scope parameters.</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">atomic_fetch_add</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_add</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_add_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_add_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_sub</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_sub</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_sub_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_sub_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_and</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_and</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_and_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_and_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_or</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_or</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_or_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_or_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_xor</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_xor</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_xor_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_xor_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">//OpenCL specific min/max atomics:</span></span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_min</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_min</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_min_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_min_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_max</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_max</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> 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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_max_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_max_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<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">atomic_store</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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">atomic_store</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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">atomic_store_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_store_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_load</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_load</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_load_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_load_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_exchange</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_exchange</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_exchange_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_exchange_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #000000">atomic_compare_exchange_strong</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> T<span style="color: #990000">*</span> expected<span style="color: #990000">,</span>
<span style="color: #008080">T</span> desired<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: #000000">atomic_compare_exchange_strong</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> T<span style="color: #990000">*</span> expected<span style="color: #990000">,</span>
<span style="color: #008080">T</span> desired<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: #000000">atomic_compare_exchange_strong_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> T<span style="color: #990000">*</span> expected<span style="color: #990000">,</span>
<span style="color: #008080">T</span> desired<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #000000">atomic_compare_exchange_strong_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span>
T<span style="color: #990000">*</span> expected<span style="color: #990000">,</span> <span style="color: #008080">T</span> desired<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span>
memory_scope<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: #000000">atomic_compare_exchange_weak</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> T<span style="color: #990000">*</span> expected<span style="color: #990000">,</span>
<span style="color: #008080">T</span> desired<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: #000000">atomic_compare_exchange_weak</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> T<span style="color: #990000">*</span> expected<span style="color: #990000">,</span>
<span style="color: #008080">T</span> desired<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: #000000">atomic_compare_exchange_weak_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> T<span style="color: #990000">*</span> expected<span style="color: #990000">,</span>
<span style="color: #008080">T</span> desired<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #000000">atomic_compare_exchange_weak_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span>
T<span style="color: #990000">*</span> expected<span style="color: #990000">,</span> <span style="color: #008080">T</span> desired<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_add</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_add</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_add_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_add_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_and</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_and</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_and_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_and_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_or</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_or</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_or_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_or_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_sub</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_sub</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_sub_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_sub_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_xor</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_xor</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_xor_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fetch_xor_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">T</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
__SIZE_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span><span style="color: #990000">)</span> <span style="color: #990000">||</span>
__SIZE_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</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">atomic_fetch_add</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_add</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_add_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_fetch_add_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<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">atomic_fetch_and</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_and</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_and_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_fetch_and_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<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">atomic_fetch_or</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_or</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_or_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_fetch_or_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<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">atomic_fetch_sub</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_sub</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_sub_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_fetch_sub_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<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">atomic_fetch_xor</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_xor</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<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">atomic_fetch_xor_explicit</span></span><span style="color: #990000">(</span>atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_fetch_xor_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic<span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;*</span> object<span style="color: #990000">,</span> <span style="color: #008080">ptrdiff_t</span> value<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fence</span></span><span style="color: #990000">(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">,</span> <span style="color: #008080">memory_order</span> order<span style="color: #990000">,</span>
<span style="color: #008080">memory_scope</span> scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">ATOMIC_VAR_INIT</span></span><span style="color: #990000">(</span>value<span style="color: #990000">)</span> as described in <span style="color: #008080">cpp14</span> specification <span style="color: #990000">[</span>atomics<span style="color: #990000">.</span>types<span style="color: #990000">.</span>operations<span style="color: #990000">]</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="order-and-scope">3.24.2. Order and scope</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> memory_order
<span style="color: #FF0000">{</span>
memory_order_relaxed<span style="color: #990000">,</span>
memory_order_acquire<span style="color: #990000">,</span>
memory_order_release<span style="color: #990000">,</span>
memory_order_acq_rel<span style="color: #990000">,</span>
memory_order_seq_cst
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">enum</span></span> memory_scope
<span style="color: #FF0000">{</span>
memory_scope_all_svm_devices<span style="color: #990000">,</span>
memory_scope_device<span style="color: #990000">,</span>
memory_scope_work_group<span style="color: #990000">,</span>
memory_scope_sub_group<span style="color: #990000">,</span>
memory_scope_work_item
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>An enumeration <span class="monospaced">memory_order</span> is described in section [atomics.order] of C++14 specification. <a href="#ftn7">[7</a>]</p></div>
<div class="paragraph"><p>The enumerated type <span class="monospaced">memory_scope</span> specifies whether the memory ordering constraints given by <span class="monospaced">memory_order</span> apply to work-items in a work-group or work-items of a kernel(s) executing on the device or across devices (in the case of shared virtual memory). Its enumeration constants are as follows:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">memory_scope_work_item</span> <a href="#ftn8">[8</a>]
</p>
</li>
<li>
<p>
<span class="monospaced">memory_scope_sub_group</span>
</p>
</li>
<li>
<p>
<span class="monospaced">memory_scope_work_group</span>
</p>
</li>
<li>
<p>
<span class="monospaced">memory_scope_device</span>
</p>
</li>
<li>
<p>
<span class="monospaced">memory_scope_all_svm_devices</span>
</p>
</li>
</ul></div>
<div class="paragraph"><p>The memory scope should only be used when performing atomic operations to global memory.
Atomic operations to local memory only guarantee memory ordering in the work-group not across work-groups and therefore ignore the <span class="monospaced">memory_scope</span> value.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">With fine-grained system SVM, sharing happens at the granularity of individual loads and stores anywhere in host memory.
Memory consistency is always guaranteed at synchronization points, but to obtain finer control over consistency, the OpenCL atomics functions may be used to ensure that the updates to individual data values made by
one unit of execution are visible to other execution units.
In particular, when a host thread needs fine control over the consistency of memory that is shared with one or more OpenCL devices, it must use atomic and fence operations that are compatible with the C++14 atomic operations <a href="#ftn9">[9</a>].</td>
</tr></table>
</div>
</div>
<div class="sect3">
<h4 id="atomic-lock-free-property">3.24.3. Atomic lock-free property</h4>
<div class="paragraph"><p>OpenCL C++ requires all atomic types to be lock free.</p></div>
</div>
<div class="sect3">
<h4 id="atomic-types">3.24.4. Atomic types</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">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">atomic</span>
<span style="color: #FF0000">{</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_lock_free</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_lock_free</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">store</span></span><span style="color: #990000">(</span>T<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">store</span></span><span style="color: #990000">(</span>T<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">load</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">load</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<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">operator</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<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">T</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">T</span> <span style="font-weight: bold"><span style="color: #000000">exchange</span></span><span style="color: #990000">(</span>T<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">exchange</span></span><span style="color: #990000">(</span>T<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">()</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">(</span>T<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> atomic<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
atomic<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> atomic<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
atomic<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> atomic<span style="color: #990000">&amp;)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>T<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>T<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;&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">atomic</span><span style="color: #990000">&lt;</span>integral<span style="color: #990000">&gt;</span>
<span style="color: #FF0000">{</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_lock_free</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_lock_free</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">store</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">store</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">load</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">load</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<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">operator</span></span> <span style="font-weight: bold"><span style="color: #000000">integral</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<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">integral</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">integral</span> <span style="font-weight: bold"><span style="color: #000000">exchange</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">exchange</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">&amp;,</span> integral<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">&amp;,</span> integral<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">&amp;,</span> integral<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">&amp;,</span> integral<span style="color: #990000">,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">&amp;,</span> integral<span style="color: #990000">,</span>
memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">&amp;,</span> integral<span style="color: #990000">,</span>
memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">&amp;,</span> integral<span style="color: #990000">,</span>
memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">&amp;,</span> integral<span style="color: #990000">,</span>
memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_add</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_add</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_sub</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_sub</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_and</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_and</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_or</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_or</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_xor</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_xor</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_min</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_min</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_max</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #000000">fetch_max</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">()</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">(</span>integral<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> atomic<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
atomic<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> atomic<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
atomic<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> atomic<span style="color: #990000">&amp;)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>integral<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>integral<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</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> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</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">integral</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> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</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">integral</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">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</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">integral</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">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</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">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span>integral<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span>integral<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span>integral<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span>integral<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;=(</span>integral<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">&amp;=(</span>integral<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">|=(</span>integral<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">|=(</span>integral<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">^=(</span>integral<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">integral</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">^=(</span>integral<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: #000080">#if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
__SIZE_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span><span style="color: #990000">)</span> <span style="color: #990000">||</span>
__SIZE_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</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">struct</span></span> <span style="color: #008080">atomic</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;</span>
<span style="color: #FF0000">{</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_lock_free</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">is_lock_free</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: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">store</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">store</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">load</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">load</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<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">operator</span></span> T<span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">operator</span></span> T<span style="color: #990000">*()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">exchange</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">exchange</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*&amp;,</span> T<span style="color: #990000">*,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*&amp;,</span> T<span style="color: #990000">*,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*&amp;,</span> T<span style="color: #990000">*,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*&amp;,</span> T<span style="color: #990000">*,</span> memory_order<span style="color: #990000">,</span>
memory_order<span style="color: #990000">,</span> memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*&amp;,</span> T<span style="color: #990000">*,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_weak</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*&amp;,</span> T<span style="color: #990000">*,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*&amp;,</span> T<span style="color: #990000">*,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">compare_exchange_strong</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*&amp;,</span> T<span style="color: #990000">*,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">fetch_add</span></span><span style="color: #990000">(</span>ptrdiff_t<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">fetch_add</span></span><span style="color: #990000">(</span>ptrdiff_t<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">fetch_sub</span></span><span style="color: #990000">(</span>ptrdiff_t<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">fetch_sub</span></span><span style="color: #990000">(</span>ptrdiff_t<span style="color: #990000">,</span> memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">()</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="color: #008080">constexpr</span> <span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">(</span>T<span style="color: #990000">*)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> atomic<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
atomic<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> atomic<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
atomic<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> atomic<span style="color: #990000">&amp;)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>T<span style="color: #990000">*)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">=(</span>T<span style="color: #990000">*)</span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</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> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</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>
T<span style="color: #990000">*</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> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</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>
T<span style="color: #990000">*</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">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">++()</span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</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">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">--()</span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span>ptrdiff_t<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">+=(</span>ptrdiff_t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span>ptrdiff_t<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">-=(</span>ptrdiff_t<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: #000080">#endif</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>The <em>opencl_atomic</em> header defines general specialization for class template <span class="monospaced">atomic&lt;T&gt;</span>.</p></div>
<div class="paragraph"><p>There are explicit specializations for integral types.
Each of these specializations provides set of extra operators suitable for integral types.</p></div>
<div class="paragraph"><p>There is an explicit specialization of the atomic template for pointer types.</p></div>
<div class="paragraph"><p>All atomic classes have deleted copy constructor and deleted copy assignment operators.</p></div>
<div class="paragraph"><p>There are several typedefs for atomic types specified as follows:</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">namespace</span></span> cl
<span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_int <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">int</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_uint <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>uint<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_long <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">long</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_ulong <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>ulong<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_float <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">float</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_fp64<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_double <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span><span style="color: #009900">double</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
__INTPTR_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span><span style="color: #990000">)</span> <span style="color: #990000">||</span>
__INTPTR_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_intptr_t <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>intptr_t<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_uintptr_t <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>uintptr_t<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
__SIZE_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span><span style="color: #990000">)</span> <span style="color: #990000">||</span>
__SIZE_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_size_t <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>size_t<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#if</span></span> <span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_base_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">defined</span></span><span style="color: #990000">(</span>cl_khr_int64_extended_atomics<span style="color: #990000">)</span> <span style="color: #990000">&amp;&amp;</span>
__PTRDIFF_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">64</span><span style="color: #990000">)</span> <span style="color: #990000">||</span>
__PTRDIFF_WIDTH__ <span style="color: #990000">==</span> <span style="color: #993399">32</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> atomic_ptrdiff_t <span style="color: #990000">=</span> atomic<span style="color: #990000">&lt;</span>ptrdiff_t<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="flag-type-and-operations">3.24.5. Flag type and operations</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">struct</span></span> <span style="color: #008080">atomic_flag</span>
<span style="color: #FF0000">{</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">test_and_set</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">test_and_set</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<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">clear</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">clear</span></span><span style="color: #990000">(</span>memory_order <span style="color: #990000">=</span> memory_order_seq_cst<span style="color: #990000">,</span>
memory_scope <span style="color: #990000">=</span> memory_scope_device<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic_flag</span></span><span style="color: #990000">()</span> noexcept <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000000">atomic_flag</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> atomic_flag<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
atomic_flag<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> atomic_flag<span style="color: #990000">&amp;)</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
atomic_flag<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> atomic_flag<span style="color: #990000">&amp;)</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">delete</span></span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">atomic_flag_test_and_set</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic_flag<span style="color: #990000">*)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">atomic_flag_test_and_set</span></span><span style="color: #990000">(</span>atomic_flag<span style="color: #990000">*)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">atomic_flag_test_and_set_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic_flag<span style="color: #990000">*,</span> memory_order<span style="color: #990000">,</span>
memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #009900">bool</span> <span style="font-weight: bold"><span style="color: #000000">atomic_flag_test_and_set_explicit</span></span><span style="color: #990000">(</span>atomic_flag<span style="color: #990000">*,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_flag_clear</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic_flag<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">atomic_flag_clear</span></span><span style="color: #990000">(</span>atomic_flag<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">atomic_flag_clear_explicit</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> atomic_flag<span style="color: #990000">*,</span> memory_order<span style="color: #990000">,</span>
memory_scope<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">atomic_flag_clear_explicit</span></span><span style="color: #990000">(</span>atomic_flag<span style="color: #990000">*,</span> memory_order<span style="color: #990000">,</span>
memory_scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> ATOMIC_FLAG_INIT as described in <span style="color: #008080">cpp14</span> specification <span style="color: #990000">[</span>atomics<span style="color: #990000">.</span>flag<span style="color: #990000">]</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="fences">3.24.6. Fences</h4>
<div class="sect4">
<h5 id="atomic_fence">atomic_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="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">atomic_fence</span></span><span style="color: #990000">(</span><span style="color: #008080">mem_fence</span> flags<span style="color: #990000">,</span> <span style="color: #008080">memory_order</span> order<span style="color: #990000">,</span> <span style="color: #008080">memory_scope</span> scope<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span></tt></pre></div></div>
<div class="paragraph"><p>Orders loads or/and stores of a work-item executing a kernel.</p></div>
<div class="paragraph"><p><span class="monospaced">flags</span> must be set to <span class="monospaced">mem_fence::global</span>, <span class="monospaced">mem_fence::local</span>, <span class="monospaced">mem_fence::image</span> or a combination of these values ORed together; otherwise the behavior is undefined.
The behavior of calling <span class="monospaced">atomic_fence</span> with <span class="monospaced">mem_fence::global</span> and <span class="monospaced">mem_fence::local</span> ORed together is equivalent to calling <span class="monospaced">atomic_fence</span> individually for each of the fence values set in <span class="monospaced">flags</span>.
<span class="monospaced">mem_fence::image</span> cannot be specified ORed with <span class="monospaced">mem_fence::global</span> and <span class="monospaced">mem_fence::local</span>.</p></div>
<div class="paragraph"><p>Depending on the value of order, this operation:</p></div>
<div class="ulist"><ul>
<li>
<p>
Has no effects, if <span class="monospaced">order == memory_order_relaxed</span>.
</p>
</li>
<li>
<p>
Is an acquire fence, if <span class="monospaced">order == memory_order_acquire</span>.
</p>
</li>
<li>
<p>
Is a release fence, if <span class="monospaced">order == memory_order_release</span>.
</p>
</li>
<li>
<p>
Is both an acquire fence and a release fence, if <span class="monospaced">order == memory_order_acq_rel</span>.
</p>
</li>
<li>
<p>
Is a sequentially consistent acquire and release fence, if <span class="monospaced">order == memory_order_seq_cst</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>For images declared with the <span class="monospaced">image_access::read_write</span>, the <span class="monospaced">atomic_fence</span> must be called to make sure that writes to the image by a work-item become visible to that work-item on subsequent reads to that image by that work-item.
Only a scope of <span class="monospaced">memory_order_acq_rel</span> is valid for <span class="monospaced">atomic_fence</span> when passed the <span class="monospaced">mem_fence::image</span> flag.</p></div>
</div>
</div>
<div class="sect3">
<h4 id="bit-atomics">3.24.7. 64-bit Atomics</h4>
<div class="paragraph"><p>The optional extensions <em>cl_khr_int64_base_atomics</em> and <em>cl_khr_int64_extended_atomics</em> implement atomic operations on 64-bit signed and unsigned integers to locations in global and local memory.</p></div>
<div class="paragraph"><p>An application that wants to use 64-bit atomic types will need to define <span class="monospaced">cl_khr_int64_base_atomics</span> and <span class="monospaced">cl_khr_int64_extended_atomics</span> macros in the code before including the OpenCL C++ standard library headers or using <em>-D</em> compiler option (<em><a href="#preprocessor_options">Preprocessor options</a> section</em>).</p></div>
</div>
<div class="sect3">
<h4 id="restrictions-3">3.24.8. Restrictions</h4>
<div class="ulist"><ul>
<li>
<p>
The generic <span class="monospaced">atomic&lt;T&gt;</span> class template is only available if <span class="monospaced">T</span> is <span class="monospaced">int</span>, <span class="monospaced">uint</span>, <span class="monospaced">long</span>, <span class="monospaced">ulong</span> <a href="#ftn10">[10</a>], <span class="monospaced">float</span>, <span class="monospaced">double</span> <a href="#ftn11">[11</a>], <span class="monospaced">intptr_t</span> <a href="#ftn12">[12</a>], <span class="monospaced">uintptr_t</span>, <span class="monospaced">size_t</span>, <span class="monospaced">ptrdiff_t</span>.
</p>
</li>
<li>
<p>
The <span class="monospaced">atomic_bool</span>, <span class="monospaced">atomic_char</span>, <span class="monospaced">atomic_uchar</span>, <span class="monospaced">atomic_short</span>, <span class="monospaced">atomic_ushort</span>, <span class="monospaced">atomic_intmax_t</span> and <span class="monospaced">atomic_uintmax_t</span> types are not supported by OpenCL C++.
</p>
</li>
<li>
<p>
OpenCL C++ requires that the built-in atomic functions on atomic types are lock-free.
</p>
</li>
<li>
<p>
The atomic data types cannot be declared inside a kernel or non-kernel function unless they are declared as <span class="monospaced">static</span> keyword or in <span class="monospaced">local&lt;T&gt;</span> and <span class="monospaced">global&lt;T&gt;</span> containers.
</p>
</li>
<li>
<p>
The atomic operations on the private memory can result in undefined behavior.
</p>
</li>
<li>
<p>
<span class="monospaced">memory_order_consume</span> is not supported by OpenCL C++.
</p>
</li>
</ul></div>
</div>
<div class="sect3">
<h4 id="examples-4">3.24.9. Examples</h4>
<div class="sect4">
<h5 id="example-1-4">Example 1</h5>
<div class="paragraph"><p>Examples of using atomic with and without an explicit address space
storage 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="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_atomic&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">atomic&lt;int&gt;</span> a<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK: atomic in the global memory</span></span>
<span style="color: #008080">local&lt;atomic&lt;int&gt;&gt;</span> b<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK: atomic in the local memory</span></span>
<span style="color: #008080">global&lt;atomic&lt;int&gt;&gt;</span> c<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK: atomic in the global memory</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> <span style="color: #FF0000">{</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">global&lt;atomic&lt;int&gt;&gt;</span> d<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK: atomic in the global memory</span></span>
<span style="color: #008080">atomic&lt;global&lt;int&gt;&gt;</span> e<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">// in address space</span></span>
<span style="color: #008080">local&lt;atomic&lt;int&gt;&gt;</span> f<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK: atomic in the local memory</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">atomic&lt;int&gt;</span> g<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// OK: atomic in the global memory</span></span>
<span style="color: #008080">atomic&lt;int&gt;</span> h<span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// undefined behavior</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="array-library">3.25. Array Library</h3>
<div class="paragraph"><p>OpenCL C++ implements part of array library (<em>chapter 23.3.2</em>, <em>[array]</em>) from the C++14 standard.</p></div>
<div class="paragraph"><p>For the detailed description please refer to C++14 standard.</p></div>
<div class="sect3">
<h4 id="header-opencl_array-synopsis">3.25.1. Header &lt;opencl_array&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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">array</span>
<span style="color: #FF0000">{</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> value_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">size_t</span> size_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> T<span style="color: #990000">&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> T<span style="color: #990000">&amp;</span> const_reference<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> iterator<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> const_iterator<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> T<span style="color: #990000">*</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> T<span style="color: #990000">*</span> const_pointer<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> cl<span style="color: #990000">::</span><span style="color: #008080">reverse_iterator&lt;iterator&gt;</span> reverse_iterator<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> cl<span style="color: #990000">::</span><span style="color: #008080">reverse_iterator&lt;const_iterator&gt;</span> const_reverse_iterator<span style="color: #990000">;</span>
<span style="color: #008080">value_type</span> __elems<span style="color: #990000">[</span>N<span style="color: #990000">];</span> <span style="font-style: italic"><span style="color: #9A1900">// exposition only</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// no explicit construct/copy/destroy for aggregate type</span></span>
<span style="font-style: italic"><span style="color: #9A1900">// iterators:</span></span>
<span style="color: #008080">iterator</span> <span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">const_iterator</span> <span style="font-weight: bold"><span style="color: #000000">begin</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">iterator</span> <span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">const_iterator</span> <span style="font-weight: bold"><span style="color: #000000">end</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">reverse_iterator</span> <span style="font-weight: bold"><span style="color: #000000">rbegin</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">const_reverse_iterator</span> <span style="font-weight: bold"><span style="color: #000000">rbegin</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">reverse_iterator</span> <span style="font-weight: bold"><span style="color: #000000">rend</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">const_reverse_iterator</span> <span style="font-weight: bold"><span style="color: #000000">rend</span></span><span style="color: #990000">()</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span><span style="color: #990000">;</span>
<span style="color: #008080">const_iterator</span> <span style="font-weight: bold"><span style="color: #000000">cbegin</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">const_iterator</span> <span style="font-weight: bold"><span style="color: #000000">cend</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">const_reverse_iterator</span> <span style="font-weight: bold"><span style="color: #000000">crbegin</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">const_reverse_iterator</span> <span style="font-weight: bold"><span style="color: #000000">crend</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-style: italic"><span style="color: #9A1900">// capacity:</span></span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">size_type</span> <span style="font-weight: bold"><span style="color: #000000">size</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">constexpr</span> <span style="color: #008080">size_type</span> <span style="font-weight: bold"><span style="color: #000000">max_size</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>
constexpr <span style="color: #008080">bool</span> <span style="font-weight: bold"><span style="color: #000000">empty</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-style: italic"><span style="color: #9A1900">// element access:</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_type</span> n<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">const_reference</span> <span style="font-weight: bold"><span style="color: #0000FF">operator</span></span><span style="color: #990000">[](</span><span style="color: #008080">size_type</span> n<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">reference</span> <span style="font-weight: bold"><span style="color: #000000">front</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">const_reference</span> <span style="font-weight: bold"><span style="color: #000000">front</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">reference</span> <span style="font-weight: bold"><span style="color: #000000">back</span></span><span style="color: #990000">()</span> noexcept<span style="color: #990000">;</span>
<span style="color: #008080">const_reference</span> <span style="font-weight: bold"><span style="color: #000000">back</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: #000000">data</span></span><span style="color: #990000">();</span>
<span style="color: #008080">const_pointer</span> <span style="font-weight: bold"><span style="color: #000000">data</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: #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">tuple_size</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="color: #008080">size_t</span> I<span style="color: #990000">,</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">tuple_element</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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">tuple_size</span><span style="color: #990000">&lt;</span>array<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> N<span style="color: #990000">&gt;&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</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">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">tuple_element</span><span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> array<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> N<span style="color: #990000">&gt;&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</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">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> T<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">(</span>array<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> N<span style="color: #990000">&gt;&amp;</span> a<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="color: #008080">size_t</span> I<span style="color: #990000">,</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">size_t</span> N<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> T<span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">(</span>array<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> N<span style="color: #990000">&gt;&amp;&amp;</span> a<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="color: #008080">size_t</span> I<span style="color: #990000">,</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">size_t</span> N<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">const</span> T<span style="color: #990000">&amp;</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> array<span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span> N<span style="color: #990000">&gt;&amp;</span> a<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
<div class="sect2">
<h3 id="limits-library">3.26. Limits Library</h3>
<div class="paragraph"><p>OpenCL C++ standard library implements modified version of the numeric limits library described in chapter <em>18.3 [support.limits]</em> of C++14 standard.</p></div>
<div class="sect3">
<h4 id="header-opencl_limits-synopsis">3.26.1. Header &lt;opencl_limits&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">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">enum</span></span> float_round_style<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">enum</span></span> float_denorm_style<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> CHAR_BIT <span style="color: #993399">8</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="color: #008080">CHAR_MAX</span> SCHAR_MAX
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="color: #008080">CHAR_MIN</span> SCHAR_MIN
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> INT_MAX <span style="color: #993399">2147483647</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">INT_MIN</span></span> <span style="color: #990000">(-</span><span style="color: #993399">2147483647</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: #000080">#define</span></span> LONG_MAX <span style="color: #993399">0x7fffffffffffffffL</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">LONG_MIN</span></span> <span style="color: #990000">(-</span><span style="color: #993399">0x7fffffffffffffffL</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: #000080">#define</span></span> SCHAR_MAX <span style="color: #993399">127</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">SCHAR_MIN</span></span> <span style="color: #990000">(-</span><span style="color: #993399">127</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: #000080">#define</span></span> SHRT_MAX <span style="color: #993399">32767</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">SHRT_MIN</span></span> <span style="color: #990000">(-</span><span style="color: #993399">32767</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: #000080">#define</span></span> UCHAR_MAX <span style="color: #993399">255</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> USHRT_MAX <span style="color: #993399">65535</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> UINT_MAX <span style="color: #993399">0xffffffff</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> ULONG_MAX 0xffffffffffffffffUL
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span><span style="color: #009900">bool</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>bool2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>bool3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>bool4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>bool8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>bool16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span><span style="color: #009900">char</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>char2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>char3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>char4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>char8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>char16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uchar<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uchar2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uchar3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uchar4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uchar8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uchar16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span><span style="color: #009900">short</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>short2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>short3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>short4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>short8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>short16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ushort<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ushort2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ushort3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ushort4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ushort8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ushort16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span><span style="color: #009900">int</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>int2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>int3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>int4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>int8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>int16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uint<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uint2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uint3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uint4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uint8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>uint16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span><span style="color: #009900">long</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>long2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>long3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>long4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>long8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>long16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ulong<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ulong2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ulong3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ulong4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ulong8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>ulong16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp16
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_DIG <span style="color: #993399">3</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MANT_DIG <span style="color: #993399">11</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX_10_EXP <span style="color: #990000">+</span><span style="color: #993399">4</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX_EXP <span style="color: #990000">+</span><span style="color: #993399">16</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN_10_EXP <span style="color: #990000">-</span><span style="color: #993399">4</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN_EXP <span style="color: #990000">-</span><span style="color: #993399">13</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_RADIX <span style="color: #993399">2</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX <span style="color: #993399">0x1</span><span style="color: #990000">.</span>ffcp15h
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>14h
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_EPSILON <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>10h
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span>half<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_DIG <span style="color: #993399">6</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MANT_DIG <span style="color: #993399">24</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MAX_10_EXP <span style="color: #990000">+</span><span style="color: #993399">38</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MAX_EXP <span style="color: #990000">+</span><span style="color: #993399">128</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MIN_10_EXP <span style="color: #990000">-</span><span style="color: #993399">37</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MIN_EXP <span style="color: #990000">-</span><span style="color: #993399">125</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_RADIX <span style="color: #993399">2</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MAX <span style="color: #993399">0x1</span><span style="color: #990000">.</span>fffffep127f
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MIN <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>126f
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_EPSILON <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>23f
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span><span style="color: #009900">float</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp64
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_DIG <span style="color: #993399">15</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MANT_DIG <span style="color: #993399">53</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MAX_10_EXP <span style="color: #990000">+</span><span style="color: #993399">308</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MAX_EXP <span style="color: #990000">+</span><span style="color: #993399">1024</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MIN_10_EXP <span style="color: #990000">-</span><span style="color: #993399">307</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MIN_EXP <span style="color: #990000">-</span><span style="color: #993399">1021</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MAX <span style="color: #993399">0x1</span><span style="color: #990000">.</span>fffffffffffffp1023
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MIN <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span><span style="color: #993399">1022</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_EPSILON <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span><span style="color: #993399">52</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</span><span style="color: #990000">&lt;</span><span style="color: #009900">double</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="class-numeric_limits">3.26.2. Class numeric_limits</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">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">numeric_limits</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">static</span></span> constexpr <span style="color: #008080">bool</span> is_specialized <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">min</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">max</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">lowest</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">int</span> digits <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">int</span> digits10 <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">int</span> max_digits10 <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_signed <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_integer <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_exact <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">int</span> radix <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">epsilon</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">round_error</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">int</span> min_exponent <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">int</span> min_exponent10 <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">int</span> max_exponent <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">int</span> max_exponent10 <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> has_infinity <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> has_quiet_NaN <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> has_signaling_NaN <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">float_denorm_style</span> has_denorm <span style="color: #990000">=</span> denorm_absent<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> has_denorm_loss <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">infinity</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">quiet_NaN</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">signaling_NaN</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">denorm_min</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_iec559 <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_bounded <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_modulo <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> traps <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> tinyness_before <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> <span style="color: #008080">constexpr</span> <span style="color: #008080">float_round_style</span> round_style <span style="color: #990000">=</span> round_toward_zero<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_scalar <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">bool</span> is_vector <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span><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">numeric_limits</span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&gt;;</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">numeric_limits</span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> T<span style="color: #990000">&gt;;</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">numeric_limits</span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> T<span style="color: #990000">&gt;;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="has_denorm-numeric_limits-class-member">3.26.3. has_denorm numeric_limits class member</h4>
<div class="paragraph"><p><span class="monospaced">has_denorm</span> class member value depends on a macro:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">HAS_SINGLE_FP_DENORM</span> for type <span class="monospaced">float</span>.
</p>
</li>
<li>
<p>
<span class="monospaced">HAS_HALF_FP_DENORM</span> for type <span class="monospaced">half</span>.
</p>
</li>
<li>
<p>
<span class="monospaced">HAS_DOUBLE_FP_DENORM</span> for type <span class="monospaced">double</span>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>If a macro is defined, <span class="monospaced">has_denorm</span> is set to <span class="monospaced">denorm_present</span>.
Otherwise it is <span class="monospaced">denorm_absent</span>.</p></div>
</div>
<div class="sect3">
<h4 id="floating-point-macros-and-limits">3.26.4. Floating-point macros and limits</h4>
<div class="paragraph"><p>The macro names given in the following list must use the values specified.
These constant expressions are suitable for use in <span class="monospaced">#if</span> preprocessing directives.</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">#define</span></span> FLT_DIG <span style="color: #993399">6</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MANT_DIG <span style="color: #993399">24</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MAX_10_EXP <span style="color: #990000">+</span><span style="color: #993399">38</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MAX_EXP <span style="color: #990000">+</span><span style="color: #993399">128</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MIN_10_EXP <span style="color: #990000">-</span><span style="color: #993399">37</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MIN_EXP <span style="color: #990000">-</span><span style="color: #993399">125</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_RADIX <span style="color: #993399">2</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MAX <span style="color: #993399">0x1</span><span style="color: #990000">.</span>fffffep127f
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_MIN <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>126f
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> FLT_EPSILON <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>23f</tt></pre></div></div>
<div class="paragraph"><p>The following table describes the built-in macro names given above in the OpenCL C++ library and the corresponding macro names available to the application.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 22. Float Built-in Macros</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Macro in OpenCL C++</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Macro for application</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_DIG</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_DIG</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_MANT_DIG</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_MANT_DIG</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_MAX_10_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_MAX_10_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_MAX_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_MAX_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_MIN_10_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_MIN_10_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_MIN_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_MIN_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_RADIX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_RADIX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_MIN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_MIN</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">FLT_EPSILSON</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_FLT_EPSILON</span></p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The following macros shall expand to integer constant expressions whose values are returned by <span class="monospaced">ilogb(x)</span> if <span class="monospaced">x</span> is zero or NaN, respectively.
The value of <span class="monospaced">FP_ILOGB0</span> shall be either <span class="monospaced">{INT_MIN}</span> or <span class="monospaced">{INT_MAX}</span>. The value of <span class="monospaced">FP_ILOGBNAN</span> shall be either <span class="monospaced">{INT_MAX}</span> or <span class="monospaced">{INT_MIN}</span>.</p></div>
<div class="paragraph"><p>If double precision is supported by the device, the following macros and constants are available:</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">#define</span></span> DBL_DIG <span style="color: #993399">15</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MANT_DIG <span style="color: #993399">53</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MAX_10_EXP <span style="color: #990000">+</span><span style="color: #993399">308</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MAX_EXP <span style="color: #990000">+</span><span style="color: #993399">1024</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MIN_10_EXP <span style="color: #990000">-</span><span style="color: #993399">307</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MIN_EXP <span style="color: #990000">-</span><span style="color: #993399">1021</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MAX <span style="color: #993399">0x1</span><span style="color: #990000">.</span>fffffffffffffp1023
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_MIN <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span><span style="color: #993399">1022</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> DBL_EPSILON <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span><span style="color: #993399">52</span></tt></pre></div></div>
<div class="paragraph"><p>The macro names given in the following list must use the values specified.
These constant expressions are suitable for use in <span class="monospaced">#if</span> preprocessing directives.</p></div>
<div class="paragraph"><p>The following table describes the built-in macro names given above in the OpenCL C++ library and the corresponding macro names available to the application.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 23. Double Built-in Macros</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Macro in OpenCL cpp</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Macro for application</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_DIG</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_DIG</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_MANT_DIG</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_MANT_DIG</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_MAX_10_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_MAX_10_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_MAX_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_MAX_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_MIN_10_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_MIN_10_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_MIN_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_MIN_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_MIN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_MIN</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">DBL_EPSILSON</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_DBL_EPSILON</span></p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>If half precision arithmetic operations are supported, the following macros and constants for half precision floating-point are available:</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">#define</span></span> HALF_DIG <span style="color: #993399">3</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MANT_DIG <span style="color: #993399">11</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX_10_EXP <span style="color: #990000">+</span><span style="color: #993399">4</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX_EXP <span style="color: #990000">+</span><span style="color: #993399">16</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN_10_EXP <span style="color: #990000">-</span><span style="color: #993399">4</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN_EXP <span style="color: #990000">-</span><span style="color: #993399">13</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_RADIX <span style="color: #993399">2</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MAX <span style="color: #993399">0x1</span><span style="color: #990000">.</span>ffcp15h
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_MIN <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>14h
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> HALF_EPSILON <span style="color: #993399">0x1</span><span style="color: #990000">.</span>0p<span style="color: #990000">-</span>10h</tt></pre></div></div>
<div class="paragraph"><p>The macro names given in the following list must use the values specified.
These constant expressions are suitable for use in <span class="monospaced">#if</span> preprocessing directives.</p></div>
<div class="paragraph"><p>The following table describes the built-in macro names given above in the OpenCL C++ library and the corresponding macro names available to the application.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 24. Half Built-in Macros</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Macro in OpenCL cpp</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Macro for application</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_DIG</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_DIG</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_MANT_DIG</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_MANT_DIG</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_MAX_10_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_MAX_10_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_MAX_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_MAX_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_MIN_10_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_MIN_10_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_MIN_EXP</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_MIN_EXP</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_RADIX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_RADIX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_MIN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_MIN</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HALF_EPSILSON</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_HALF_EPSILON</span></p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The following symbolic constants are available.
Their values are of type float and are accurate within the precision of a single precision floating-point number.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 25. Float Symbolic Constants</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Constant Name</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">MAXFLOAT</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of maximum non-infinite single-precision floating-point number.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">HUGE_VALF</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A positive float constant expression. <span class="monospaced">HUGE_VALF</span> evaluates to +infinity.
Used as an error value returned by the built-in math functions.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">INFINITY</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A constant expression of type float representing positive or unsigned infinity.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">NAN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A constant expression of type float representing a quiet NaN.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>If double precision is supported by the device, the following symbolic constant will also be available:</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 26. Double Symbolic Constants</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Constant Name</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">HUGE_VAL</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">A positive double constant expression.
<span class="monospaced">HUGE_VAL</span> evaluates to +infinity.
Used as an error value returned by the built-in math functions.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="integer-macros-and-limits">3.26.5. Integer macros and limits</h4>
<div class="paragraph"><p>The macro names given in the following list must use the values specified.
The values shall all be constant expressions suitable for use in <span class="monospaced">#if</span> preprocessing directives.</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">#define</span></span> CHAR_BIT <span style="color: #993399">8</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="color: #008080">CHAR_MAX</span> SCHAR_MAX
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="color: #008080">CHAR_MIN</span> SCHAR_MIN
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> INT_MAX <span style="color: #993399">2147483647</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">INT_MIN</span></span> <span style="color: #990000">(-</span><span style="color: #993399">2147483647</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: #000080">#define</span></span> LONG_MAX <span style="color: #993399">0x7fffffffffffffffL</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">LONG_MIN</span></span> <span style="color: #990000">(-</span><span style="color: #993399">0x7fffffffffffffffL</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: #000080">#define</span></span> SCHAR_MAX <span style="color: #993399">127</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">SCHAR_MIN</span></span> <span style="color: #990000">(-</span><span style="color: #993399">127</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: #000080">#define</span></span> SHRT_MAX <span style="color: #993399">32767</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> <span style="font-weight: bold"><span style="color: #000000">SHRT_MIN</span></span> <span style="color: #990000">(-</span><span style="color: #993399">32767</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: #000080">#define</span></span> UCHAR_MAX <span style="color: #993399">255</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> USHRT_MAX <span style="color: #993399">65535</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> UINT_MAX <span style="color: #993399">0xffffffff</span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> ULONG_MAX 0xffffffffffffffffUL</tt></pre></div></div>
<div class="paragraph"><p>The following table describes the built-in macro names given above in the OpenCL C++ library and the corresponding macro names available to the application.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 27. Integer built-in macros</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Macro in OpenCL cpp</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Macro for application</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CHAR_BIT</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_CHAR_BIT</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CHAR_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_CHAR_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CHAR_MIN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_CHAR_MIN</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">INT_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_INT_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">INT_MIN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_INT_MIN</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">LONG_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_LONG_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">LONG_MIN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_LONG_MIN</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">SCHAR_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_SCHAR_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">SCHAR_MIN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_SCHAR_MIN</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">SHRT_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_SHRT_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">SHRT_MIN</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_SHRT_MIN</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">UCHAR_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_UCHAR_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">USHRT_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_USHRT_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">UINT_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_UINT_MAX</span></p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ULONG_MAX</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">CL_ULONG_MAX</span></p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect2">
<h3 id="math-constants-library">3.27. Math Constants Library</h3>
<div class="paragraph"><p>OpenCL C++ implements math constant library.
The purpose of this library is to provide the commonly used constants for half, float and double data types.</p></div>
<div class="sect3">
<h4 id="header-opencl_math_constants-synopsis">3.27.1. Header &lt;opencl_math_constants&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">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><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: #000080">#define</span></span> M_E_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LOG2E_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LOG10E_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LN2_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LN10_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI_2_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI_4_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_1_PI_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_2_PI_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_2_SQRTPI_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_SQRT2_H see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_SQRT1_2_H see below
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>half<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>half2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>half3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>half4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>half8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>half16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</span></span>
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_E_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LOG2E_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LOG10E_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LN2_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LN10_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI_2_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI_4_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_1_PI_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_2_PI_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_2_SQRTPI_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_SQRT2_F see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_SQRT1_2_F see below
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span><span style="color: #009900">float</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>float2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>float3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>float4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>float8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>float16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#ifdef</span></span> cl_khr_fp64
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_E see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LOG2E see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LOG10E see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LN2 see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_LN10 see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI_2 see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_PI_4 see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_1_PI see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_2_PI see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_2_SQRTPI see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_SQRT2 see below
<span style="font-weight: bold"><span style="color: #000080">#define</span></span> M_SQRT1_2 see below
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span><span style="color: #009900">double</span><span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>double2<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>double3<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>double4<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>double8<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span><span style="color: #990000">&lt;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</span><span style="color: #990000">&lt;</span>double16<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #000080">#endif</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>
constexpr <span style="color: #008080">T</span> e_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">e</span></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>
constexpr <span style="color: #008080">T</span> log2e_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">log2e</span></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>
constexpr <span style="color: #008080">T</span> log10e_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">log10e</span></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>
constexpr <span style="color: #008080">T</span> ln2_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">ln2</span></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>
constexpr <span style="color: #008080">T</span> ln10_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">ln10</span></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>
constexpr <span style="color: #008080">T</span> pi_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">pi</span></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>
constexpr <span style="color: #008080">T</span> pi_2_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">pi_2</span></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>
constexpr <span style="color: #008080">T</span> pi_4_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">pi_4</span></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>
constexpr <span style="color: #008080">T</span> one_pi_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">one_pi</span></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>
constexpr <span style="color: #008080">T</span> two_pi_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">two_pi</span></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>
constexpr <span style="color: #008080">T</span> two_sqrtpi_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">two_sqrtpi</span></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>
constexpr <span style="color: #008080">T</span> sqrt2_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">sqrt2</span></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>
constexpr <span style="color: #008080">T</span> sqrt1_2_v <span style="color: #990000">=</span> math_constants<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span><span style="font-weight: bold"><span style="color: #000000">sqrt1_2</span></span><span style="color: #990000">();</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="class-math_constants">3.27.2. Class math_constants</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">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">math_constants</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">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">e</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">log2e</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">log10e</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">ln2</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">ln10</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">pi</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">pi_2</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">pi_4</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">one_pi</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">two_pi</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">two_sqrtpi</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">sqrt2</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="font-weight: bold"><span style="color: #0000FF">static</span></span> constexpr <span style="color: #008080">T</span> <span style="font-weight: bold"><span style="color: #000000">sqrt1_2</span></span><span style="color: #990000">()</span> noexcept <span style="color: #FF0000">{</span> <span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">T</span></span><span style="color: #990000">();</span> <span style="color: #FF0000">}</span>
<span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="half-constants">3.27.3. Half Constants</h4>
<div class="paragraph"><p>The following constants are also available.
They are of type <span class="monospaced">half</span> and are accurate within the precision of the <span class="monospaced">half</span> type.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 28. Half Constants</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Constant</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">e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">log2e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>2</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">log10e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>10</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ln2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>e</sub>2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ln10</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>e</sub>10</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi_2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π / 2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi_4</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π / 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">one_pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 1 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">two_pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 2 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">two_sqrtpi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 2 / √π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">sqrt2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of √2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">sqrt1_2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 1 / √2</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="float-constants">3.27.4. Float Constants</h4>
<div class="paragraph"><p>The following constants are also available.
They are of type <span class="monospaced">float</span> and are accurate within the precision of the <span class="monospaced">float</span> type.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 29. Float Constants</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Constant</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">e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">log2e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>2</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">log10e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>10</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ln2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>e</sub>2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ln10</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>e</sub>10</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi_2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π / 2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi_4</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π / 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">one_pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 1 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">two_pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 2 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">two_sqrtpi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 2 / √π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">sqrt2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of √2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">sqrt1_2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 1 / √2</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect3">
<h4 id="double-constants">3.27.5. Double Constants</h4>
<div class="paragraph"><p>The following constants are also available.
They are of type <span class="monospaced">double</span> and are accurate within the precision of the <span class="monospaced">double</span> type.</p></div>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 30. Double Constants</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Constant</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">e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">log2e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>2</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">log10e</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>10</sub>e</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ln2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>e</sub>2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">ln10</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of log<sub>e</sub>10</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi_2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π / 2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">pi_4</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of π / 4</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">one_pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 1 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">two_pi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 2 / π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">two_sqrtpi</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 2 / √π</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">sqrt2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of √2</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">sqrt1_2</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Value of 1 / √2</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect2">
<h3 id="tuple-library">3.28. Tuple Library</h3>
<div class="paragraph"><p>OpenCL C++ standard library implements most of the tuples described in <em>chapter 20.4 [tuple]</em> of C++14 standard.</p></div>
<div class="paragraph"><p>The following parts of tuple library are not supported:</p></div>
<div class="ulist"><ul>
<li>
<p>
allocator related traits (C++14 standard, <em>section 20.4.2.8</em>)
</p>
</li>
</ul></div>
<div class="sect3">
<h4 id="header-opencl_tuple-synopsis">3.28.1. Header &lt;opencl_tuple&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-style: italic"><span style="color: #9A1900">// class template tuple:</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: #990000">...</span> Types<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">tuple</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// tuple creation functions:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">unspecified</span> ignore<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: #990000">...</span> Types<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">tuple&lt;VTypes ...&gt;</span> <span style="font-weight: bold"><span style="color: #000000">make_tuple</span></span><span style="color: #990000">(</span>Types<span style="color: #990000">&amp;&amp;...);</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: #990000">...</span> Types<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">tuple&lt;Types&amp;&amp;...&gt;</span> <span style="font-weight: bold"><span style="color: #000000">forward_as_tuple</span></span><span style="color: #990000">(</span>Types<span style="color: #990000">&amp;&amp;...)</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: #990000">...</span> Types<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">tuple&lt;Types&amp;...&gt;</span> <span style="font-weight: bold"><span style="color: #000000">tie</span></span><span style="color: #990000">(</span>Types<span style="color: #990000">&amp;...)</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: #990000">...</span> Tuples<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> <span style="color: #008080">tuple&lt;Ctypes ...&gt;</span> <span style="font-weight: bold"><span style="color: #000000">tuple_cat</span></span><span style="color: #990000">(</span>Tuples<span style="color: #990000">&amp;&amp;...);</span>
<span style="font-style: italic"><span style="color: #9A1900">// tuple helper 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">tuple_size</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// undefined</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">tuple_size</span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&gt;;</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">tuple_size</span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> T<span style="color: #990000">&gt;;</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">tuple_size</span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> T<span style="color: #990000">&gt;;</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: #990000">...</span> Types<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">tuple_size</span><span style="color: #990000">&lt;</span>tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;</span> <span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</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">tuple_element</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// undefined</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</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">tuple_element</span><span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</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">tuple_element</span><span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> T<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</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">tuple_element</span><span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="font-weight: bold"><span style="color: #0000FF">volatile</span></span> T<span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Types<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">tuple_element</span><span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;</span> <span style="color: #990000">&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</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> tuple_element_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">tuple_element</span><span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> T<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// element access:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span><span style="color: #008080">size_t</span> I<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Types<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> tuple_element_t<span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&gt;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">(</span>tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&amp;)</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="color: #008080">size_t</span> I<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Types<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> tuple_element_t<span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&gt;&amp;&amp;</span>
<span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">(</span>tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&amp;&amp;)</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="color: #008080">size_t</span> I<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Types<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">const</span> tuple_element_t<span style="color: #990000">&lt;</span>I<span style="color: #990000">,</span> tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&gt;&amp;</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> tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&amp;)</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: #990000">...</span> Types<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> T<span style="color: #990000">&amp;</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">(</span>tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&amp;</span> 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">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Types<span style="color: #990000">&gt;</span>
<span style="color: #008080">constexpr</span> T<span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">get</span></span><span style="color: #990000">(</span>tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&amp;&amp;</span> 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">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Types<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">const</span> T<span style="color: #990000">&amp;</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> tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&amp;</span> t<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// relational operators:</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: #990000">...</span> TTypes<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> UTypes<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">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> tuple<span style="color: #990000">&lt;</span>TTypes<span style="color: #990000">...&gt;&amp;,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> tuple<span style="color: #990000">&lt;</span>UTypes<span style="color: #990000">...&gt;&amp;);</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: #990000">...</span> TTypes<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> UTypes<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">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> tuple<span style="color: #990000">&lt;</span>TTypes<span style="color: #990000">...&gt;&amp;,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> tuple<span style="color: #990000">&lt;</span>UTypes<span style="color: #990000">...&gt;&amp;);</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: #990000">...</span> TTypes<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> UTypes<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">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> tuple<span style="color: #990000">&lt;</span>TTypes<span style="color: #990000">...&gt;&amp;,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> tuple<span style="color: #990000">&lt;</span>UTypes<span style="color: #990000">...&gt;&amp;);</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: #990000">...</span> TTypes<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> UTypes<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">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> tuple<span style="color: #990000">&lt;</span>TTypes<span style="color: #990000">...&gt;&amp;,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> tuple<span style="color: #990000">&lt;</span>UTypes<span style="color: #990000">...&gt;&amp;);</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: #990000">...</span> TTypes<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> UTypes<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">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> tuple<span style="color: #990000">&lt;</span>TTypes<span style="color: #990000">...&gt;&amp;,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> tuple<span style="color: #990000">&lt;</span>UTypes<span style="color: #990000">...&gt;&amp;);</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: #990000">...</span> TTypes<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> UTypes<span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">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> tuple<span style="color: #990000">&lt;</span>TTypes<span style="color: #990000">...&gt;&amp;,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> tuple<span style="color: #990000">&lt;</span>UTypes<span style="color: #990000">...&gt;&amp;);</span>
<span style="font-style: italic"><span style="color: #9A1900">// specialized algorithms:</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: #990000">...</span> Types<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>tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&amp;</span> x<span style="color: #990000">,</span> tuple<span style="color: #990000">&lt;</span>Types<span style="color: #990000">...&gt;&amp;</span> y<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #000000">noexcept</span></span><span style="color: #990000">(</span>see <span style="color: #008080">cpp14</span> standard<span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
<div class="sect2">
<h3 id="type-traits-library">3.29. Type Traits Library</h3>
<div class="paragraph"><p>OpenCL C++ supports type traits defined in C++14 specification with following changes:</p></div>
<div class="ulist"><ul>
<li>
<p>
<em><a href="#unary-type-traits">Unary Type Traits</a> section</em> describes additions and changes to <em>UnaryTypeTraits</em>.
</p>
</li>
<li>
<p>
<em><a href="#binary-type-traits">Binary type traits</a> section</em> describes additions and changes to <em>BinaryTypeTraits</em>.
</p>
</li>
<li>
<p>
<em><a href="#transformation-traits">Transformation traits</a> section</em> describes additions and changes to <em>TransformationTraits</em>.
</p>
</li>
</ul></div>
<div class="paragraph"><p>This section specifies only OpenCL specific type traits and modifications.
All C++ type traits are described in <em>chapter 20.10 [meta]</em> of C++14 standard.</p></div>
<div class="sect3">
<h4 id="header-opencl_type_traits-synopsis">3.29.1. Header &lt;opencl_type_traits&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-style: italic"><span style="color: #9A1900">// helper class:</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">,</span> <span style="color: #008080">T</span> v<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">integral_constant</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">integral_constant&lt;bool, true&gt;</span> true_type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typedef</span></span> <span style="color: #008080">integral_constant&lt;bool, false&gt;</span> false_type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// primary type categories:</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">struct</span></span> <span style="color: #008080">is_void</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">struct</span></span> <span style="color: #008080">is_null_pointer</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">struct</span></span> <span style="color: #008080">is_integral</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">struct</span></span> <span style="color: #008080">is_floating_point</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">struct</span></span> <span style="color: #008080">is_array</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">struct</span></span> <span style="color: #008080">is_pointer</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">struct</span></span> <span style="color: #008080">is_lvalue_reference</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">struct</span></span> <span style="color: #008080">is_rvalue_reference</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">struct</span></span> <span style="color: #008080">is_member_object_pointer</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">struct</span></span> <span style="color: #008080">is_member_function_pointer</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">struct</span></span> <span style="color: #008080">is_enum</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">struct</span></span> <span style="color: #008080">is_union</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">struct</span></span> <span style="color: #008080">is_class</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">struct</span></span> <span style="color: #008080">is_function</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// composite type categories:</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">struct</span></span> <span style="color: #008080">is_reference</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">struct</span></span> <span style="color: #008080">is_arithmetic</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">struct</span></span> <span style="color: #008080">is_fundamental</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">struct</span></span> <span style="color: #008080">is_object</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">struct</span></span> <span style="color: #008080">is_scalar</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">struct</span></span> <span style="color: #008080">is_compound</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">struct</span></span> <span style="color: #008080">is_member_pointer</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// type properties:</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">struct</span></span> <span style="color: #008080">is_const</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">struct</span></span> <span style="color: #008080">is_volatile</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">struct</span></span> <span style="color: #008080">is_private</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">struct</span></span> <span style="color: #008080">is_local</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">struct</span></span> <span style="color: #008080">is_global</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">struct</span></span> <span style="color: #008080">is_constant</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">struct</span></span> <span style="color: #008080">is_generic</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">struct</span></span> <span style="color: #008080">is_vector</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">struct</span></span> <span style="color: #008080">is_trivial</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">struct</span></span> <span style="color: #008080">is_trivially_copyable</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">struct</span></span> <span style="color: #008080">is_standard_layout</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">struct</span></span> <span style="color: #008080">is_pod</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">struct</span></span> <span style="color: #008080">is_literal_type</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">struct</span></span> <span style="color: #008080">is_empty</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">struct</span></span> <span style="color: #008080">is_polymorphic</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">struct</span></span> <span style="color: #008080">is_abstract</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">struct</span></span> <span style="color: #008080">is_final</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">struct</span></span> <span style="color: #008080">is_signed</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">struct</span></span> <span style="color: #008080">is_unsigned</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: #990000">...</span> Args<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_constructible</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">struct</span></span> <span style="color: #008080">is_default_constructible</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">struct</span></span> <span style="color: #008080">is_copy_constructible</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">struct</span></span> <span style="color: #008080">is_move_constructible</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="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_assignable</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">struct</span></span> <span style="color: #008080">is_copy_assignable</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">struct</span></span> <span style="color: #008080">is_move_assignable</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">struct</span></span> <span style="color: #008080">is_destructible</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: #990000">...</span> Args<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_trivially_constructible</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">struct</span></span> <span style="color: #008080">is_trivially_default_constructible</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">struct</span></span> <span style="color: #008080">is_trivially_copy_constructible</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">struct</span></span> <span style="color: #008080">is_trivially_move_constructible</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="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_trivially_assignable</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">struct</span></span> <span style="color: #008080">is_trivially_copy_assignable</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">struct</span></span> <span style="color: #008080">is_trivially_move_assignable</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">struct</span></span> <span style="color: #008080">is_trivially_destructible</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: #990000">...</span> Args<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_nothrow_constructible</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">struct</span></span> <span style="color: #008080">is_nothrow_default_constructible</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">struct</span></span> <span style="color: #008080">is_nothrow_copy_constructible</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">struct</span></span> <span style="color: #008080">is_nothrow_move_constructible</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="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_nothrow_assignable</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">struct</span></span> <span style="color: #008080">is_nothrow_copy_assignable</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">struct</span></span> <span style="color: #008080">is_nothrow_move_assignable</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">struct</span></span> <span style="color: #008080">is_nothrow_destructible</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">struct</span></span> <span style="color: #008080">has_virtual_destructor</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// type property queries:</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">struct</span></span> <span style="color: #008080">alignment_of</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">struct</span></span> <span style="color: #008080">rank</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="color: #009900">unsigned</span> I <span style="color: #990000">=</span> <span style="color: #993399">0</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">extent</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// type relations:</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">,</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="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_same</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">Base</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Derived</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_base_of</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">From</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">To</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">is_convertible</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// const-volatile modifications:</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">struct</span></span> <span style="color: #008080">remove_const</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">struct</span></span> <span style="color: #008080">remove_volatile</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">struct</span></span> <span style="color: #008080">remove_cv</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">struct</span></span> <span style="color: #008080">add_const</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">struct</span></span> <span style="color: #008080">add_volatile</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">struct</span></span> <span style="color: #008080">add_cv</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> remove_const_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_const</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_volatile_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_volatile</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_cv_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_cv</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_const_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_const</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_volatile_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_volatile</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_cv_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_cv</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// as modifications</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">struct</span></span> <span style="color: #008080">remove_constant</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">struct</span></span> <span style="color: #008080">remove_local</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">struct</span></span> <span style="color: #008080">remove_global</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">struct</span></span> <span style="color: #008080">remove_private</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">struct</span></span> <span style="color: #008080">remove_generic</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">struct</span></span> <span style="color: #008080">remove_as</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">struct</span></span> <span style="color: #008080">remove_attrs</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">struct</span></span> <span style="color: #008080">add_constant</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">struct</span></span> <span style="color: #008080">add_local</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">struct</span></span> <span style="color: #008080">add_global</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">struct</span></span> <span style="color: #008080">add_private</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">struct</span></span> <span style="color: #008080">add_generic</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> remove_constant_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_constant</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_local_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_local</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_global_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_global</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_private_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_private</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_generic_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_generic</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_as_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_as</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_attrs_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_attrs</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_constant_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_constant</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_local_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_local</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_global_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_global</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_private_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_private</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_generic_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_generic</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// reference modifications:</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">struct</span></span> <span style="color: #008080">remove_reference</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">struct</span></span> <span style="color: #008080">add_lvalue_reference</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">struct</span></span> <span style="color: #008080">add_rvalue_reference</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> remove_reference_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_reference</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_lvalue_reference_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_lvalue_reference</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_rvalue_reference_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_rvalue_reference</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// sign modifications:</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">struct</span></span> <span style="color: #008080">make_signed</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">struct</span></span> <span style="color: #008080">make_unsigned</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> make_signed_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">make_signed</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> make_unsigned_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">make_unsigned</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// array modifications:</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">struct</span></span> <span style="color: #008080">remove_extent</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">struct</span></span> <span style="color: #008080">remove_all_extents</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> remove_extent_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_extent</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> remove_all_extents_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_all_extents</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// pointer modifications:</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">struct</span></span> <span style="color: #008080">remove_pointer</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">struct</span></span> <span style="color: #008080">add_pointer</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> remove_pointer_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_pointer</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> add_pointer_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">add_pointer</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// built-in vector queries</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">struct</span></span> <span style="color: #008080">is_vector_type</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">struct</span></span> <span style="color: #008080">vector_size</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// built-in vector modifications</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">struct</span></span> <span style="color: #008080">vector_element</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="color: #008080">uint</span> DIM<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">make_vector</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> vector_element_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">vector_element</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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">uint</span> DIM<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> make_vector_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">make_vector</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">,</span>DIM<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// other transformations:</span></span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span>cl<span style="color: #990000">::</span><span style="color: #008080">size_t</span> Len<span style="color: #990000">,</span>
cl<span style="color: #990000">::</span><span style="color: #008080">size_t</span> Align <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">-</span>alignment<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">aligned_storage</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span>cl<span style="color: #990000">::</span><span style="color: #008080">size_t</span> Len<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Types<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">aligned_union</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">struct</span></span> <span style="color: #008080">decay</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="color: #009900">bool</span><span style="color: #990000">,</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: #009900">void</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">enable_if</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="color: #009900">bool</span><span style="color: #990000">,</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">F</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">conditional</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: #990000">...</span> T<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">common_type</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">struct</span></span> <span style="color: #008080">underlying_type</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: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">result_of</span><span style="color: #990000">;</span> <span style="font-style: italic"><span style="color: #9A1900">// not defined</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">F</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> ArgTypes<span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">result_of</span><span style="color: #990000">&lt;</span><span style="font-weight: bold"><span style="color: #000000">F</span></span><span style="color: #990000">(</span>ArgTypes<span style="color: #990000">...)&gt;;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span>cl<span style="color: #990000">::</span><span style="color: #008080">size_t</span> Len<span style="color: #990000">,</span>
cl<span style="color: #990000">::</span><span style="color: #008080">size_t</span> Align <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">default</span></span><span style="color: #990000">-</span>alignment <span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> aligned_storage_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">aligned_storage</span><span style="color: #990000">&lt;</span>Len<span style="color: #990000">,</span>Align<span style="color: #990000">&gt;::</span>type<span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">template</span></span> <span style="color: #990000">&lt;</span>cl<span style="color: #990000">::</span><span style="color: #008080">size_t</span> Len<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span><span style="color: #990000">...</span> Types<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> aligned_union_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">aligned_union</span><span style="color: #990000">&lt;</span>Len<span style="color: #990000">,</span>Types<span style="color: #990000">...&gt;::</span>type<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> decay_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">decay</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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="color: #009900">bool</span> b<span style="color: #990000">,</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: #009900">void</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> enable_if_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">enable_if</span><span style="color: #990000">&lt;</span>b<span style="color: #990000">,</span>T<span style="color: #990000">&gt;::</span>type<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="color: #009900">bool</span> b<span style="color: #990000">,</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">F</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> conditional_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">conditional</span><span style="color: #990000">&lt;</span>b<span style="color: #990000">,</span>T<span style="color: #990000">,</span>F<span style="color: #990000">&gt;::</span>type<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: #990000">...</span> T<span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> common_type_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">common_type</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">...&gt;::</span>type<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> underlying_type_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">underlying_type</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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> result_of_t <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">result_of</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>type<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: #990000">...&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">using</span></span> void_t <span style="color: #990000">=</span> <span style="color: #009900">void</span><span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
<div class="sect3">
<h4 id="unary-type-traits">3.29.2. Unary Type Traits</h4>
<div class="sect4">
<h5 id="additional-type-property-predicates">Additional type property predicates</h5>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 31. Additional type property predicates</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Template</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Condition</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct is_private;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct is_local;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct is_global;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct is_constant;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct is_generic;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct is_vector;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">T</span> is built-in vector type.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect4">
<h5 id="additional-type-property-queries">Additional type property queries</h5>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 32. Additional type property queries</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Template</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Value</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct vector_size;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If <span class="monospaced">T</span> names a built-in vector type, an integer value representing number of <span class="monospaced">T</span>'s components; otherwise <span class="monospaced">1</span>.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect3">
<h4 id="binary-type-traits">3.29.3. Binary type traits</h4>
<div class="sect4">
<h5 id="changed-relationships-traits">Changed relationships traits</h5>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 33. Changed relationship traits</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Template</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Condition</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T, class U&gt;
struct is_same;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">T</span> and <span class="monospaced">U</span> name the same type with the same <em>cv qualifications</em>.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="sect3">
<h4 id="transformation-traits">3.29.4. Transformation traits</h4>
<div class="sect4">
<h5 id="address-space-and-vector-modifications">Address space and vector modifications</h5>
<table class="tableblock frame-all grid-all"
style="
width:100%;
">
<caption class="title">Table 34. Address space and vector traits</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Template</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Comments</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct remove_private;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct remove_local;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct remove_global;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct remove_constant;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct remove_generic;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct remove_as;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct remove_attrs;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct add_private;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct add_local;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct add_global;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct add_constant;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct add_generic;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation defined.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T&gt;
struct vector_element;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If <span class="monospaced">T</span> is a built-in vector type, member typedef <span class="monospaced">T</span> shall name type of <span class="monospaced">T</span>'s component; otherwise it shall name <span class="monospaced">T</span>.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><span class="monospaced">template &lt;class T, size_t Dim&gt;
struct make_vector;</span></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">If type <span class="monospaced">U</span> exists and names a built-in vector type with <span class="monospaced">Dim</span> components of type <span class="monospaced">T</span>, member typedef type shall name <span class="monospaced">U</span>; otherwise it shall name <span class="monospaced">T</span>.</p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sect2">
<h3 id="iterator-library">3.30. Iterator Library</h3>
<div class="paragraph"><p>OpenCL C++ implements part of iterator library (<em>chapter 24, [iterators]</em>) from the C++14 standard.
Primitives (C++14 standard, <em>section 24.4</em>), iterator operations (C++14 standard, <em>section 24.4.4,</em>), predefined iterators (C++14 standard, <em>section 24.5</em>) and range access (C++14 standard, <em>section 24.7</em>) are supported.</p></div>
<div class="paragraph"><p>For the detailed description please refer to C++14 standard.</p></div>
<div class="sect3">
<h4 id="header-opencl_iterator-synopsis">3.30.1. Header &lt;opencl_iterator&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-style: italic"><span style="color: #9A1900">// primitives:</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">Iterator</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">iterator_traits</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">struct</span></span> <span style="color: #008080">iterator_traits</span><span style="color: #990000">&lt;</span>T<span style="color: #990000">*&gt;;</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">Category</span><span style="color: #990000">,</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">Distance</span> <span style="color: #990000">=</span> ptrdiff_t<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Pointer</span> <span style="color: #990000">=</span> T<span style="color: #990000">*,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Reference</span> <span style="color: #990000">=</span> T<span style="color: #990000">&amp;&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">iterator</span><span style="color: #990000">;</span>
<span style="font-weight: bold"><span style="color: #0000FF">struct</span></span> <span style="color: #008080">input_iterator_tag</span> <span style="color: #FF0000">{</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: #008080">output_iterator_tag</span> <span style="color: #FF0000">{</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: #008080">forward_iterator_tag</span><span style="color: #990000">:</span> <span style="font-weight: bold"><span style="color: #0000FF">public</span></span> input_iterator_tag <span style="color: #FF0000">{</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: #008080">bidirectional_iterator_tag</span><span style="color: #990000">:</span> <span style="font-weight: bold"><span style="color: #0000FF">public</span></span> forward_iterator_tag <span style="color: #FF0000">{</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: #008080">random_access_iterator_tag</span><span style="color: #990000">:</span> <span style="font-weight: bold"><span style="color: #0000FF">public</span></span> bidirectional_iterator_tag <span style="color: #FF0000">{</span> <span style="color: #FF0000">}</span><span style="color: #990000">;</span>
<span style="font-style: italic"><span style="color: #9A1900">// iterator operations:</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">InputIterator</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Distance</span><span style="color: #990000">&gt;</span>
<span style="color: #009900">void</span> <span style="font-weight: bold"><span style="color: #000000">advance</span></span><span style="color: #990000">(</span>InputIterator<span style="color: #990000">&amp;</span> i<span style="color: #990000">,</span> <span style="color: #008080">Distance</span> n<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">InputIterator</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">iterator_traits</span><span style="color: #990000">&lt;</span>InputIterator<span style="color: #990000">&gt;::</span>difference_type
<span style="font-weight: bold"><span style="color: #000000">distance</span></span><span style="color: #990000">(</span><span style="color: #008080">InputIterator</span> first<span style="color: #990000">,</span> <span style="color: #008080">InputIterator</span> last<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">ForwardIterator</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">ForwardIterator</span> <span style="font-weight: bold"><span style="color: #000000">next</span></span><span style="color: #990000">(</span><span style="color: #008080">ForwardIterator</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">std</span><span style="color: #990000">::</span>iterator_traits<span style="color: #990000">&lt;</span>ForwardIterator<span style="color: #990000">&gt;::</span><span style="color: #008080">difference_type</span> n <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">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">BidirectionalIterator</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">BidirectionalIterator</span> <span style="font-weight: bold"><span style="color: #000000">prev</span></span><span style="color: #990000">(</span><span style="color: #008080">BidirectionalIterator</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">std</span><span style="color: #990000">::</span>iterator_traits<span style="color: #990000">&lt;</span>BidirectionalIterator<span style="color: #990000">&gt;::</span><span style="color: #008080">difference_type</span> n <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">// predefined iterators:</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">Iterator</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">reverse_iterator</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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> reverse_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reverse_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> reverse_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reverse_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> reverse_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reverse_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> reverse_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reverse_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> reverse_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reverse_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> reverse_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reverse_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></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> reverse_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reverse_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span><span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>y<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">base</span></span><span style="color: #990000">()</span> <span style="color: #990000">-</span> x<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">base</span></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">Iterator</span><span style="color: #990000">&gt;</span>
reverse_iterator<span style="color: #990000">&lt;</span>Iterator<span style="color: #990000">&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">typename</span></span> <span style="color: #008080">reverse_iterator</span><span style="color: #990000">&lt;</span>Iterator<span style="color: #990000">&gt;::</span><span style="color: #008080">difference_type</span> n<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> reverse_iterator<span style="color: #990000">&lt;</span>Iterator<span style="color: #990000">&gt;&amp;</span> x<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">Iterator</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">reverse_iterator&lt;Iterator&gt;</span> <span style="font-weight: bold"><span style="color: #000000">make_reverse_iterator</span></span><span style="color: #990000">(</span><span style="color: #008080">Iterator</span> i<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">Container</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">back_insert_iterator</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">Container</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">back_insert_iterator&lt;Container&gt;</span> <span style="font-weight: bold"><span style="color: #000000">back_inserter</span></span><span style="color: #990000">(</span>Container<span style="color: #990000">&amp;</span> x<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">Container</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">front_insert_iterator</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">Container</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">front_insert_iterator&lt;Container&gt;</span> <span style="font-weight: bold"><span style="color: #000000">front_inserter</span></span><span style="color: #990000">(</span>Container<span style="color: #990000">&amp;</span> x<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">Container</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">insert_iterator</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">Container</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">insert_iterator&lt;Container&gt;</span> <span style="font-weight: bold"><span style="color: #000000">inserter</span></span><span style="color: #990000">(</span>Container<span style="color: #990000">&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">Container</span><span style="color: #990000">::</span><span style="color: #008080">iterator</span> i<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">Iterator</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">move_iterator</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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> move_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> move_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> move_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> move_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> move_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> move_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> move_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> move_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> move_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> move_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</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> move_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">const</span></span> move_iterator<span style="color: #990000">&lt;</span>Iterator2<span style="color: #990000">&gt;&amp;</span> y<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">Iterator1</span><span style="color: #990000">,</span> <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> <span style="color: #008080">Iterator2</span><span style="color: #990000">&gt;</span>
<span style="font-weight: bold"><span style="color: #0000FF">auto</span></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> move_iterator<span style="color: #990000">&lt;</span>Iterator1<span style="color: #990000">&gt;&amp;</span> x<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> <span style="color: #008080">move_iterator&lt;Iterator2&gt;&amp; y) -&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>x<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">base</span></span><span style="color: #990000">()</span> <span style="color: #990000">-</span> y<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">base</span></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">Iterator</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">move_iterator&lt;Iterator&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">typename</span></span> <span style="color: #008080">move_iterator</span><span style="color: #990000">&lt;</span>Iterator<span style="color: #990000">&gt;::</span><span style="color: #008080">difference_type</span> n<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> move_iterator<span style="color: #990000">&lt;</span>Iterator<span style="color: #990000">&gt;&amp;</span> x<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">Iterator</span><span style="color: #990000">&gt;</span>
<span style="color: #008080">move_iterator&lt;Iterator&gt;</span> <span style="font-weight: bold"><span style="color: #000000">make_move_iterator</span></span><span style="color: #990000">(</span><span style="color: #008080">Iterator</span> i<span style="color: #990000">);</span>
<span style="font-style: italic"><span style="color: #9A1900">// range access:</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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span>C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">begin</span></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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">begin</span></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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span>C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">end</span></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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">end</span></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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span> <span style="color: #008080">constexpr</span> T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">T</span></span> <span style="color: #990000">(&amp;</span>array<span style="color: #990000">)[</span>N<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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span> <span style="color: #008080">constexpr</span> T<span style="color: #990000">*</span> <span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">T</span></span> <span style="color: #990000">(&amp;</span>array<span style="color: #990000">)[</span>N<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">C</span><span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">auto</span> <span style="font-weight: bold"><span style="color: #000000">cbegin</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #000000">noexcept</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">noexcept</span></span><span style="color: #990000">(</span>std<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span>c<span style="color: #990000">)))</span>
<span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>std<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">begin</span></span><span style="color: #990000">(</span>c<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">C</span><span style="color: #990000">&gt;</span>
constexpr <span style="color: #008080">auto</span> <span style="font-weight: bold"><span style="color: #000000">cend</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #000000">noexcept</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">noexcept</span></span><span style="color: #990000">(</span>std<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span>c<span style="color: #990000">)))</span>
<span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>std<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">end</span></span><span style="color: #990000">(</span>c<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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">rbegin</span></span><span style="color: #990000">(</span>C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">rbegin</span></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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">rbegin</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">rbegin</span></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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">rend</span></span><span style="color: #990000">(</span>C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">rend</span></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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">rend</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>c<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">rend</span></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="color: #008080">size_t</span> N<span style="color: #990000">&gt;</span> <span style="color: #008080">reverse_iterator&lt;T*&gt;</span> <span style="font-weight: bold"><span style="color: #000000">rbegin</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">T</span></span> <span style="color: #990000">(&amp;</span>array<span style="color: #990000">)[</span>N<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">size_t</span> N<span style="color: #990000">&gt;</span> <span style="color: #008080">reverse_iterator&lt;T*&gt;</span> <span style="font-weight: bold"><span style="color: #000000">rend</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #000000">T</span></span> <span style="color: #990000">(&amp;</span>array<span style="color: #990000">)[</span>N<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">E</span><span style="color: #990000">&gt;</span> <span style="color: #008080">reverse_iterator&lt;const E*&gt; rbegin(initializer_list&lt;E&gt;</span> il<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">E</span><span style="color: #990000">&gt;</span> <span style="color: #008080">reverse_iterator&lt;const E*&gt; rend(initializer_list&lt;E&gt;</span> il<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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">crbegin</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>std<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">rbegin</span></span><span style="color: #990000">(</span>c<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">C</span><span style="color: #990000">&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">auto</span></span> <span style="font-weight: bold"><span style="color: #000000">crend</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">const</span></span> C<span style="color: #990000">&amp;</span> c<span style="color: #990000">)</span> <span style="color: #990000">-&gt;</span> <span style="font-weight: bold"><span style="color: #000000">decltype</span></span><span style="color: #990000">(</span>std<span style="color: #990000">::</span><span style="font-weight: bold"><span style="color: #000000">rend</span></span><span style="color: #990000">(</span>c<span style="color: #990000">));</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
<div class="sect2">
<h3 id="general-utilities-library">3.31. General Utilities Library</h3>
<div class="paragraph"><p>OpenCL C++ implements part of utility library (<em>chapter 20.2, [utilities]</em>) from the C++14 standard.</p></div>
<div class="paragraph"><p>For the detailed description please refer to C++14 standard.</p></div>
<div class="sect3">
<h4 id="header-opencl_utility-synopsis">3.31.1. Header &lt;opencl_utility&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">&gt;</span>
<span style="color: #008080">add_rvalue_reference_t&lt;T&gt;</span> <span style="font-weight: bold"><span style="color: #000000">declval</span></span><span style="color: #990000">(</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="color: #008080">constexpr</span> T<span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">forward</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_reference_t</span><span style="color: #990000">&amp;</span> 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: #008080">constexpr</span> T<span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">forward</span></span><span style="color: #990000">(</span><span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_reference_t</span><span style="color: #990000">&amp;&amp;</span> 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>
constexpr <span style="font-weight: bold"><span style="color: #0000FF">typename</span></span> <span style="color: #008080">remove_reference_t</span><span style="color: #990000">&amp;&amp;</span> <span style="font-weight: bold"><span style="color: #000000">move</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;&amp;</span> 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">void</span> <span style="font-weight: bold"><span style="color: #000000">swap</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;</span> a<span style="color: #990000">,</span> T<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: #008080">constexpr</span> conditional_t<span style="color: #990000">&lt;</span>
<span style="color: #990000">!</span>is_nothrow_move_constructible<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>value <span style="color: #990000">&amp;&amp;</span> is_copy_constructible<span style="color: #990000">&lt;</span>T<span style="color: #990000">&gt;::</span>value<span style="color: #990000">,</span>
<span style="font-weight: bold"><span style="color: #0000FF">const</span></span> T<span style="color: #990000">&amp;,</span> T<span style="color: #990000">&amp;&amp;&gt;</span> <span style="font-weight: bold"><span style="color: #000000">move_if_noexcept</span></span><span style="color: #990000">(</span>T<span style="color: #990000">&amp;</span> x<span style="color: #990000">)</span> noexcept<span style="color: #990000">;</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="opencl-numerical-compliance">4. OpenCL Numerical Compliance</h2>
<div class="sectionbody">
<div class="paragraph"><p>This section describes features of the C++14 and IEEE 754 standards that must be supported by all OpenCL compliant devices.</p></div>
<div class="paragraph"><p>This section describes the functionality that must be supported by all OpenCL devices for single precision floating-point numbers.
Currently, only single precision and half precision floating-point is a requirement.
Double precision floating-point is an optional feature.</p></div>
<div class="sect2">
<h3 id="rounding-modes-1">4.1. Rounding Modes</h3>
<div class="paragraph"><p>Floating-point calculations may be carried out internally with extra precision and then rounded to fit into the destination type.
IEEE 754 defines four possible rounding modes:</p></div>
<div class="ulist"><ul>
<li>
<p>
Round to nearest even.
</p>
</li>
<li>
<p>
Round toward +infinity.
</p>
</li>
<li>
<p>
Round toward -infinity.
</p>
</li>
<li>
<p>
Round toward zero.
</p>
</li>
</ul></div>
<div class="paragraph"><p><em>Round to nearest even</em> is currently the only rounding mode required <a href="#ftn30">[30</a>] by the OpenCL specification for single precision and double precision operations and is therefore the default rounding mode.
In addition, only static selection of rounding mode is supported.
Static and dynamic selection of rounding mode is not supported.</p></div>
</div>
<div class="sect2">
<h3 id="inf-nan-and-denormalized-numbers">4.2. INF, NaN and Denormalized Numbers</h3>
<div class="paragraph"><p>INF and NaNs must be supported.
Support for signaling NaNs is not required.</p></div>
<div class="paragraph"><p>Support for denormalized numbers with single precision floating-point is optional.
Denormalized single precision floating-point numbers passed as input or produced as the output of single precision floating-point operations such as add, sub, mul, divide, and the functions defined in <a href="#math-functions">Math Functions</a>, <a href="#common-functions">Common Functions</a> and <a href="#geometric-functions">Geometric Functions</a> may be flushed to zero.</p></div>
</div>
<div class="sect2">
<h3 id="floating-point-exceptions">4.3. Floating-Point Exceptions</h3>
<div class="paragraph"><p>Floating-point exceptions are disabled in OpenCL.
The result of a floating-point exception must match the IEEE 754 spec for the exceptions not enabled case.
Whether and when the implementation sets floating-point flags or raises floating-point exceptions is implementation-defined.
This standard provides no method for querying, clearing or setting floating-point flags or trapping raised exceptions.
Due to non-performance, non-portability of trap mechanisms and the impracticality of servicing precise exceptions in a vector context (especially on heterogeneous hardware), such features are discouraged.</p></div>
<div class="paragraph"><p>Implementations that nevertheless support such operations through an extension to the standard shall initialize with all exception flags cleared and the exception masks set so that exceptions raised by arithmetic operations do not trigger a trap to be taken.
If the underlying work is reused by the implementation, the implementation is however not responsible for reclearing the flags or resetting exception masks to default values before entering the kernel.
That is to say that kernels that do not inspect flags or enable traps are licensed to expect that their arithmetic will not trigger a trap.
Those kernels that do examine flags or enable traps are responsible for clearing flag state and disabling all traps before returning control to the implementation.
Whether or when the underlying work-item (and accompanying global floating-point state if any) is reused is implementation-defined.</p></div>
<div class="paragraph"><p>The expressions math_errorhandling and MATH_ERREXCEPT are reserved for use by this standard, but not defined.
Implementations that extend this specification with support for floating-point exceptions shall define math_errorhandling and MATH_ERREXCEPT per ISO / IEC 9899 : TC2.</p></div>
</div>
<div class="sect2">
<h3 id="relative-error-as-ulps">4.4. Relative Error as ULPs</h3>
<div class="paragraph"><p>In this section we discuss the maximum relative error defined as ulp (units in the last place).
Addition, subtraction, multiplication, fused multiply-add and conversion between integer and a single precision floating-point format are IEEE 754 compliant and are therefore correctly rounded.
Conversion between floating-point formats and explicit conversions specified in <em><a href="#conversions-library">Conversions Library</a> section</em> must be correctly rounded.</p></div>
<div class="paragraph"><p>The ULP is defined as follows:</p></div>
<div class="paragraph"><p>If x is a real number that lies between two finite consecutive floating-point numbers a and b, without being equal to one of them, then ulp(x) = |b −a|, otherwise ulp(x) is the distance between the two non-equal finite floating-point numbers nearest x.
Moreover, ulp(NaN) is NaN.</p></div>
<div class="paragraph"><p><em>Attribution: This definition was taken with consent from Jean-Michel Muller with slight clarification for behavior at zero.
Refer to <a href="ftp://ftp.inria.fr/INRIA/publication/publi-pdf/RR/RR-5504.pdf">ftp://ftp.inria.fr/INRIA/publication/publi-pdf/RR/RR-5504.pdf</a></em></p></div>
<div class="paragraph"><p><a href="#ulp_values_for_single_precision_builtin_math_functions">ULP values for single precision built-in math functions</a> <a href="#ftn31">[31</a>] table describes the minimum accuracy of single precision floating-point arithmetic operations given as ULP values.
The reference value used to compute the ULP value of an arithmetic operation is the infinitely precise result.</p></div>
<table class="tableblock frame-all grid-all" id="ulp_values_for_single_precision_builtin_math_functions"
style="
width:100%;
">
<caption class="title">Table 35. ULP values for single precision built-in math functions</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Function</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Min Accuracy - ULP values <a href="#ftn32">[32</a>]</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>x</em> + <em>y</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>x</em> - <em>y</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>x</em> * <em>y</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1.0 / <em>x</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2.5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>x</em> / <em>y</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2.5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acospi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2pi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acosh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cbrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ceil</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">copysign</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cosh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cospi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">erfc</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">erf</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">expm1</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fabs</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fdim</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">floor</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fma</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmax</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmod</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fract</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">frexp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">hypot</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ilogb</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ldexp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log1p</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">logb</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">mad</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented either as a correctly rounded fma or as a multiply followed by an add both of which are correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">maxmag</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">minmag</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">modf</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">nan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">nextafter</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pow(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pown(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">powr(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">remainder</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">remquo</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rint</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rootn</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">round</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rsqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sincos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp for sine and cosine values</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tgamma</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">trunc</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::cos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::divide</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::exp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::exp2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::exp10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::log</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::log2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::log10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::powr</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::recip</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::rsqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::sin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::sqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::tan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p><a href="#ulp_values_for_single_precision_builtin_math_functions_for_embedded_profile">ULP values for single precision builtin math functions for embedded profile</a> table describes the minimum accuracy of single precision floating-point arithmetic operations given as ULP values for the embedded profile.
The reference value used to compute the ULP value of an arithmetic operation is the infinitely precise result.</p></div>
<table class="tableblock frame-all grid-all" id="ulp_values_for_single_precision_builtin_math_functions_for_embedded_profile"
style="
width:100%;
">
<caption class="title">Table 36. ULP values for single precision built-in math functions for embedded profile</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Function</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Min Accuracy - ULP values <a href="#ftn32">[32</a>]</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>x</em> + <em>y</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>x</em> - <em>y</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>x</em> * <em>y</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1.0 / <em>x</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock"><em>x</em> / <em>y</em></p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acospi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2pi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acosh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cbrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ceil</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">copysign</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cosh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cospi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">erfc</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">erf</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">expm1</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fabs</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fdim</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">floor</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fma</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmax</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmod</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fract</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">frexp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">hypot</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ilogb</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ldexp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log1p</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">logb</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">mad</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Any value allowed (infinite ulp)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">maxmag</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">minmag</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">modf</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">nan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">nextafter</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pow(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pown(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">powr(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">remainder</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">remquo</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rint</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rootn</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">round</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rsqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sincos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp for sine and cosine values</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tgamma</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">trunc</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_cos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_divide</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_exp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_exp2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_exp10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_log</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_log2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_log10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_powr</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_recip</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_rsqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_sin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_sqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">half_tan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 8192 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::cos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::divide</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::exp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::exp2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::exp10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::log</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::log2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::log10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::powr</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::recip</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::rsqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::sin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::sqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">native_math::tan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implementation-defined</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p><a href="#ulp_values_for_single_precision_builtin_math_functions_with_fast_relaxed_math">ULP values for single precision built-in math functions with fast relaxed math</a> table describes the minimum accuracy of commonly used single precision floating-point arithmetic operations given as ULP values if the <em>-cl-fast-relaxed-math</em> compiler option is specified when compiling or building an OpenCL program.
For derived implementations, the operations used in the derivation may themselves be relaxed according to <a href="#ulp_values_for_single_precision_builtin_math_functions_with_fast_relaxed_math">ULP values for single precision built-in math functions with fast relaxed math</a> table.
The minimum accuracy of math functions not defined in <a href="#ulp_values_for_single_precision_builtin_math_functions_with_fast_relaxed_math">ULP values for single precision built-in math functions with fast relaxed math</a> table when the <em>-cl-fast-relaxed-math</em> compiler option is specified is as defined in <a href="#ulp_values_for_single_precision_builtin_math_functions">ULP values for single precision built-in math functions</a> table when operating in the full profile, and as defined in <a href="#ulp_values_for_single_precision_builtin_math_functions_for_embedded_profile">ULP values for single precision built-in math functions for embedded profile</a> table when operating in the embedded profile.
The reference value used to compute the ULP value of an arithmetic operation is the infinitely precise result.</p></div>
<table class="tableblock frame-all grid-all" id="ulp_values_for_single_precision_builtin_math_functions_with_fast_relaxed_math"
style="
width:100%;
">
<caption class="title">Table 37. ULP values for single precision built-in math functions with fast relaxed math in the full and embedded profiles</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Function</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Min Accuracy - ULP values <a href="#ftn32">[32</a>]</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1.0 / x</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2.5 ulp for x in the domain of 2<sup>-126</sup> to 2<sup>126</sup> for the full profile, and &lt;= 3 ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x / y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2.5 ulp for x in the domain of 2<sup>-62</sup> to 2<sup>62</sup> and <em>y</em> in the domain of 2<sup>-62</sup> to 2<sup>62</sup> for the full profile, and &lt;= 3 ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acos(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4096 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acospi(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented as acos(x) * M_PI_F.
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asin(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4096 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinpi(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented as asin(x) * M_PI_F.
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4096 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2(y, x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented as atan(y/x) for x &gt; 0, atan(y/x) + M_PI_F for x &lt; 0 and y &gt; 0 and atan(y/x) - M_PI_F for x &lt; 0 and y &lt; 0.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanpi(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented as atan(x) * M_1_PI_F.
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2pi(y, x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented as atan2(y, x) * M_1_PI_F.
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acosh(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented as log( x + sqrt(x*x - 1) ).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinh(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented as log( x + sqrt(x*x + 1) ).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanh(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Defined for x in the domain (-1, 1). For x in [-2<sup>-10</sup>, 2<sup>-10</sup>], implemented as x.
For x outside of [-2<sup>-10</sup>, 2<sup>-10</sup>], implemented as 0.5f * log( (1.0f + x) / (1.0f - x) ).
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cbrt(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented as rootn(x, 3).
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cos(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For x in the domain [-π, π], the maximum absolute error is &lt;= 2<sup>-11</sup> and larger otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cosh(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Defined for x in the domain [-88, 88] and implemented as 0.5f * ( exp(x) + exp(-x) ).
For non-derived implementations, the error is &lt;= 8192 ULP.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cospi(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For x in the domain [-1, 1], the maximum absolute error is &lt;= 2<sup>-11</sup> and larger otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 + floor( fabs(2 * x) ) ulp for the full profile, and &lt;= 4 ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp2(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 + floor( fabs(2 * x) ) ulp for the full profile, and &lt;= 4 ulp for the embedded profile.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp10(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Derived implementations implement this as exp2( x * log2(10) ).
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">expm1(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Derived implementations implement this as exp(x) - 1.
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For x in the domain [0.5, 2] the maximum absolute error is &lt;= 2<sup>-21</sup>; otherwise the maximum error is &lt;=3 ulp for the full profile and &lt;= 4 ulp for the embedded profile</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log2(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For x in the domain [0.5, 2] the maximum absolute error is &lt;= 2<sup>-21</sup>; otherwise the maximum error is &lt;=3 ulp for the full profile and &lt;= 4 ulp for the embedded profile</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log10(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For x in the domain [0.5, 2] the maximum absolute error is &lt;= 2<sup>-21</sup>; otherwise the maximum error is &lt;=3 ulp for the full profile and &lt;= 4 ulp for the embedded profile</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log1p(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Derived implementations implement this as log(x + 1).
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pow(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Undefined for x = 0 and y = 0.
Undefined for x &lt; 0 and non-integer y.
Undefined for x &lt; 0 and y outside the domain [-2<sup>24</sup>, 2<sup>24</sup>].
For x &gt; 0 or x &lt; 0 and even y, derived implementations implement this as exp2( y * log2(x) ).
For x &lt; 0 and odd y, derived implementations implement this as -exp2( y * log2(fabs(x) ) <a href="#ftn33">[33</a>].
For x == 0 and nonzero y, derived implementations return zero.
For non-derived implementations, the error is &lt;= 8192 ULP.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pown(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Defined only for integer values of y.
Undefined for x = 0 and y = 0.
For x &gt;= 0 or x &lt; 0 and even y, derived implementations implement this as exp2( y * log2(x) ).
For x &lt; 0 and odd y, derived implementations implement this as -exp2( y * log2( fabs(x) ) ).
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">powr(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Defined only for x &gt;= 0.
Undefined for x = 0 and y = 0.
Derived implementations implement this as exp2( y * log2(x) ).
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rootn(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Defined for x &gt; 0 when y is non-zero, derived implementations implement this case as exp2( log2(x) / y ). Defined for x &lt; 0 when y is odd, derived implementations implement this case as -exp2( log2(-x) / y ).
Defined for x = +/-0 when y &gt; 0, derived implementations will return +0 in this case.
For non-derived implementations, the error is &lt;= 8192 ULP.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sin(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For x in the domain [-π, π], the maximum absolute error is &lt;= 2<sup>-11</sup> and larger otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sincos(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ulp values as defined for sin(x) and cos(x).</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinh(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Defined for x in the domain [-88, 88].
For x in [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations implement as x.
For x outside of [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implement as 0.5f * ( exp(x) - exp(-x) ).
For non-derived implementations, the error is &lt;= 8192 ULP.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinpi(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">For x in the domain [-1, 1], the maximum absolute error is &lt;= 2<sup>-11</sup> and larger otherwise.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tan(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Derived implementations implement this as sin(x) * ( 1.0f / cos(x) ).
For non-derived implementations, the error is &lt;= 8192 ulp.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Defined for x in the domain [-88, 88].
For x in [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations implement as x.
For x outside of [-2<sup>-10</sup>, 2<sup>-10</sup>], derived implementations implement as ( exp(x) - exp(-x) ) / ( exp(x) + exp(-x) ).
For non-derived implementations, the error is &lt;= 8192 ULP.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanpi(x)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Derived implementations implement this as tan(x * M_PI_F).
For non-derived implementations, the error is &lt;= 8192 ulp for x in the domain [-1, 1].</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x * y + z</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Implemented either as a correctly rounded fma or as a multiply and an add both of which are correctly rounded.</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p><a href="#ulp_values_for_double_precision_builtin_math_functions">ULP values for double precision built-in math functions</a> table describes the minimum accuracy of double precision floating-point arithmetic operations given as ULP values.
The reference value used to compute the ULP value of an arithmetic operation is the infinitely precise result.</p></div>
<table class="tableblock frame-all grid-all" id="ulp_values_for_double_precision_builtin_math_functions"
style="
width:100%;
">
<caption class="title">Table 38. ULP values for double precision built-in math functions</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Function</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Min Accuracy - ULP values <a href="#ftn32">[32</a>]</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x + y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x - y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x * y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1.0 / x</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x / y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acospi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2pi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acosh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cbrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ceil</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">copysign</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cosh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cospi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">erfc</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">erf</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">expm1</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fabs</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fdim</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">floor</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fma</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmax</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmod</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fract</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">frexp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">hypot</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ilogb</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ldexp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 3 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log1p</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">logb</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">mad</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Any value allowed (infinite ulp)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">maxmag</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">minmag</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">modf</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">nan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">nextafter</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pow(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pown(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">powr(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">remainder</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">remquo</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rint</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rootn</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">round</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rsqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sincos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp for sine and cosine values</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 5 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 6 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tgamma</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 16 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">trunc</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p><a href="#ulp_values_for_half_precision_builtin_math_functions">ULP values for half precision built-in math functions</a> table describes the minimum accuracy of half precision floating-point arithmetic operations given as ULP values.
The reference value used to compute the ULP value of an arithmetic operation is the infinitely precise result.</p></div>
<table class="tableblock frame-all grid-all" id="ulp_values_for_half_precision_builtin_math_functions"
style="
width:100%;
">
<caption class="title">Table 39. ULP values for half precision built-in math functions</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><strong>Function</strong></th>
<th class="tableblock halign-left valign-top" ><strong>Min Accuracy - ULP values <a href="#ftn32">[32</a>]</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x + y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x - y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x * y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">1.0 / x</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">x / y</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acospi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atan2pi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">acosh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">asinh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">atanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cbrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ceil</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">copysign</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cosh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">cospi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">erfc</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">erf</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">exp10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">expm1</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fabs</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fdim</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">floor</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fma</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmax</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fmod</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">fract</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">frexp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">hypot</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ilogb</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">ldexp</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log2</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log10</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">log1p</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">logb</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">mad</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Any value allowed (infinite ulp)</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">maxmag</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">minmag</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">modf</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">nan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">nextafter</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pow(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">pown(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">powr(x, y)</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">remainder</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">remquo</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">0 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rint</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rootn</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">round</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">rsqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 1 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sin</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sincos</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp for sine and cosine values</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sinpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">sqrt</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tan</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanh</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tanpi</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 2 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">tgamma</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">&lt;= 4 ulp</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><p class="tableblock">trunc</p></td>
<td class="tableblock halign-left valign-top" ><p class="tableblock">Correctly rounded</p></td>
</tr>
</tbody>
</table>
</div>
<div class="sect2">
<h3 id="edge-case-behavior">4.5. Edge Case Behavior</h3>
<div class="paragraph"><p>The edge case behavior of the math functions (<em><a href="#math-functions">Math Functions</a> section</em>) shall conform to sections F.9 and G.6 of ISO/IEC 9899:TC 2, except where noted below in <em><a href="#additional-requirements-beyond-isoiec-9899tc2">Additional Requirements Beyond ISO/IEC 9899:TC2</a> section</em>.</p></div>
<div class="sect3">
<h4 id="additional-requirements-beyond-isoiec-9899tc2">4.5.1. Additional Requirements Beyond ISO/IEC 9899:TC2</h4>
<div class="paragraph"><p>Functions that return a NaN with more than one NaN operand shall return one of the NaN operands.
Functions that return a NaN operand may silence the NaN if it is a signaling NaN.
A non-signaling NaN shall be converted to a non-signaling NaN.
A signaling NaN shall be converted to a NaN, and should be converted to a non-signaling NaN.
How the rest of the NaN payload bits or the sign of NaN is converted is undefined.</p></div>
<div class="paragraph"><p>The usual allowances for rounding error (<em><a href="#relative-error-as-ulps">Relative Error as ULPs</a> section</em>) or flushing behavior (<em><a href="#edge-case-behavior-in-flush-to-zero-mode">Edge Case Behavior in Flush To Zero Mode</a> section</em>) shall not apply for those values for which <em>section F.9</em> of ISO/IEC 9899:,TC2, or <em><a href="#additional-requirements-beyond-isoiec-9899tc2">Additional Requirements Beyond ISO/IEC 9899:TC2</a></em> and <em><a href="#edge-case-behavior-in-flush-to-zero-mode">Edge Case Behavior in Flush To Zero Mode</a> sections</em> below (and similar sections for other floating-point precisions) prescribe a result (e.g. ceil( -1 &lt; x &lt; 0 ) returns -0).
Those values shall produce exactly the prescribed answers, and no other.
Where the ± symbol is used, the sign shall be preserved.
For example, sin(±0) = ±0 shall be interpreted to mean sin(+0) is +0 and sin(-0) is -0.</p></div>
<div class="ulist"><ul>
<li>
<p>
acospi( 1 ) = +0.
</p>
</li>
<li>
<p>
acospi( x ) returns a NaN for | x | &gt; 1.
</p>
</li>
<li>
<p>
asinpi( ±0 ) = ±0.
</p>
</li>
<li>
<p>
asinpi( x ) returns a NaN for | x | &gt; 1.
</p>
</li>
<li>
<p>
atanpi( ±0 ) = ±0.
</p>
</li>
<li>
<p>
atanpi ( ±∞ ) = ±0.5.
</p>
</li>
<li>
<p>
atan2pi ( ±0, -0 ) = ±1.
</p>
</li>
<li>
<p>
atan2pi ( ±0, +0 ) = ± 0.
</p>
</li>
<li>
<p>
atan2pi ( ±0, x ) returns ± 1 for x &lt; 0.
</p>
</li>
<li>
<p>
atan2pi ( ±0, x) returns ± 0 for x &gt; 0.
</p>
</li>
<li>
<p>
atan2pi ( y, ±0 ) returns -0.5 for y &lt; 0.
</p>
</li>
<li>
<p>
atan2pi ( y, ±0 ) returns 0.5 for y &gt; 0.
</p>
</li>
<li>
<p>
atan2pi ( ±y, -∞ ) returns ± 1 for finite y &gt; 0.
</p>
</li>
<li>
<p>
atan2pi ( ±y, +∞ ) returns ± 0 for finite y &gt; 0.
</p>
</li>
<li>
<p>
atan2pi ( ±∞, x ) returns ± 0.5 for finite x.
</p>
</li>
<li>
<p>
atan2pi (±∞, -∞ ) returns ±0.75.
</p>
</li>
<li>
<p>
atan2pi (±∞, +∞ ) returns ±0.25.
</p>
</li>
<li>
<p>
ceil( -1 &lt; x &lt; 0 ) returns -0.
</p>
</li>
<li>
<p>
cospi( ±0 ) returns 1
</p>
</li>
<li>
<p>
cospi( n + 0.5 ) is +0 for any integer n where n + 0.5 is representable.
</p>
</li>
<li>
<p>
cospi( ±∞ ) returns a NaN.
</p>
</li>
<li>
<p>
exp10( ±0 ) returns 1.
</p>
</li>
<li>
<p>
exp10( -∞ ) returns +0.
</p>
</li>
<li>
<p>
exp10( +∞ ) returns +∞.
</p>
</li>
<li>
<p>
distance(x, y) calculates the distance from x to y without overflow or extraordinary precision loss due to underflow.
</p>
</li>
<li>
<p>
fdim( any, NaN ) returns NaN.
</p>
</li>
<li>
<p>
fdim( NaN, any ) returns NaN.
</p>
</li>
<li>
<p>
fmod( ±0, NaN ) returns NaN.
</p>
</li>
<li>
<p>
frexp( ±∞, exp ) returns ±∞ and stores 0 in exp.
</p>
</li>
<li>
<p>
frexp( NaN, exp ) returns the NaN and stores 0 in exp.
</p>
</li>
<li>
<p>
fract( x, iptr) shall not return a value greater than or equal to 1.0, and shall not return a value less than 0.
</p>
</li>
<li>
<p>
fract( +0, iptr ) returns +0 and +0 in iptr.
</p>
</li>
<li>
<p>
fract( -0, iptr ) returns -0 and -0 in iptr.
</p>
</li>
<li>
<p>
fract( +inf, iptr ) returns +0 and +inf in iptr.
</p>
</li>
<li>
<p>
fract( -inf, iptr ) returns -0 and -inf in iptr.
</p>
</li>
<li>
<p>
fract( NaN, iptr ) returns the NaN and NaN in iptr.
</p>
</li>
<li>
<p>
length calculates the length of a vector without overflow or extraordinary precision loss due to underflow.
</p>
</li>
<li>
<p>
lgamma_r( x, signp ) returns 0 in signp if x is zero or a negative integer.
</p>
</li>
<li>
<p>
nextafter( -0, y &gt; 0 ) returns smallest positive denormal value.
</p>
</li>
<li>
<p>
nextafter( +0, y &lt; 0 ) returns smallest negative denormal value.
</p>
</li>
<li>
<p>
normalize shall reduce the vector to unit length, pointing in the same direction without overflow or extraordinary precision loss due to underflow.
</p>
</li>
<li>
<p>
normalize( v ) returns v if all elements of v are zero.
</p>
</li>
<li>
<p>
normalize( v ) returns a vector full of NaNs if any element is a NaN.
</p>
</li>
<li>
<p>
normalize( v ) for which any element in v is infinite shall proceed as if the elements in v were replaced as follows:
</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="font-weight: bold"><span style="color: #0000FF">for</span></span><span style="color: #990000">(</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="font-weight: bold"><span style="color: #0000FF">sizeof</span></span><span style="color: #990000">(</span>v<span style="color: #990000">)</span> <span style="color: #990000">/</span> <span style="font-weight: bold"><span style="color: #0000FF">sizeof</span></span><span style="color: #990000">(</span>v<span style="color: #990000">[</span><span style="color: #993399">0</span><span style="color: #990000">]</span> <span style="color: #990000">);</span> i<span style="color: #990000">++</span> <span style="color: #990000">)</span>
v<span style="color: #990000">[</span>i<span style="color: #990000">]</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">isinf</span></span><span style="color: #990000">(</span>v<span style="color: #990000">[</span>i<span style="color: #990000">]</span> <span style="color: #990000">)</span> <span style="color: #990000">?</span> <span style="font-weight: bold"><span style="color: #000000">copysign</span></span><span style="color: #990000">(</span><span style="color: #993399">1.0</span><span style="color: #990000">,</span> v<span style="color: #990000">[</span>i<span style="color: #990000">])</span> <span style="color: #990000">:</span> <span style="color: #993399">0.0</span> <span style="color: #990000">*</span> v <span style="color: #990000">[</span>i<span style="color: #990000">];</span></tt></pre></div></div>
</li>
<li>
<p>
pow( ±0, -∞ ) returns +∞
</p>
</li>
<li>
<p>
pown( x, 0 ) is 1 for any x, even zero, NaN or infinity.
</p>
</li>
<li>
<p>
pown( ±0, n ) is ±∞ for odd n &lt; 0.
</p>
</li>
<li>
<p>
pown( ±0, n ) is +∞ for even n &lt; 0.
</p>
</li>
<li>
<p>
pown( ±0, n ) is +0 for even n &gt; 0.
</p>
</li>
<li>
<p>
pown( ±0, n ) is ±0 for odd n &gt; 0.
</p>
</li>
<li>
<p>
powr( x, ±0 ) is 1 for finite x &gt; 0.
</p>
</li>
<li>
<p>
powr( ±0, y ) is +∞ for finite y &lt; 0.
</p>
</li>
<li>
<p>
powr( ±0, -∞) is +∞.
</p>
</li>
<li>
<p>
powr( ±0, y ) is +0 for y &gt; 0.
</p>
</li>
<li>
<p>
powr( +1, y ) is 1 for finite y.
</p>
</li>
<li>
<p>
powr( x, y ) returns NaN for x &lt; 0.
</p>
</li>
<li>
<p>
powr( ±0, ±0 ) returns NaN.
</p>
</li>
<li>
<p>
powr( +∞, ±0 ) returns NaN.
</p>
</li>
<li>
<p>
powr( +1, ±∞ ) returns NaN.
</p>
</li>
<li>
<p>
powr( x, NaN ) returns the NaN for x &gt;= 0.
</p>
</li>
<li>
<p>
powr( NaN, y ) returns the NaN.
</p>
</li>
<li>
<p>
rint( -0.5 &lt;= x &lt; 0 ) returns -0.
</p>
</li>
<li>
<p>
remquo(x, y, &amp;quo) returns a NaN and 0 in quo if x is ±∞, or if y is 0 and the other argument is non-NaN or if either argument is a NaN.
</p>
</li>
<li>
<p>
rootn( ±0, n ) is ±∞ for odd n &lt; 0.
</p>
</li>
<li>
<p>
rootn( ±0, n ) is +∞ for even n &lt; 0.
</p>
</li>
<li>
<p>
rootn( ±0, n ) is +0 for even n &gt; 0.
</p>
</li>
<li>
<p>
rootn( ±0, n ) is ±0 for odd n &gt; 0.
</p>
</li>
<li>
<p>
rootn( x, n ) returns a NaN for x &lt; 0 and n is even.
</p>
</li>
<li>
<p>
rootn( x, 0 ) returns a NaN.
</p>
</li>
<li>
<p>
round( -0.5 &lt; x &lt; 0 ) returns -0.
</p>
</li>
<li>
<p>
sinpi( ±0 ) returns ±0.
</p>
</li>
<li>
<p>
sinpi( +n) returns +0 for positive integers n.
</p>
</li>
<li>
<p>
sinpi( -n ) returns -0 for negative integers n.
</p>
</li>
<li>
<p>
sinpi( ±∞ ) returns a NaN.
</p>
</li>
<li>
<p>
tanpi( ±0 ) returns ±0.
</p>
</li>
<li>
<p>
tanpi( ±∞ ) returns a NaN.
</p>
</li>
<li>
<p>
tanpi( n ) is copysign( 0.0, n ) for even integers n.
</p>
</li>
<li>
<p>
tanpi( n ) is copysign( 0.0, - n) for odd integers n.
</p>
</li>
<li>
<p>
tanpi( n + 0.5 ) for even integer n is +∞ where n + 0.5 is representable.
</p>
</li>
<li>
<p>
tanpi( n + 0.5 ) for odd integer n is -∞ where n + 0.5 is representable.
</p>
</li>
<li>
<p>
trunc( -1 &lt; x &lt; 0 ) returns -0.
</p>
</li>
</ul></div>
</div>
<div class="sect3">
<h4 id="changes-to-isoiec-9899-tc2-behavior">4.5.2. Changes to ISO/IEC 9899: TC2 Behavior</h4>
<div class="paragraph"><p><span class="monospaced">modf</span> behaves as though implemented by:</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">modf</span></span><span style="color: #990000">(</span> <span style="color: #008080">gentype</span> value<span style="color: #990000">,</span> <span style="color: #008080">gentype</span> <span style="color: #990000">*</span>iptr <span style="color: #990000">)</span>
<span style="color: #FF0000">{</span>
<span style="color: #990000">*</span>iptr <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">trunc</span></span><span style="color: #990000">(</span> value <span style="color: #990000">);</span>
<span style="font-weight: bold"><span style="color: #0000FF">return</span></span> <span style="font-weight: bold"><span style="color: #000000">copysign</span></span><span style="color: #990000">(</span> <span style="font-weight: bold"><span style="color: #000000">isinf</span></span><span style="color: #990000">(</span> value <span style="color: #990000">)</span> <span style="color: #990000">?</span> <span style="color: #993399">0.0</span> <span style="color: #990000">:</span> value <span style="color: #990000">-</span> <span style="color: #990000">*</span>iptr<span style="color: #990000">,</span> value <span style="color: #990000">);</span>
<span style="color: #FF0000">}</span></tt></pre></div></div>
<div class="paragraph"><p>rint always rounds according to round to nearest even rounding mode even if the caller is in some other rounding mode.</p></div>
</div>
<div class="sect3">
<h4 id="edge-case-behavior-in-flush-to-zero-mode">4.5.3. Edge Case Behavior in Flush To Zero Mode</h4>
<div class="paragraph"><p>If denormals are flushed to zero, then a function may return one of four results:</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
Any conforming result for non-flush-to-zero mode.
</p>
</li>
<li>
<p>
If the result given by 1. is a sub-normal before rounding, it may be flushed to zero.
</p>
</li>
<li>
<p>
Any non-flushed conforming result for the function if one or more of its sub-normal operands are flushed to zero.
</p>
</li>
<li>
<p>
If the result of 3. is a sub-normal before rounding, the result may be flushed to zero.
</p>
</li>
</ol></div>
<div class="paragraph"><p>In each of the above cases, if an operand or result is flushed to zero, the sign of the zero is undefined.</p></div>
<div class="paragraph"><p>If subnormals are flushed to zero, a device may choose to conform to the following edge cases for nextafter instead of those listed in <em><a href="#additional-requirements-beyond-isoiec-9899tc2">Additional Requirements Beyond ISO/IEC 9899:TC2</a> section</em>:</p></div>
<div class="ulist"><ul>
<li>
<p>
nextafter ( +smallest normal, y &lt; +smallest normal ) = +0.
</p>
</li>
<li>
<p>
nextafter ( -smallest normal, y &gt; -smallest normal ) = -0.
</p>
</li>
<li>
<p>
nextafter ( -0, y &gt; 0 ) returns smallest positive normal value.
</p>
</li>
<li>
<p>
nextafter ( +0, y &lt; 0 ) returns smallest negative normal value.
</p>
</li>
</ul></div>
<div class="paragraph"><p>For clarity, subnormals or denormals are defined to be the set of representable numbers in the range 0 &lt; x &lt; TYPE_MIN and -TYPE_MIN &lt; x &lt; -0.
They do not include ±0.
A non-zero number is said to be sub-normal before rounding if after normalization, its radix-2 exponent is less than (TYPE_MIN_EXP - 1). <a href="#ftn35">[35</a>]</p></div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="image-addressing-and-filtering">5. Image Addressing and Filtering</h2>
<div class="sectionbody">
<div class="paragraph"><p>Let w<sub>t</sub>, h<sub>t</sub> and d<sub>t</sub> be the width, height (or image array size for a 1D image array) and depth (or image array size for a 2D image array) of the image in pixels.
Let coord.xy also referred to as (s,t) or coord.xyz also referred to as (s,t,r) be the coordinates specified to <span class="monospaced">image::read</span>.
The sampler specified in <span class="monospaced">image::read</span> is used to determine how to sample the image and return an appropriate color.</p></div>
<div class="sect2">
<h3 id="image-coordinates">5.1. Image Coordinates</h3>
<div class="paragraph"><p>This affects the interpretation of image coordinates.
If image coordinates specified to <span class="monospaced">image::read</span> are normalized (as specified in the sampler), the s,t, and r coordinate values are multiplied by w<sub>t</sub>, h<sub>t,</sub> and d<sub>t</sub> respectively to generate the unnormalized coordinate values.
For image arrays, the image array coordinate (i.e. t if it is a 1D image array or r if it is a 2D image array) specified to <span class="monospaced">image::read</span> must always be the unnormalized image coordinate value.</p></div>
<div class="paragraph"><p>Let (u,v,w) represent the unnormalized image coordinate values.</p></div>
</div>
<div class="sect2">
<h3 id="addressing-and-filter-modes">5.2. Addressing and Filter Modes</h3>
<div class="paragraph"><p>We first describe how the addressing and filter modes are applied to generate the appropriate sample locations to read from the image if the addressing mode is not <span class="monospaced">addressing_mode::repeat</span> nor <span class="monospaced">addressing_mode::mirrored_repeat</span>.</p></div>
<div class="paragraph"><p>After generating the image coordinate (u,v,w) we apply the appropriate addressing and filter mode to generate the appropriate sample locations to read from the image.</p></div>
<div class="paragraph"><p>If values in (u,v,w) are INF or NaN, the behavior of <span class="monospaced">image::read</span> is undefined.</p></div>
<div class="sect3">
<h4 id="filtering_modenearest">5.2.1. filtering_mode::nearest</h4>
<div class="paragraph"><p>When filter mode is <span class="monospaced">filtering_mode::nearest</span>, the image element in the image that is nearest (in Manhattan distance) to that specified by (u,v,w) is obtained.
This means the image element at location (i,j,k) becomes the image element value, where</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
i &=& address\_mode((int)floor(u))\\
j &=& address\_mode((int)floor(v))\\
k &=& address\_mode((int)floor(w))
\end{array}
\]</div></div>
<div class="paragraph"><p>For a 3D image, the image element at location (i, j, k) becomes the color value.
For a 2D image, the image element at location (i, j) becomes the color value.</p></div>
<div class="paragraph"><p>The below table describes the <span class="monospaced">address_mode</span> function.</p></div>
<table class="tableblock frame-all grid-all" id="addressing_modes_to_generate_texel_location"
style="
width:100%;
">
<caption class="title">Table 40. Addressing modes to generate texel location</caption>
<col style="width:50%;">
<col style="width:50%;">
<thead>
<tr>
<th class="tableblock halign-left valign-top" ><div class="paragraph"><p><strong>Addressing Mode</strong></p></div></th>
<th class="tableblock halign-left valign-top" ><div class="paragraph"><p><strong>Result of address_mode(coord)</strong></p></div></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">clamp_to_edge</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>clamp (coord, 0, size - 1)</p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">clamp</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>clamp (coord, -1, size)</p></div></div></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p><span class="monospaced">none</span></p></div></div></td>
<td class="tableblock halign-left valign-top" ><div><div class="paragraph"><p>Coord</p></div></div></td>
</tr>
</tbody>
</table>
<div class="paragraph"><p>The size term in <a href="#addressing_modes_to_generate_texel_location">Addressing modes to generate texel location</a> table is w<sub>t</sub> for u, h<sub>t</sub> for v and d<sub>t</sub> for w.</p></div>
<div class="paragraph"><p>The clamp function used in <a href="#addressing_modes_to_generate_texel_location">Addressing modes to generate texel location</a> table is defined as:</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
clamp(a, b, c) &=& return (a < b) ? b : ((a > c) ? c : a)
\end{array}
\]</div></div>
<div class="paragraph"><p>If the selected texel location (i,j,k) refers to a location outside the image, the border color is used as the color value for this texel.</p></div>
</div>
<div class="sect3">
<h4 id="filtering_modelinear">5.2.2. filtering_mode::linear</h4>
<div class="paragraph"><p>When filter mode is <span class="monospaced">filtering_mode::linear</span>, a 2 x 2 square of image elements for a 2D image or a 2 x 2 x 2 cube of image elements for a 3D image is selected.
This 2 x 2 square or 2 x 2 x 2 cube is obtained as follows.</p></div>
<div class="paragraph"><p>Let</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
i0 &=& address\_mode((int)floor(u - 0.5))\\
j0 &=& address\_mode((int)floor(v - 0.5))\\
k0 &=& address\_mode((int)floor(w - 0.5))\\
i1 &=& address\_mode((int)floor(u - 0.5) + 1)\\
j1 &=& address\_mode((int)floor(v - 0.5) + 1)\\
k1 &=& address\_mode((int)floor(w - 0.5) + 1)\\
a &=& frac(u - 0.5)\\
b &=& frac(v - 0.5)\\
c &=& frac(w - 0.5)
\end{array}
\]</div></div>
<div class="paragraph"><p>where frac(x) denotes the fractional part of x and is computed as x - floor(x).</p></div>
<div class="paragraph"><p>For a 3D image, the image element value is found as</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
T &=& (1 - a) * (1 - b) * (1 - c) * T_{i0j0k0}\\
&& \negmedspace {} + a * (1 - b) * (1 - c) * T_{i1j0k0}\\
&& \negmedspace {} + (1 - a) * b * (1 - c) * T_{i0j1k0}\\
&& \negmedspace {} + a * b * (1 - c) * T_{i1j1k0}\\
&& \negmedspace {} + (1 - a) * (1 - b) * c * T_{i0j0k1}\\
&& \negmedspace {} + a * (1 - b) * c * T_{i1j0k1}\\
&& \negmedspace {} + (1 - a) * b * c * T_{i0j1k1}\\
&& \negmedspace {} + a * b * c * T_{i1j1k1}
\end{array}
\]</div></div>
<div class="paragraph"><p>where T<sub>ijk</sub> is the image element at location (i,j,k) in the 3D image.</p></div>
<div class="paragraph"><p>For a 2D image, the image element value is found as</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
T &=& (1 - a) * (1 - b) * T_{i0j0}\\
&& \negmedspace {} + a * (1 - b) * T_{i1j0}\\
&& \negmedspace {} + (1 - a) * b * T_{i0j1}\\
&& \negmedspace {} + a * b * T_{i1j1}
\end{array}
\]</div></div>
<div class="paragraph"><p>where T<sub>ij</sub> is the image element at location (i,j) in the 2D image.</p></div>
<div class="paragraph"><p>If any of the selected T<sub>ijk</sub> or T<sub>ij</sub> in the above equations refers to a location outside the image, the border color is used as the color value for T<sub>ijk</sub> or T<sub>ij</sub>.</p></div>
<div class="paragraph"><p>If the image channel type is <span class="monospaced">CL_FLOAT</span> or <span class="monospaced">CL_HALF_FLOAT</span> and any of the image elements T<sub>ijk</sub> or T<sub>ij</sub> is INF or NaN, the behavior of the built-in image read function is undefined.</p></div>
<div class="paragraph"><p>We now discuss how the addressing and filter modes are applied to generate the appropriate sample locations to read from the image if the addressing mode is <span class="monospaced">addressing_mode::repeat</span>.</p></div>
<div class="paragraph"><p>If values in (s,t,r) are INF or NaN, the behavior of the built-in image read functions is undefined.</p></div>
</div>
<div class="sect3">
<h4 id="filtering_modenearest-1">5.2.3. filtering_mode::nearest</h4>
<div class="paragraph"><p>When filter mode is <span class="monospaced">filtering_mode::nearest</span>, the image element at location (i,j,k) becomes the image element value, with i, j and k computed as</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
u = (s - floor(s)) * w_t\\
i = (int)floor(u)\\
if (i > w_t - 1)\\
\qquad i = i - w_t\\
v = (t - floor(t)) * h_t\\
j = (int)floor(v)\\
if (j > h_t - 1)\\
\qquad j = j - h_t\\
w = (r - floor(r)) * d_t\\
k = (int)floor(w)\\
if (k > d_t - 1)\\
\qquad k = k - d_t
\end{array}
\]</div></div>
<div class="paragraph"><p>For a 3D image, the image element at location (i, j, k) becomes the color value.
For a 2D image, the image element at location (i, j) becomes the color value.</p></div>
</div>
<div class="sect3">
<h4 id="filtering_modelinear-1">5.2.4. filtering_mode::linear</h4>
<div class="paragraph"><p>When filter mode is <span class="monospaced">filtering_mode::linear</span>, a 2 x 2 square of image elements for a 2D image or a 2 x 2 x 2 cube of image elements for a 3D image is selected.
This 2 x 2 square or 2 x 2 x 2 cube is obtained as follows.</p></div>
<div class="paragraph"><p>Let</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
u = (s - floor(s)) * w_t\\
i0 = (int)floor(u - 0.5)\\
i1 = i0 + 1\\
if (i0 < 0)\\
i0 = w_t + i0\\
if (i1 > w_t - 1)\\
\qquad i1 = i1 - w_t\\
v = (t - floor(t)) * h_t\\
j0 = (int)floor(v - 0.5)\\
j1 = j0 + 1\\
if (j0 < 0)\\
j0 = h_t + j0\\
if (j1 > h_t - 1)\\
\qquad j1 = j1 - h_t\\
w = (r - floor(r)) * d_t\\
k0 = (int)floor(w - 0.5)\\
k1 = k0 + 1\\
if (k0 < 0)\\
\qquad k0 = d_t + k0\\
if (k1 > d_t - 1)\\
\qquad k1 = k1 - d_t\\
a = frac(u - 0.5)\\
b = frac(v - 0.5)\\
c = frac(w - 0.5)
\end{array}
\]</div></div>
<div class="paragraph"><p>where frac(x) denotes the fractional part of x and is computed as x - floor(x).</p></div>
<div class="paragraph"><p>For a 3D image, the image element value is found as</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
T &=& (1 - a) * (1 - b) * (1 - c) * T_{i0j0k0}\\
&& \negmedspace {} + a * (1 - b) * (1 - c) * T_{i1j0k0}\\
&& \negmedspace {} + (1 - a) * b * (1 - c) * T_{i0j1k0}\\
&& \negmedspace {} + a * b * (1 - c) * T_{i1j1k0}\\
&& \negmedspace {} + (1 - a) * (1 - b) * c * T_{i0j0k1}\\
&& \negmedspace {} + a * (1 - b) * c * T_{i1j0k1}\\
&& \negmedspace {} + (1 - a) * b * c * T_{i0j1k1}\\
&& \negmedspace {} + a * b * c * T_{i1j1k1}
\end{array}
\]</div></div>
<div class="paragraph"><p>where T<sub>ijk</sub> is the image element at location (i,j,k) in the 3D image.</p></div>
<div class="paragraph"><p>For a 2D image, the image element value is found as</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
T &=&(1 - a) * (1 - b) * T_{i0j0}\\
&& \negmedspace {} + a * (1 - b) * T_{i1j0}\\
&& \negmedspace {} + (1 - a) * b * T_{i0j1}\\
&& \negmedspace {} + a * b * T_{i1j1}
\end{array}
\]</div></div>
<div class="paragraph"><p>where T<sub>ij</sub> is the image element at location (i,j) in the 2D image.</p></div>
<div class="paragraph"><p>If the image channel type is <span class="monospaced">CL_FLOAT</span> or <span class="monospaced">CL_HALF_FLOAT</span> and any of the image elements T<sub>ijk</sub> or T<sub>ij</sub> is INF or NaN, the behavior of the built-in image read function is undefined.</p></div>
<div class="paragraph"><p>We now discuss how the addressing and filter modes are applied to generate the appropriate sample locations to read from the image if the addressing mode is <span class="monospaced">addressing_mode::repeat</span>.
The <span class="monospaced">addressing_mode::mirrored_repeat</span> addressing mode causes the image to be read as if it is tiled at every integer seam with the interpretation of the image data flipped at each integer crossing.
For example, the (s,t,r) coordinates between 2 and 3 are addressed into the image as coordinates from 1 down to 0.
If values in (s,t,r) are INF or NaN, the behavior of the built-in image read functions is undefined.</p></div>
</div>
<div class="sect3">
<h4 id="filtering_modenearest-2">5.2.5. filtering_mode::nearest</h4>
<div class="paragraph"><p>When filter mode is <span class="monospaced">filtering_mode::nearest</span>, the image element at location (i,j,k) becomes the image element value, with i,j and k computed as</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
s' &=& 2.0f * rint(0.5f * s)\\
s' &=& fabs(s - s')\\
u &=& s' * w_t\\
i &=& (int)floor(u)\\
i &=& min(i, w_t - 1)\\
t' &=& 2.0f * rint(0.5f * t)\\
t' &=& fabs(t - t')\\
v &=& t' * h_t\\
j &=& (int)floor(v)\\
j &=& min(j, h_t - 1)\\
r' &=& 2.0f * rint(0.5f * r)\\
r' &=& fabs(r - r')\\
w &=& r' * d_t\\
k &=& (int)floor(w)\\
k &=& min(k, d_t - 1)
\end{array}
\]</div></div>
<div class="paragraph"><p>For a 3D image, the image element at location (i, j, k) becomes the color value.
For a 2D image, the image element at location (i, j) becomes the color value.</p></div>
</div>
<div class="sect3">
<h4 id="filtering_modelinear-2">5.2.6. filtering_mode::linear</h4>
<div class="paragraph"><p>When filter mode is <span class="monospaced">filtering_mode::linear</span>, a 2 x 2 square of image elements for a 2D image or a 2 x 2 x 2 cube of image elements for a 3D image is selected.
This 2 x 2 square or 2 x 2 x 2 cube is obtained as follows.</p></div>
<div class="paragraph"><p>Let</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
s' &=& 2.0f * rint(0.5f * s)\\
s' &=& fabs(s - s')\\
u &=& s' * w_t\\
i0 &=& (int)floor(u - 0.5f)\\
i1 &=& i0 + 1\\
i0 &=& max(i0, 0)\\
i1 &=& min(i1, w_t - 1)\\
t' &=& 2.0f * rint(0.5f * t)\\
t' &=& fabs(t - t')\\
v &=& t' * h_t\\
j0 &=& (int)floor(v - 0.5f)\\
j1 &=& j0 + 1\\
j0 &=& max(j0, 0)\\
j1 &=& min(j1, h_t - 1)\\
r' &=& 2.0f * rint(0.5f * r)\\
r' &=& fabs(r - r')\\
w &=& r' * d_t\\
k0 &=& (int)floor(w - 0.5f)\\
k1 &=& k0 + 1\\
k0 &=& max(k0, 0)\\
k1 &=& min(k1, d_t - 1)\\
a &=& frac(u - 0.5)\\
b &=& frac(v - 0.5)\\
c &=& frac(w - 0.5)
\end{array}
\]</div></div>
<div class="paragraph"><p>where frac(x) denotes the fractional part of x and is computed as x - floor(x).</p></div>
<div class="paragraph"><p>For a 3D image, the image element value is found as</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
T &=& (1 - a) * (1 - b) * (1 - c) * T_{i0j0k0}\\
&& \negmedspace {} + a * (1 - b) * (1 - c) * T_{i1j0k0}\\
&& \negmedspace {} + (1 - a) * b * (1 - c) * T_{i0j1k0}\\
&& \negmedspace {} + a * b * (1 - c) * T_{i1j1k0}\\
&& \negmedspace {} + (1 - a) * (1 - b) * c * T_{i0j0k1}\\
&& \negmedspace {} + a * (1 - b) * c * T_{i1j0k1}\\
&& \negmedspace {} + (1 - a) * b * c * T_{i0j1k1}\\
&& \negmedspace {} + a * b * c * T_{i1j1k1}
\end{array}
\]</div></div>
<div class="paragraph"><p>where T<sub>ijk</sub> is the image element at location (i,j,k) in the 3D image.</p></div>
<div class="paragraph"><p>For a 2D image, the image element value is found as</p></div>
<div class="mathblock">
<div class="content">\[
\begin{array}{rcl}
T &=& (1 - a) * (1 - b) * T_{i0j0}\\
&& \negmedspace {} + a * (1 - b) * T_{i1j0}\\
&& \negmedspace {} + (1 - a) * b * T_{i0j1}\\
&& \negmedspace {} + a * b * T_{i1j1}
\end{array}
\]</div></div>
<div class="paragraph"><p>where T<sub>ij</sub> is the image element at location (i,j) in the 2D image.</p></div>
<div class="paragraph"><p>For a 1D image, the image element value is found as</p></div>
<div class="mathblock">
<div class="content">\[
T = (1 - a) * T_i0 + a * T_i1
\]</div></div>
<div class="paragraph"><p>where T<sub>i</sub> is the image element at location (i) in the 1D image.</p></div>
<div class="paragraph"><p>If the image channel type is <span class="monospaced">CL_FLOAT</span> or <span class="monospaced">CL_HALF_FLOAT</span> and any of the image elements T<sub>ijk</sub> or T<sub>ij</sub> is INF or NaN, the behavior of the built-in image read function is undefined.</p></div>
<div class="admonitionblock">
<table><tr>
<td class="icon">
<div class="title">Note</div>
</td>
<td class="content">If the sampler is specified as using unnormalized coordinates (floating-point or integer coordinates), filter mode set to <span class="monospaced">filtering_mode::nearest</span> and addressing mode set to one of the following modes - <span class="monospaced">addressing_mode::none</span>, <span class="monospaced">addressing_mode::clamp_to_edge</span> or <span class="monospaced">addressing_mode::clamp</span>, the location of the image element in the image given by (i, j, k) will be computed without any loss of precision.
For all other sampler combinations of normalized or unnormalized coordinates, filter and addressing modes, the relative error or precision of the addressing mode calculations and the image filter operation are not defined by this revision of the OpenCL specification.
To ensure a minimum precision of image addressing and filter calculations across any OpenCL device, for these sampler combinations, developers should unnormalize the image coordinate in the kernel and implement the linear filter in the kernel with appropriate calls to <span class="monospaced">image::read</span> with a sampler that uses unnormalized coordinates, filter mode set to <span class="monospaced">filtering_mode::nearest</span>, addressing mode set to <span class="monospaced">addressing_mode::none</span>, <span class="monospaced">addressing_mode::clamp_to_edge</span> or <span class="monospaced">addressing_mode::clamp</span> and finally performing the interpolation of color values read from the image to generate the filtered color value.</td>
</tr></table>
</div>
</div>
</div>
<div class="sect2">
<h3 id="conversion-rules">5.3. Conversion Rules</h3>
<div class="paragraph"><p>In this section we discuss conversion rules that are applied when reading and writing images in a kernel.</p></div>
<div class="sect3">
<h4 id="conversion-rules-for-normalized-integer-channel-data-types">5.3.1. Conversion rules for normalized integer</h4>
<div class="paragraph"><p>In this section we discuss converting normalized integer channel data types to half-precision and single-precision floating-point values and vice-versa.</p></div>
<div class="sect4">
<h5 id="converting-normalized-integer-channel-data-types-to-half-precision-floating-point-values">Converting normalized integer channel data types to half precision floating-point values</h5>
<div class="paragraph"><p>For images created with image channel data type of <span class="monospaced">CL_UNORM_INT8</span> and <span class="monospaced">CL_UNORM_INT16</span>, <span class="monospaced">image::read</span> will convert the channel values from an 8-bit or 16-bit unsigned integer to normalized half precision floating-point values in the range [0.0h &#8230; 1.0h].</p></div>
<div class="paragraph"><p>For images created with image channel data type of <span class="monospaced">CL_SNORM_INT8</span> and <span class="monospaced">CL_SNORM_INT16</span>, <span class="monospaced">image::read</span> will convert the channel values from an 8-bit or 16-bit signed integer to normalized half precision floating-point values in the range [-1.0h &#8230; 1.0h].</p></div>
<div class="paragraph"><p>These conversions are performed as follows:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">CL_UNORM_INT8</span> (8-bit unsigned integer) &#8594; <span class="monospaced">half</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_half\_value(x)=round\_to\_half(\frac{x}{255})
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">CL_UNORM_INT_101010</span> (10-bit unsigned integer) &#8594; <span class="monospaced">half</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_half\_value(x)=round\_to\_half(\frac{x}{1023})
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">CL_UNORM_INT16</span> (16-bit unsigned integer) &#8594; <span class="monospaced">half</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_half\_value(x)=round\_to\_half(\frac{x}{65535})
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">CL_SNORM_INT8</span> (8-bit signed integer) &#8594; <span class="monospaced">half</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_half\_value(x)=max(-1.0h, round\_to\_half(\frac{x}{127}))
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">CL_SNORM_INT16</span> (16-bit signed integer) &#8594; <span class="monospaced">half</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_half\_value(x)=max(-1.0h, round\_to\_half(\frac{x}{32767}))
\]</div></div>
</li>
</ul></div>
<div class="paragraph"><p>The precision of the above conversions is &lt;= 1.5 ulp except for the following cases.</p></div>
<div class="paragraph"><p>For <span class="monospaced">CL_UNORM_INT8</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
0 must convert to 0.0h and
</p>
</li>
<li>
<p>
255 must convert to 1.0h
</p>
</li>
</ul></div>
<div class="paragraph"><p>For <span class="monospaced">CL_UNORM_INT_101010</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
0 must convert to 0.0h and
</p>
</li>
<li>
<p>
1023 must convert to 1.0h
</p>
</li>
</ul></div>
<div class="paragraph"><p>For <span class="monospaced">CL_UNORM_INT16</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
0 must convert to 0.0h and
</p>
</li>
<li>
<p>
65535 must convert to 1.0h
</p>
</li>
</ul></div>
<div class="paragraph"><p>For <span class="monospaced">CL_SNORM_INT8</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
-128 and -127 must convert to -1.0h,
</p>
</li>
<li>
<p>
0 must convert to 0.0h and
</p>
</li>
<li>
<p>
127 must convert to 1.0h
</p>
</li>
</ul></div>
<div class="paragraph"><p>For <span class="monospaced">CL_SNORM_INT16</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
-32768 and -32767 must convert to -1.0h,
</p>
</li>
<li>
<p>
0 must convert to 0.0h and
</p>
</li>
<li>
<p>
32767 must convert to 1.0h
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="converting-half-precision-floating-point-values-to-normalized-integer-channel-data-types">Converting half precision floating-point values to normalized integer channel data types</h5>
<div class="paragraph"><p>For images created with image channel data type of <span class="monospaced">CL_UNORM_INT8</span> and <span class="monospaced">CL_UNORM_INT16</span>, <span class="monospaced">image::write</span> will convert the half precision floating-point color value to an 8-bit or 16-bit unsigned integer.</p></div>
<div class="paragraph"><p>For images created with image channel data type of <span class="monospaced">CL_SNORM_INT8</span> and <span class="monospaced">CL_SNORM_INT16</span>, <span class="monospaced">image::write</span> will convert the half precision floating-point color value to an 8-bit or 16-bit signed integer.</p></div>
<div class="paragraph"><p>OpenCL implementations may choose to approximate the rounding mode used in the conversions described below.
When approximate rounding is used instead of the preferred rounding, the result of the conversion must satisfy the bound given below.</p></div>
<div class="paragraph"><p>The conversions from half precision floating-point values to normalized integer values are performed is as follows:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">half</span> &#8594; <span class="monospaced">CL_UNORM_INT8</span> (8-bit unsigned integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(0,min(255,255 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint8(f(x)) & x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint8(f(x)) & x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">half</span> &#8594; <span class="monospaced">CL_UNORM_INT16</span> (16-bit unsigned integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(0,min(65535,65535 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint16(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint16(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">half</span> &#8594; <span class="monospaced">CL_SNORM_INT8</span> (8-bit signed integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(-128,min(127,127 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint8(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint8(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">half</span> &#8594; <span class="monospaced">CL_SNORM_INT16</span> (16-bit signed integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(-32768,min(32767,32767 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint16(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint16(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="converting-normalized-integer-channel-data-types-to-floating-point-values">Converting normalized integer channel data types to floating-point values</h5>
<div class="paragraph"><p>For images created with image channel data type of <span class="monospaced">CL_UNORM_INT8</span> and <span class="monospaced">CL_UNORM_INT16</span>, <span class="monospaced">image::read</span> will convert the channel values from an 8-bit or 16-bit unsigned integer to normalized floating-point values in the range [0.0f &#8230; 1.0f].</p></div>
<div class="paragraph"><p>For images created with image channel data type of <span class="monospaced">CL_SNORM_INT8</span> and <span class="monospaced">CL_SNORM_INT16</span>, <span class="monospaced">image::read</span> will convert the channel values from an 8-bit or 16-bit signed integer to normalized floating-point values in the range [-1.0f &#8230; 1.0f].</p></div>
<div class="paragraph"><p>These conversions are performed as follows:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">CL_UNORM_INT8</span> (8-bit unsigned integer) &#8594; <span class="monospaced">float</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_float\_value(x)=round\_to\_float(\frac{x}{255})
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">CL_UNORM_INT_101010</span> (10-bit unsigned integer) &#8594; <span class="monospaced">float</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_float\_value(x)=round\_to\_float(\frac{x}{1023})
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">CL_UNORM_INT16</span> (16-bit unsigned integer) &#8594; <span class="monospaced">float</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_float\_value(x)=round\_to\_float(\frac{x}{65535})
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">CL_SNORM_INT8</span> (8-bit signed integer) &#8594; <span class="monospaced">float</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_float\_value(x)=max(-1.0f, round\_to\_float(\frac{x}{127}))
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">CL_SNORM_INT16</span> (16-bit signed integer) &#8594; <span class="monospaced">float</span>
</p>
<div class="mathblock">
<div class="content">\[
normalized\_float\_value(x)=max(-1.0f, round\_to\_float(\frac{x}{32767}))
\]</div></div>
</li>
</ul></div>
<div class="paragraph"><p>The precision of the above conversions is &lt;= 1.5 ulp except for the following cases.</p></div>
<div class="paragraph"><p>For <span class="monospaced">CL_UNORM_INT8</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
0 must convert to 0.0f and
</p>
</li>
<li>
<p>
255 must convert to 1.0f
</p>
</li>
</ul></div>
<div class="paragraph"><p>For <span class="monospaced">CL_UNORM_INT_101010</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
0 must convert to 0.0f and
</p>
</li>
<li>
<p>
1023 must convert to 1.0f
</p>
</li>
</ul></div>
<div class="paragraph"><p>For <span class="monospaced">CL_UNORM_INT16</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
0 must convert to 0.0f and
</p>
</li>
<li>
<p>
65535 must convert to 1.0f
</p>
</li>
</ul></div>
<div class="paragraph"><p>For <span class="monospaced">CL_SNORM_INT8</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
-128 and -127 must convert to -1.0f,
</p>
</li>
<li>
<p>
0 must convert to 0.0f and
</p>
</li>
<li>
<p>
127 must convert to 1.0f
</p>
</li>
</ul></div>
<div class="paragraph"><p>For <span class="monospaced">CL_SNORM_INT16</span>:</p></div>
<div class="ulist"><ul>
<li>
<p>
-32768 and -32767 must convert to -1.0f,
</p>
</li>
<li>
<p>
0 must convert to 0.0f and
</p>
</li>
<li>
<p>
32767 must convert to 1.0f
</p>
</li>
</ul></div>
</div>
<div class="sect4">
<h5 id="converting-floating-point-values-to-normalized-integer-channel-data-types">Converting floating-point values to normalized integer channel data types</h5>
<div class="paragraph"><p>For images created with image channel data type of <span class="monospaced">CL_UNORM_INT8</span> and <span class="monospaced">CL_UNORM_INT16</span>, <span class="monospaced">image::write</span> will convert the floating-point color value to an 8-bit or 16-bit unsigned integer.</p></div>
<div class="paragraph"><p>For images created with image channel data type of <span class="monospaced">CL_SNORM_INT8</span> and <span class="monospaced">CL_SNORM_INT16</span>, <span class="monospaced">image::write</span> will convert the floating-point color value to an 8-bit or 16-bit signed integer.</p></div>
<div class="paragraph"><p>OpenCL implementations may choose to approximate the rounding mode used in the conversions described below.
When approximate rounding is used instead of the preferred rounding, the result of the conversion must satisfy the bound given below.</p></div>
<div class="paragraph"><p>The conversions from half precision floating-point values to normalized integer values are performed is as follows:</p></div>
<div class="ulist"><ul>
<li>
<p>
<span class="monospaced">float</span> &#8594; <span class="monospaced">CL_UNORM_INT8</span> (8-bit unsigned integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(0,min(255,255 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint8(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint8(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">float</span> &#8594; <span class="monospaced">CL_UNORM_INT_101010</span> (10-bit unsigned integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(0,min(1023,1023 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint10(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint10(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">float</span> &#8594; <span class="monospaced">CL_UNORM_INT16</span> (16-bit unsigned integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(0,min(65535,65535 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint16(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint16(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">float</span> &#8594; <span class="monospaced">CL_SNORM_INT8</span> (8-bit signed integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(-128,min(127,127 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint8(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint8(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
<li>
<p>
<span class="monospaced">float</span> &#8594; <span class="monospaced">CL_SNORM_INT16</span> (16-bit signed integer)
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
f(x)=max(-32768,min(32767,32767 \times x))\\
\\
f_{preferred}(x) =
\begin{cases}
round\_to\_nearest\_even\_uint16(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
f_{approx}(x) =
\begin{cases}
round\_to\_impl\_uint16(f(x)) & \quad x \neq \infty \text{ and } x \neq NaN\\
\text{implementation-defined} & \quad x = \infty \text{ or } x = NaN
\end{cases}\\
\\
|f(x) - f_{approx}(x)|\leq 0.6, x \neq \infty \text{ and } x \neq NaN
\end{array}
\]</div></div>
</li>
</ul></div>
</div>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-half-precision-floating-point-channel-data-type">5.3.2. Conversion rules for half precision floating-point channel data type</h4>
<div class="paragraph"><p>For images created with a channel data type of <span class="monospaced">CL_HALF_FLOAT</span>, the conversions of half to float and half to half are lossless (as described in <em><a href="#builtin-half-data-type">Built-in Half Data Type</a> section</em>).
Conversions from float to half round the mantissa using the round to nearest even or round to zero rounding mode.
Denormalized numbers for the half data type which may be generated when converting a float to a half may be flushed to zero.
A float NaN must be converted to an appropriate NaN in the half type.
A float INF must be converted to an appropriate INF in the half type.</p></div>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-floating-point-channel-data-type">5.3.3. Conversion rules for floating-point channel data type</h4>
<div class="paragraph"><p>The following rules apply for reading and writing images created with channel data type of <span class="monospaced">CL_FLOAT</span>.</p></div>
<div class="ulist"><ul>
<li>
<p>
NaNs may be converted to a NaN value(s) supported by the device.
</p>
</li>
<li>
<p>
Denorms can be flushed to zero.
</p>
</li>
<li>
<p>
All other values must be preserved.
</p>
</li>
</ul></div>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-signed-and-unsigned-8-bit-16-bit-and-32-bit-integer-channel-data-types">5.3.4. Conversion rules for signed and unsigned 8-bit, 16-bit and 32-bit integer channel data types</h4>
<div class="paragraph"><p>Calls to <span class="monospaced">image::read</span> with channel data type values of <span class="monospaced">CL_SIGNED_INT8</span>, <span class="monospaced">CL_SIGNED_INT16</span> and <span class="monospaced">CL_SIGNED_INT32</span> return the unmodified integer values stored in the image at specified location.</p></div>
<div class="paragraph"><p>Calls to <span class="monospaced">image::read</span> with channel data type values of <span class="monospaced">CL_UNSIGNED_INT8</span>, <span class="monospaced">CL_UNSIGNED_INT16</span> and <span class="monospaced">CL_UNSIGNED_INT32</span> return the unmodified integer values stored in the image at specified location.</p></div>
<div class="paragraph"><p>Calls to <span class="monospaced">image::write</span> will perform one of the following conversions:</p></div>
<div class="paragraph"><p>32 bit signed integer &#8594; 8-bit signed integer</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>convert_cast<span style="color: #990000">&lt;</span><span style="color: #009900">char</span><span style="color: #990000">,</span>saturate<span style="color: #990000">::</span>on<span style="color: #990000">&gt;(</span>i<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>32 bit signed integer &#8594; 16-bit signed integer</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>convert_cast<span style="color: #990000">&lt;</span><span style="color: #009900">short</span><span style="color: #990000">,</span>saturate<span style="color: #990000">::</span>on<span style="color: #990000">&gt;(</span>i<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>32 bit signed integer &#8594; 32-bit signed integer</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>no conversion is performed</pre>
</div></div>
<div class="paragraph"><p>Calls to image::write will perform one of the following conversions:</p></div>
<div class="paragraph"><p>32 bit unsigned integer &#8594; 8-bit unsigned integer</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>convert_cast<span style="color: #990000">&lt;</span>uchar<span style="color: #990000">,</span>saturate<span style="color: #990000">::</span>on<span style="color: #990000">&gt;(</span>i<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>32 bit unsigned integer &#8594; 16-bit unsigned integer</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>convert_cast<span style="color: #990000">&lt;</span>ushort<span style="color: #990000">,</span>saturate<span style="color: #990000">::</span>on<span style="color: #990000">&gt;(</span>i<span style="color: #990000">)</span></tt></pre></div></div>
<div class="paragraph"><p>32 bit unsigned integer &#8594; 32-bit unsigned integer</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>no conversion is performed</pre>
</div></div>
<div class="paragraph"><p>The conversions described in this section must be correctly saturated.</p></div>
</div>
<div class="sect3">
<h4 id="conversion-rules-for-srgba-and-sbgra-images">5.3.5. Conversion rules for sRGBA and sBGRA images</h4>
<div class="paragraph"><p>Standard RGB data, which roughly displays colors in a linear ramp of luminosity levels such that an average observer, under average viewing conditions, can view them as perceptually equal steps on an average display.
All 0&#8217;s maps to 0.0f, and all 1&#8217;s maps to 1.0f.
The sequence of unsigned integer encodings between all 0&#8217;s and all 1&#8217;s represent a nonlinear progression in the floating-point interpretation of the numbers between 0.0f to 1.0f.
For more detail, see the SRGB color standard, IEC 61996-2-1, at IEC (International Electrotechnical Commission).</p></div>
<div class="paragraph"><p>Conversion from sRGB space is automatically done by image::read built-in functions if the image channel order is one of the sRGB values described above.
When reading from an sRGB image, the conversion from sRGB to linear RGB is performed before the filter specified in the sampler specified to image::sample is applied.
If the format has an alpha channel, the alpha data is stored in linear color space.
Conversion to sRGB space is automatically done by image::write built-in functions if the image channel order is one of the sRGB values described above and the device supports writing to sRGB images.</p></div>
<div class="paragraph"><p>If the format has an alpha channel, the alpha data is stored in linear color space.</p></div>
<div class="olist arabic"><ol class="arabic">
<li>
<p>
The following process is used by image::read and image::sample to convert a normalized 8-bit unsigned integer sRGB color value x to a floating-point linear RGB color value y:
</p>
<div class="olist loweralpha"><ol class="loweralpha">
<li>
<p>
Convert a normalized 8-bit unsigned integer sRGB value x to a floating-point sRGB value r as per rules described in <em><a href="#converting-floating-point-values-to-normalized-integer-channel-data-types">Converting floating-point values to normalized integer channel data types</a> section</em>.
</p>
<div class="mathblock">
<div class="content">\[
r=normalized\_float\_value(x)
\]</div></div>
</li>
<li>
<p>
Convert a floating-point sRGB value r to a floating-point linear RGB color value y:
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
c_{linear}(x) =
\begin{cases}
\frac{r}{12.92} & \quad r \geq 0 \text{ and } r \leq 0.04045\\
(\frac{r + 0.055}{1.055})^{2.4} & \quad r > 0.04045 \text{ and } \leq 1
\end{cases}\\
\\
y = c_{linear}(r)
\end{array}
\]</div></div>
</li>
</ol></div>
</li>
<li>
<p>
The following process is used by <span class="monospaced">image::write</span> to convert a linear RGB floating-point color value y to a normalized 8-bit unsigned integer sRGB value x:
</p>
<div class="olist loweralpha"><ol class="loweralpha">
<li>
<p>
Convert a floating-point linear RGB value y to a normalized floating point sRGB value r:
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
c_{linear}(x) =
\begin{cases}
0 & \quad y \geq NaN \text{ or } y < 0\\
12.92 \times y & \quad y \geq 0 \text{ and } y < 0.0031308\\
1.055 \times y^{(\frac{1}{2.4})} & \quad y \geq 0.0031308 \text{ and } y \leq 1\\
1 & \quad y > 1
\end{cases}\\
\\
r = c_{sRGB}(y)
\end{array}
\]</div></div>
</li>
<li>
<p>
Convert a normalized floating-point sRGB value r to a normalized 8-bit unsigned integer sRGB value x as per rules described in <a href="#converting-normalized-integer-channel-data-types-to-half-precision-floating-point-values">Converting normalized integer channel data types to half precision floating-point values</a> section.
</p>
<div class="mathblock">
<div class="content">\[
\begin{array}{l}
g(r) =
\begin{cases}
f_{preferred}(r) & \quad \text{if rounding mode is round to even}\\
f_{approx}(r) & \quad \text{if implementation-defined rounding mode}
\end{cases}\\
\\
x = g(r)
\end{array}
\]</div></div>
</li>
</ol></div>
</li>
</ol></div>
<div class="paragraph"><p>The accuracy required of using <span class="monospaced">image::read</span> and <span class="monospaced">image::sample</span> to convert a normalized 8-bit unsigned integer sRGB color value x to a floating-point linear RGB color value y is given by:</p></div>
<div class="mathblock">
<div class="content">\[
|x-255 \times c_{sRGB}(y)|\leq 0.5
\]</div></div>
<div class="paragraph"><p>The accuracy required of using <span class="monospaced">image::write</span> to convert a linear RGB floating-point color value y to a normalized 8-bit unsigned integer sRGB value x is given by:</p></div>
<div class="mathblock">
<div class="content">\[
|x-255 \times c_{sRGB}(y)|\leq 0.6
\]</div></div>
</div>
</div>
<div class="sect2">
<h3 id="selecting-an-image-from-an-image-array">5.4. Selecting an Image from an Image Array</h3>
<div class="paragraph"><p>Let (u,v,w) represent the unnormalized image coordinate values for reading from and/or writing to a 2D image in a 2D image array.</p></div>
<div class="paragraph"><p>When read using a sampler, the 2D image layer selected is computed as:</p></div>
<div class="mathblock">
<div class="content">\[
layer = clamp(rint(w), 0, d_t - 1)
\]</div></div>
<div class="paragraph"><p>otherwise the layer selected is computed as:</p></div>
<div class="mathblock">
<div class="content">\[
layer = w
\]</div></div>
<div class="paragraph"><p>(since w is already an integer) and the result is undefined if w is not one of the integers 0, 1, &#8230; d<sub>t</sub> - 1.</p></div>
<div class="paragraph"><p>Let (u,v) represent the unnormalized image coordinate values for reading from and/or writing to a 1D image in a 1D image array.</p></div>
<div class="paragraph"><p>When read using a sampler, the 1D image layer selected is computed as:</p></div>
<div class="mathblock">
<div class="content">\[
layer = clamp(rint(v), 0, h_t - 1)
\]</div></div>
<div class="paragraph"><p>otherwise the layer selected is computed as:</p></div>
<div class="mathblock">
<div class="content">\[
layer = v
\]</div></div>
<div class="paragraph"><p>(since v is already an integer) and the result is undefined if v is not one of the integers 0, 1, &#8230; h<sub>t</sub> - 1.</p></div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="compiler_options">6. Compiler options</h2>
<div class="sectionbody">
<div class="paragraph"><p>The compiler options are categorized as preprocessor options, options for controlling the OpenCL C++ version, options that control FP16 and FP64 support.
This specification defines a standard set of options that must be supported by the compiler when building program executables online or offline from OpenCL C++ to an IL.
These may be extended by a set of vendor or platform specific options.</p></div>
<div class="sect2">
<h3 id="preprocessor_options">6.1. Preprocessor options</h3>
<div class="paragraph"><p>These options control the OpenCL C++ preprocessor which is run on each program source before actual compilation.</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>-D name</pre>
</div></div>
<div class="paragraph"><p>Predefine name as a macro, with definition 1.</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>-D name=definition</pre>
</div></div>
<div class="paragraph"><p>The contents of definition are tokenized and processed as if they appeared during translation phase three in a <span class="monospaced">#define</span> directive.
In particular, the definition will be truncated by embedded newline characters.</p></div>
</div>
<div class="sect2">
<h3 id="options-controlling_the-opencl_c_version">6.2. Options Controlling the OpenCL C++ version</h3>
<div class="paragraph"><p>The following option controls the version of OpenCL C++ that the compiler accepts.</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>-cl-std=</pre>
</div></div>
<div class="paragraph"><p>Determine the OpenCL C++ language version to use.
A value for this option must be provided.
Valid values are:</p></div>
<div class="ulist"><ul>
<li>
<p>
c++ - Support all OpenCL C++ programs that use the OpenCL C++ language features defined in <em><a href="#openclcpp-programming-language">OpenCL C++ Programming Language</a> section</em>.
</p>
</li>
</ul></div>
</div>
<div class="sect2">
<h3 id="fp16_and_fp64_options">6.3. Double and half-precision floating-point options</h3>
<div class="paragraph"><p>The following option controls the double and half floating-point support that the compiler accepts.</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>-cl-fp16-enable</pre>
</div></div>
<div class="paragraph"><p>This option enables full half data type support.
The option defines <span class="monospaced">cl_khr_fp16</span> macro.
The default is disabled.</p></div>
<div class="listingblock">
<div class="content monospaced">
<pre>-cl-fp64-enable</pre>
</div></div>
<div class="paragraph"><p>This option enables double data type support.
The option defines <span class="monospaced">cl_khr_fp64</span> macro.
The default is disabled.</p></div>
</div>
<div class="sect2">
<h3 id="other_options">6.4. Other options</h3>
<div class="listingblock">
<div class="content monospaced">
<pre>-cl-zero-init-local-mem-vars</pre>
</div></div>
<div class="paragraph"><p>This option enables software zero-initialization of variables allocated in local memory.</p></div>
<hr>
<div class="paragraph" id="ftn2"><p><a href="#_ftnref2">[2</a>] The double data type is an optional type that is supported if <span class="monospaced">CL_DEVICE_DOUBLE_FP_CONFIG</span> in table 4.3 for a device is not zero.</p></div>
<div class="paragraph" id="ftn3"><p><a href="#_ftnref3">[3</a>] The question mark ? in numerical selector refers to special undefined component of vector; reading from it results in undefined value, writing to it is discarded.</p></div>
<div class="paragraph" id="ftn4"><p><a href="#_ftnref4">[4</a>] Only if <em>cl_khr_fp16</em> extension is enabled and has been supported</p></div>
<div class="paragraph" id="ftn5"><p><a href="#_ftnref5">[5</a>] For conversions to floating-point format, when a finite source value exceeds the maximum representable finite floating-point destination value, the rounding mode will affect whether the result is the maximum finite floating-point value or infinity of same sign as the source value, per IEEE-754 rules for rounding.</p></div>
<div class="paragraph" id="ftn6"><p><a href="#_ftnref6">[6</a>] The <span class="monospaced">as_type&lt;T&gt;</span> function is intended to reflect the organization of data in register.
The <span class="monospaced">as_type&lt;T&gt;</span> construct is intended to compile to no instructions on devices that use a shared register file designed to operate on both the operand and result types.
Note that while differences in memory organization are expected to largely be limited to those arising from endianness, the register based representation may also differ due to size of the element in register.
(For example, an architecture may load a char into a 32-bit register, or a char vector into a SIMD vector register with fixed 32-bit element size.)
If the element count does not match, then the implementation should pick a data representation that most closely matches what would happen if an appropriate result type operator was applied to a register containing data of the source type.
So, for example if an implementation stores all single precision data as double in register, it should implement <span class="monospaced">as_type&lt;int&gt;(float)</span> by first downconverting the double to single precision and then (if necessary) moving the single precision bits to a register suitable for operating on integer data.
If data stored in different address spaces do not have the same endianness, then the "dominant endianness" of the device should prevail.</p></div>
<div class="paragraph" id="ftn7"><p><a href="#_ftnref7">[7</a>] <span class="monospaced">memory_order_consume</span> is not supported in OpenCL C++</p></div>
<div class="paragraph" id="ftn8"><p><a href="#_ftnref8">[8</a>] This value for <span class="monospaced">memory_scope</span> can only be used with <span class="monospaced">atomic_fence</span> with flags set to <span class="monospaced">mem_fence::image</span>.</p></div>
<div class="paragraph" id="ftn9"><p><a href="#_ftnref9">[9</a>] We can&#8217;t require C++14 atomics since host programs can be implemented in other programming languages and versions of C or C++, but we do require that the host programs use atomics and that those atomics be compatible with those in C++14.</p></div>
<div class="paragraph" id="ftn10"><p><a href="#_ftnref10">[10</a>] The <span class="monospaced">atomic_long</span> and <span class="monospaced">atomic_ulong</span> types are supported if the <em>cl_khr_int64_base_atomics</em> and <em>cl_khr_int64_extended_atomics</em> extensions are supported and have been enabled.</p></div>
<div class="paragraph" id="ftn11"><p><a href="#_ftnref11">[11</a>] The <span class="monospaced">atomic_double</span> type is only supported if the double precision is supported and the <em>cl_khr_int64_base_atomics</em> and <em>cl_khr_int64_extended_atomics</em> extensions are supported and have been enabled.</p></div>
<div class="paragraph" id="ftn12"><p><a href="#_ftnref12">[12</a>] If the device address space is 64-bits, the data types <span class="monospaced">atomic_intptr_t</span>, <span class="monospaced">atomic_uintptr_t</span>, <span class="monospaced">atomic_size_t</span> and <span class="monospaced">atomic_ptrdiff_t</span> are supported if the <em>cl_khr_int64_base_atomics</em> and <em>cl_khr_int64_extended_atomics</em> extensions are supported and have been enabled.</p></div>
<div class="paragraph" id="ftn13"><p><a href="#_ftnref13">[13</a>] *<em>ms</em> types are supported if the <em>cl_khr_gl_msaa_sharing</em> and <em>cl_khr_gl_depth_images</em> extensions are supported and have been enabled.</p></div>
<div class="paragraph" id="ftn14"><p><a href="#_ftnref14">[14</a>] Immediate meaning not side effects resulting from child kernels. The side effects would include stores to global memory and pipe reads and writes.</p></div>
<div class="paragraph" id="ftn15"><p><a href="#_ftnref15">[15</a>] This acts as a memory synchronization point between work-items in a work-group and child kernels enqueued by work-items in the work-group.</p></div>
<div class="paragraph" id="ftn16"><p><a href="#_ftnref16">[16</a>] i.e. the <span class="monospaced">global_work_size</span> values passed to <span class="monospaced">clEnqueueNDRangeKernel</span> are not evenly divisible by the <span class="monospaced">local_work_size</span> values for each dimension.</p></div>
<div class="paragraph" id="ftn17"><p><a href="#_ftnref17">[17</a>] i.e. the <span class="monospaced">global_work_size</span> values specified to <span class="monospaced">clEnqueueNDRangeKernel</span> are not evenly divisible by the <span class="monospaced">local_work_size</span> values for each dimension.</p></div>
<div class="paragraph" id="ftn18"><p><a href="#_ftnref18">[18</a>] Only if double precision is supported and has been enabled.</p></div>
<div class="paragraph" id="ftn19"><p><a href="#_ftnref19">[19</a>] Refer to <em><a href="#order-and-scope">Memory order and scope</a> section</em> for description of memory_scope.</p></div>
<div class="paragraph" id="ftn20"><p><a href="#_ftnref20">[20</a>] The <span class="monospaced">min()</span> operator is there to prevent <span class="monospaced">fract(-small)</span> from returning 1.0.
It returns the largest positive floating-point number less than 1.0.</p></div>
<div class="paragraph" id="ftn21"><p><a href="#_ftnref21">[21</a>] fmin and fmax behave as defined by C++14 and may not match the IEEE 754-2008 definition for minNum and maxNum with regard to signaling NaNs.
Specifically, signaling NaNs may behave as quiet NaNs.</p></div>
<div class="paragraph" id="ftn22"><p><a href="#_ftnref22">[22</a>] The user is cautioned that for some usages, e.g. <span class="monospaced">mad(a, b, -a*b)</span>, the definition of <span class="monospaced">mad()</span> is loose enough that almost any result is allowed from <span class="monospaced">mad()</span> for some values of <span class="monospaced">a</span> and <span class="monospaced">b</span>.</p></div>
<div class="paragraph" id="ftn23"><p><a href="#_ftnref23">[23</a>] Frequently vector operations need n + 1 bits temporarily to calculate a result.
The rhadd instruction gives you an extra bit without needing to upsample and downsample. This can be a profound performance win.</p></div>
<div class="paragraph" id="ftn24"><p><a href="#_ftnref24">[24</a>] The primary purpose of the printf function is to help in debugging OpenCL kernels.</p></div>
<div class="paragraph" id="ftn25"><p><a href="#_ftnref25">[25</a>] Note that <em>0</em> is taken as a flag, not as the beginning of a field width.</p></div>
<div class="paragraph" id="ftn26"><p><a href="#_ftnref26">[26</a>] The results of all floating conversions of a negative zero, and of negative values that round to zero, include a minus sign.</p></div>
<div class="paragraph" id="ftn27"><p><a href="#_ftnref27">[27</a>] When applied to infinite and NaN values, the -, +, and space flag characters have their usual meaning; the # and <em>0</em> flag characters have no effect.</p></div>
<div class="paragraph" id="ftn28"><p><a href="#_ftnref28">[28</a>] Binary implementations can choose the hexadecimal digit to the left of the decimal-point character so that subsequent digits align to nibble (4-bit) boundaries.</p></div>
<div class="paragraph" id="ftn29"><p><a href="#_ftnref29">[29</a>] No special provisions are made for multibyte characters.
The behavior of printf with the <em>s</em> conversion specifier is undefined if the argument value is not a pointer to a literal string.</p></div>
<div class="paragraph" id="ftn30"><p><a href="#_ftnref30">[30</a>] Except for the embedded profile whether either round to zero or round to nearest rounding mode may be supported for single precision floating-point.</p></div>
<div class="paragraph" id="ftn31"><p><a href="#_ftnref31">[31</a>] The ULP values for built-in math functions <span class="monospaced">lgamma</span> and <span class="monospaced">lgamma_r</span> is currently undefined.</p></div>
<div class="paragraph" id="ftn32"><p><a href="#_ftnref32">[32</a>] 0 ulp is used for math functions that do not require rounding.</p></div>
<div class="paragraph" id="ftn33"><p><a href="#_ftnref33">[33</a>] On some implementations, <span class="monospaced">powr()</span> or <span class="monospaced">pown()</span> may perform faster than <span class="monospaced">pow()</span>.
If <span class="monospaced">x</span> is known to be <span class="monospaced">&gt;= 0</span>, consider using <span class="monospaced">powr()</span> in place of <span class="monospaced">pow()</span>, or if <span class="monospaced">y</span> is known to be an integer, consider using <span class="monospaced">pown()</span> in place of <span class="monospaced">pow()</span>.</p></div>
<div class="paragraph" id="ftn34"><p><a href="#_ftnref34">[34</a>] 0 ulp is used for math functions that do not require rounding.</p></div>
<div class="paragraph" id="ftn35"><p><a href="#_ftnref35">[35</a>] Here <span class="monospaced">TYPE_MIN</span> and <span class="monospaced">TYPE_MIN_EXP</span> should be substituted by constants appropriate to the floating-point type under consideration, such as <span class="monospaced">FLT_MIN</span> and <span class="monospaced">FLT_MIN_EXP</span> for float.</p></div>
</div>
</div>
</div>
</div>
<div id="footnotes"><hr></div>
<div id="footer">
<div id="footer-text">
Last updated
2017-05-12 11:00:12 PDT
</div>
</div>
</body>
</html>