• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<html lang="en">
3<head>
4<meta charset="UTF-8">
5<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
6<meta name="viewport" content="width=device-width, initial-scale=1.0">
7<meta name="generator" content="Asciidoctor 1.5.8">
8<meta name="author" content="Peter Dimov">
9<title>Boost.Mp11: A C++11 metaprogramming library</title>
10<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
11<style>
12/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
13/* Uncomment @import statement below to use as custom stylesheet */
14/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/
15article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
16audio,canvas,video{display:inline-block}
17audio:not([controls]){display:none;height:0}
18script{display:none!important}
19html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
20a{background:transparent}
21a:focus{outline:thin dotted}
22a:active,a:hover{outline:0}
23h1{font-size:2em;margin:.67em 0}
24abbr[title]{border-bottom:1px dotted}
25b,strong{font-weight:bold}
26dfn{font-style:italic}
27hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
28mark{background:#ff0;color:#000}
29code,kbd,pre,samp{font-family:monospace;font-size:1em}
30pre{white-space:pre-wrap}
31q{quotes:"\201C" "\201D" "\2018" "\2019"}
32small{font-size:80%}
33sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
34sup{top:-.5em}
35sub{bottom:-.25em}
36img{border:0}
37svg:not(:root){overflow:hidden}
38figure{margin:0}
39fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
40legend{border:0;padding:0}
41button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
42button,input{line-height:normal}
43button,select{text-transform:none}
44button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
45button[disabled],html input[disabled]{cursor:default}
46input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
47button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
48textarea{overflow:auto;vertical-align:top}
49table{border-collapse:collapse;border-spacing:0}
50*,*::before,*::after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
51html,body{font-size:100%}
52body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
53a:hover{cursor:pointer}
54img,object,embed{max-width:100%;height:auto}
55object,embed{height:100%}
56img{-ms-interpolation-mode:bicubic}
57.left{float:left!important}
58.right{float:right!important}
59.text-left{text-align:left!important}
60.text-right{text-align:right!important}
61.text-center{text-align:center!important}
62.text-justify{text-align:justify!important}
63.hide{display:none}
64img,object,svg{display:inline-block;vertical-align:middle}
65textarea{height:auto;min-height:50px}
66select{width:100%}
67.center{margin-left:auto;margin-right:auto}
68.stretch{width:100%}
69.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
70div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
71a{color:#2156a5;text-decoration:underline;line-height:inherit}
72a:hover,a:focus{color:#1d4b8f}
73a img{border:none}
74p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
75p aside{font-size:.875em;line-height:1.35;font-style:italic}
76h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
77h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
78h1{font-size:2.125em}
79h2{font-size:1.6875em}
80h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
81h4,h5{font-size:1.125em}
82h6{font-size:1em}
83hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
84em,i{font-style:italic;line-height:inherit}
85strong,b{font-weight:bold;line-height:inherit}
86small{font-size:60%;line-height:inherit}
87code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
88ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
89ul,ol{margin-left:1.5em}
90ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
91ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
92ul.square{list-style-type:square}
93ul.circle{list-style-type:circle}
94ul.disc{list-style-type:disc}
95ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
96dl dt{margin-bottom:.3125em;font-weight:bold}
97dl dd{margin-bottom:1.25em}
98abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
99abbr{text-transform:none}
100blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
101blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
102blockquote cite::before{content:"\2014 \0020"}
103blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
104blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
105@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
106h1{font-size:2.75em}
107h2{font-size:2.3125em}
108h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
109h4{font-size:1.4375em}}
110table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
111table thead,table tfoot{background:#f7f8f7}
112table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
113table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
114table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
115table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
116h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
117h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
118.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
119.clearfix::after,.float-group::after{clear:both}
120*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word}
121*:not(pre)>code.nobreak{word-wrap:normal}
122*:not(pre)>code.nowrap{white-space:nowrap}
123pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
124em em{font-style:normal}
125strong strong{font-weight:400}
126.keyseq{color:rgba(51,51,51,.8)}
127kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
128.keyseq kbd:first-child{margin-left:0}
129.keyseq kbd:last-child{margin-right:0}
130.menuseq,.menuref{color:#000}
131.menuseq b:not(.caret),.menuref{font-weight:inherit}
132.menuseq{word-spacing:-.02em}
133.menuseq b.caret{font-size:1.25em;line-height:.8}
134.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
135b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
136b.button::before{content:"[";padding:0 3px 0 2px}
137b.button::after{content:"]";padding:0 2px 0 3px}
138p a>code:hover{color:rgba(0,0,0,.9)}
139#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
140#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
141#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
142#content{margin-top:1.25em}
143#content::before{content:none}
144#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
145#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
146#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
147#header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
148#header .details span:first-child{margin-left:-.125em}
149#header .details span.email a{color:rgba(0,0,0,.85)}
150#header .details br{display:none}
151#header .details br+span::before{content:"\00a0\2013\00a0"}
152#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
153#header .details br+span#revremark::before{content:"\00a0|\00a0"}
154#header #revnumber{text-transform:capitalize}
155#header #revnumber::after{content:"\00a0"}
156#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
157#toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
158#toc>ul{margin-left:.125em}
159#toc ul.sectlevel0>li>a{font-style:italic}
160#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
161#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
162#toc li{line-height:1.3334;margin-top:.3334em}
163#toc a{text-decoration:none}
164#toc a:active{text-decoration:underline}
165#toctitle{color:#7a2518;font-size:1.2em}
166@media screen and (min-width:768px){#toctitle{font-size:1.375em}
167body.toc2{padding-left:15em;padding-right:0}
168#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
169#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
170#toc.toc2>ul{font-size:.9em;margin-bottom:0}
171#toc.toc2 ul ul{margin-left:0;padding-left:1em}
172#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
173body.toc2.toc-right{padding-left:0;padding-right:15em}
174body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
175@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
176#toc.toc2{width:20em}
177#toc.toc2 #toctitle{font-size:1.375em}
178#toc.toc2>ul{font-size:.95em}
179#toc.toc2 ul ul{padding-left:1.25em}
180body.toc2.toc-right{padding-left:0;padding-right:20em}}
181#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
182#content #toc>:first-child{margin-top:0}
183#content #toc>:last-child{margin-bottom:0}
184#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
185#footer-text{color:rgba(255,255,255,.8);line-height:1.44}
186#content{margin-bottom:.625em}
187.sect1{padding-bottom:.625em}
188@media screen and (min-width:768px){#content{margin-bottom:1.25em}
189.sect1{padding-bottom:1.25em}}
190.sect1:last-child{padding-bottom:0}
191.sect1+.sect1{border-top:1px solid #e7e7e9}
192#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
193#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
194#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
195#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
196#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
197.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
198.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
199table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
200.paragraph.lead>p,#preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
201table.tableblock #preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:inherit}
202.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
203.admonitionblock>table td.icon{text-align:center;width:80px}
204.admonitionblock>table td.icon img{max-width:none}
205.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
206.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6)}
207.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
208.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
209.exampleblock>.content>:first-child{margin-top:0}
210.exampleblock>.content>:last-child{margin-bottom:0}
211.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
212.sidebarblock>:first-child{margin-top:0}
213.sidebarblock>:last-child{margin-bottom:0}
214.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
215.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
216.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
217.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
218.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;overflow-x:auto;padding:1em;font-size:.8125em}
219@media screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}
220@media screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}
221.literalblock pre.nowrap,.literalblock pre.nowrap pre,.listingblock pre.nowrap,.listingblock pre.nowrap pre{white-space:pre;word-wrap:normal}
222.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
223.listingblock pre.highlightjs{padding:0}
224.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
225.listingblock pre.prettyprint{border-width:0}
226.listingblock>.content{position:relative}
227.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
228.listingblock:hover code[data-lang]::before{display:block}
229.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:#999}
230.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
231table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
232table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45}
233table.pyhltable td.code{padding-left:.75em;padding-right:0}
234pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #dddddf}
235pre.pygments .lineno{display:inline-block;margin-right:.25em}
236table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
237.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
238.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
239.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
240.quoteblock blockquote{margin:0;padding:0;border:0}
241.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
242.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
243.quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
244.verseblock{margin:0 1em 1.25em}
245.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
246.verseblock pre strong{font-weight:400}
247.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
248.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
249.quoteblock .attribution br,.verseblock .attribution br{display:none}
250.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
251.quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
252.quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
253.quoteblock.abstract{margin:0 1em 1.25em;display:block}
254.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
255.quoteblock.excerpt,.quoteblock .quoteblock{margin:0 0 1.25em;padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
256.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
257.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;text-align:left;margin-right:0}
258table.tableblock{max-width:100%;border-collapse:separate}
259p.tableblock:last-child{margin-bottom:0}
260td.tableblock>.content{margin-bottom:-1.25em}
261table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
262table.grid-all>thead>tr>.tableblock,table.grid-all>tbody>tr>.tableblock{border-width:0 1px 1px 0}
263table.grid-all>tfoot>tr>.tableblock{border-width:1px 1px 0 0}
264table.grid-cols>*>tr>.tableblock{border-width:0 1px 0 0}
265table.grid-rows>thead>tr>.tableblock,table.grid-rows>tbody>tr>.tableblock{border-width:0 0 1px}
266table.grid-rows>tfoot>tr>.tableblock{border-width:1px 0 0}
267table.grid-all>*>tr>.tableblock:last-child,table.grid-cols>*>tr>.tableblock:last-child{border-right-width:0}
268table.grid-all>tbody>tr:last-child>.tableblock,table.grid-all>thead:last-child>tr>.tableblock,table.grid-rows>tbody>tr:last-child>.tableblock,table.grid-rows>thead:last-child>tr>.tableblock{border-bottom-width:0}
269table.frame-all{border-width:1px}
270table.frame-sides{border-width:0 1px}
271table.frame-topbot,table.frame-ends{border-width:1px 0}
272table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd){background:#f8f8f7}
273table.stripes-none tr,table.stripes-odd tr:nth-of-type(even){background:none}
274th.halign-left,td.halign-left{text-align:left}
275th.halign-right,td.halign-right{text-align:right}
276th.halign-center,td.halign-center{text-align:center}
277th.valign-top,td.valign-top{vertical-align:top}
278th.valign-bottom,td.valign-bottom{vertical-align:bottom}
279th.valign-middle,td.valign-middle{vertical-align:middle}
280table thead th,table tfoot th{font-weight:bold}
281tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
282tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
283p.tableblock>code:only-child{background:none;padding:0}
284p.tableblock{font-size:1em}
285td>div.verse{white-space:pre}
286ol{margin-left:1.75em}
287ul li ol{margin-left:1.5em}
288dl dd{margin-left:1.125em}
289dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
290ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
291ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
292ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
293ul.unstyled,ol.unstyled{margin-left:0}
294ul.checklist{margin-left:.625em}
295ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
296ul.checklist li>p:first-child>input[type="checkbox"]:first-child{margin-right:.25em}
297ul.inline{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
298ul.inline>li{margin-left:1.25em}
299.unstyled dl dt{font-weight:400;font-style:normal}
300ol.arabic{list-style-type:decimal}
301ol.decimal{list-style-type:decimal-leading-zero}
302ol.loweralpha{list-style-type:lower-alpha}
303ol.upperalpha{list-style-type:upper-alpha}
304ol.lowerroman{list-style-type:lower-roman}
305ol.upperroman{list-style-type:upper-roman}
306ol.lowergreek{list-style-type:lower-greek}
307.hdlist>table,.colist>table{border:0;background:none}
308.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
309td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
310td.hdlist1{font-weight:bold;padding-bottom:1.25em}
311.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
312.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
313.colist td:not([class]):first-child img{max-width:none}
314.colist td:not([class]):last-child{padding:.25em 0}
315.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
316.imageblock.left{margin:.25em .625em 1.25em 0}
317.imageblock.right{margin:.25em 0 1.25em .625em}
318.imageblock>.title{margin-bottom:0}
319.imageblock.thumb,.imageblock.th{border-width:6px}
320.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
321.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
322.image.left{margin-right:.625em}
323.image.right{margin-left:.625em}
324a.image{text-decoration:none;display:inline-block}
325a.image object{pointer-events:none}
326sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
327sup.footnote a,sup.footnoteref a{text-decoration:none}
328sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
329#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
330#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
331#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
332#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
333#footnotes .footnote:last-of-type{margin-bottom:0}
334#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
335.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
336.gist .file-data>table td.line-data{width:99%}
337div.unbreakable{page-break-inside:avoid}
338.big{font-size:larger}
339.small{font-size:smaller}
340.underline{text-decoration:underline}
341.overline{text-decoration:overline}
342.line-through{text-decoration:line-through}
343.aqua{color:#00bfbf}
344.aqua-background{background-color:#00fafa}
345.black{color:#000}
346.black-background{background-color:#000}
347.blue{color:#0000bf}
348.blue-background{background-color:#0000fa}
349.fuchsia{color:#bf00bf}
350.fuchsia-background{background-color:#fa00fa}
351.gray{color:#606060}
352.gray-background{background-color:#7d7d7d}
353.green{color:#006000}
354.green-background{background-color:#007d00}
355.lime{color:#00bf00}
356.lime-background{background-color:#00fa00}
357.maroon{color:#600000}
358.maroon-background{background-color:#7d0000}
359.navy{color:#000060}
360.navy-background{background-color:#00007d}
361.olive{color:#606000}
362.olive-background{background-color:#7d7d00}
363.purple{color:#600060}
364.purple-background{background-color:#7d007d}
365.red{color:#bf0000}
366.red-background{background-color:#fa0000}
367.silver{color:#909090}
368.silver-background{background-color:#bcbcbc}
369.teal{color:#006060}
370.teal-background{background-color:#007d7d}
371.white{color:#bfbfbf}
372.white-background{background-color:#fafafa}
373.yellow{color:#bfbf00}
374.yellow-background{background-color:#fafa00}
375span.icon>.fa{cursor:default}
376a span.icon>.fa{cursor:inherit}
377.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
378.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
379.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
380.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
381.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
382.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
383.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
384.conum[data-value] *{color:#fff!important}
385.conum[data-value]+b{display:none}
386.conum[data-value]::after{content:attr(data-value)}
387pre .conum[data-value]{position:relative;top:-.125em}
388b.conum *{color:inherit!important}
389.conum:not([data-value]):empty{display:none}
390dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
391h1,h2,p,td.content,span.alt{letter-spacing:-.01em}
392p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
393p,blockquote,dt,td.content,span.alt{font-size:1.0625rem}
394p{margin-bottom:1.25rem}
395.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
396.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
397.print-only{display:none!important}
398@page{margin:1.25cm .75cm}
399@media print{*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
400html{font-size:80%}
401a{color:inherit!important;text-decoration:underline!important}
402a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
403a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
404abbr[title]::after{content:" (" attr(title) ")"}
405pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
406thead{display:table-header-group}
407svg{max-width:100%}
408p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
409h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
410#toc,.sidebarblock,.exampleblock>.content{background:none!important}
411#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
412body.book #header{text-align:center}
413body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
414body.book #header .details{border:0!important;display:block;padding:0!important}
415body.book #header .details span:first-child{margin-left:0!important}
416body.book #header .details br{display:block}
417body.book #header .details br+span::before{content:none!important}
418body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
419body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
420.listingblock code[data-lang]::before{display:block}
421#footer{padding:0 .9375em}
422.hide-on-print{display:none!important}
423.print-only{display:block!important}
424.hide-for-print{display:none!important}
425.show-for-print{display:inherit!important}}
426@media print,amzn-kf8{#header>h1:first-child{margin-top:1.25rem}
427.sect1{padding:0!important}
428.sect1+.sect1{border:0}
429#footer{background:none}
430#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
431@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
432</style>
433</head>
434<body class="article toc2 toc-left">
435<div id="header">
436<h1>Boost.Mp11: A C++11 metaprogramming library</h1>
437<div class="details">
438<span id="author" class="author">Peter Dimov</span><br>
439</div>
440<div id="toc" class="toc2">
441<div id="toctitle">Table of Contents</div>
442<ul class="sectlevel1">
443<li><a href="#overview">Overview</a></li>
444<li><a href="#definitions">Definitions</a></li>
445<li><a href="#examples">Examples</a>
446<ul class="sectlevel2">
447<li><a href="#generating_test_cases">Generating Test Cases</a></li>
448<li><a href="#writing_common_type_specializations">Writing common_type Specializations</a></li>
449<li><a href="#fixing_tuple_cat">Fixing tuple_cat</a></li>
450<li><a href="#computing_return_types">Computing Return Types</a></li>
451</ul>
452</li>
453<li><a href="#changelog">Revision History</a>
454<ul class="sectlevel2">
455<li><a href="#changes_in_1_74_0">Changes in 1.74.0</a></li>
456<li><a href="#changes_in_1_73_0">Changes in 1.73.0</a></li>
457<li><a href="#changes_in_1_70_0">Changes in 1.70.0</a></li>
458<li><a href="#changes_in_1_69_0">Changes in 1.69.0</a></li>
459</ul>
460</li>
461<li><a href="#reference">Reference</a>
462<ul class="sectlevel2">
463<li><a href="#integral">Integral Constants, &lt;boost/mp11/integral.hpp&gt;</a>
464<ul class="sectlevel3">
465<li><a href="#mp_boolb">mp_bool&lt;B&gt;</a></li>
466<li><a href="#mp_true">mp_true</a></li>
467<li><a href="#mp_false">mp_false</a></li>
468<li><a href="#mp_to_boolt">mp_to_bool&lt;T&gt;</a></li>
469<li><a href="#mp_nott">mp_not&lt;T&gt;</a></li>
470<li><a href="#mp_inti">mp_int&lt;I&gt;</a></li>
471<li><a href="#mp_size_tn">mp_size_t&lt;N&gt;</a></li>
472</ul>
473</li>
474<li><a href="#list">List Operations, &lt;boost/mp11/list.hpp&gt;</a>
475<ul class="sectlevel3">
476<li><a href="#mp_listt">mp_list&lt;T&#8230;&#8203;&gt;</a></li>
477<li><a href="#mp_list_ct_i">mp_list_c&lt;T, I&#8230;&#8203;&gt;</a></li>
478<li><a href="#mp_is_listl">mp_is_list&lt;L&gt;</a></li>
479<li><a href="#mp_sizel">mp_size&lt;L&gt;</a></li>
480<li><a href="#mp_emptyl">mp_empty&lt;L&gt;</a></li>
481<li><a href="#mp_assignl1_l2">mp_assign&lt;L1, L2&gt;</a></li>
482<li><a href="#mp_clearl">mp_clear&lt;L&gt;</a></li>
483<li><a href="#mp_frontl">mp_front&lt;L&gt;</a></li>
484<li><a href="#mp_pop_frontl">mp_pop_front&lt;L&gt;</a></li>
485<li><a href="#mp_firstl">mp_first&lt;L&gt;</a></li>
486<li><a href="#mp_restl">mp_rest&lt;L&gt;</a></li>
487<li><a href="#mp_secondl">mp_second&lt;L&gt;</a></li>
488<li><a href="#mp_thirdl">mp_third&lt;L&gt;</a></li>
489<li><a href="#mp_push_frontl_t">mp_push_front&lt;L, T&#8230;&#8203;&gt;</a></li>
490<li><a href="#mp_push_backl_t">mp_push_back&lt;L, T&#8230;&#8203;&gt;</a></li>
491<li><a href="#mp_renamel_y">mp_rename&lt;L, Y&gt;</a></li>
492<li><a href="#mp_applyf_l">mp_apply&lt;F, L&gt;</a></li>
493<li><a href="#mp_apply_qq_l">mp_apply_q&lt;Q, L&gt;</a></li>
494<li><a href="#mp_appendl">mp_append&lt;L&#8230;&#8203;&gt;</a></li>
495<li><a href="#mp_replace_frontl_t">mp_replace_front&lt;L, T&gt;</a></li>
496<li><a href="#mp_replace_firstl_t">mp_replace_first&lt;L, T&gt;</a></li>
497<li><a href="#mp_replace_secondl_t">mp_replace_second&lt;L, T&gt;</a></li>
498<li><a href="#mp_replace_thirdl_t">mp_replace_third&lt;L, T&gt;</a></li>
499<li><a href="#mp_transform_frontl_f">mp_transform_front&lt;L, F&gt;</a></li>
500<li><a href="#mp_transform_front_ql_q">mp_transform_front_q&lt;L, Q&gt;</a></li>
501<li><a href="#mp_transform_firstl_f">mp_transform_first&lt;L, F&gt;</a></li>
502<li><a href="#mp_transform_first_ql_q">mp_transform_first_q&lt;L, Q&gt;</a></li>
503<li><a href="#mp_transform_secondl_f">mp_transform_second&lt;L, F&gt;</a></li>
504<li><a href="#mp_transform_second_ql_q">mp_transform_second_q&lt;L, Q&gt;</a></li>
505<li><a href="#mp_transform_thirdl_f">mp_transform_third&lt;L, F&gt;</a></li>
506<li><a href="#mp_transform_third_ql_q">mp_transform_third_q&lt;L, Q&gt;</a></li>
507</ul>
508</li>
509<li><a href="#utility">Utility Components, &lt;boost/mp11/utility.hpp&gt;</a>
510<ul class="sectlevel3">
511<li><a href="#mp_identityt">mp_identity&lt;T&gt;</a></li>
512<li><a href="#mp_identity_tt">mp_identity_t&lt;T&gt;</a></li>
513<li><a href="#mp_inheritt">mp_inherit&lt;T&#8230;&#8203;&gt;</a></li>
514<li><a href="#mp_if_cc_t_e">mp_if_c&lt;C, T, E&#8230;&#8203;&gt;</a></li>
515<li><a href="#mp_ifc_t_e">mp_if&lt;C, T, E&#8230;&#8203;&gt;</a></li>
516<li><a href="#mp_eval_if_cc_t_f_u">mp_eval_if_c&lt;C, T, F, U&#8230;&#8203;&gt;</a></li>
517<li><a href="#mp_eval_ifc_t_f_u">mp_eval_if&lt;C, T, F, U&#8230;&#8203;&gt;</a></li>
518<li><a href="#mp_eval_if_qc_t_q_u">mp_eval_if_q&lt;C, T, Q, U&#8230;&#8203;&gt;</a></li>
519<li><a href="#mp_eval_if_notc_t_f_u">mp_eval_if_not&lt;C, T, F, U&#8230;&#8203;&gt;</a></li>
520<li><a href="#mp_eval_if_not_qc_t_q_u">mp_eval_if_not_q&lt;C, T, Q, U&#8230;&#8203;&gt;</a></li>
521<li><a href="#mp_validf_t">mp_valid&lt;F, T&#8230;&#8203;&gt;</a></li>
522<li><a href="#mp_valid_qq_t">mp_valid_q&lt;Q, T&#8230;&#8203;&gt;</a></li>
523<li><a href="#mp_eval_ort_f_u">mp_eval_or&lt;T, F, U&#8230;&#8203;&gt;</a></li>
524<li><a href="#mp_eval_or_qt_q_u">mp_eval_or_q&lt;T, Q, U&#8230;&#8203;&gt;</a></li>
525<li><a href="#mp_condc_t_r">mp_cond&lt;C, T, R&#8230;&#8203;&gt;</a></li>
526<li><a href="#mp_deferf_t">mp_defer&lt;F, T&#8230;&#8203;&gt;</a></li>
527<li><a href="#mp_quotef">mp_quote&lt;F&gt;</a></li>
528<li><a href="#mp_quote_traitf">mp_quote_trait&lt;F&gt;</a></li>
529<li><a href="#mp_invoke_qq_t">mp_invoke_q&lt;Q, T&#8230;&#8203;&gt;</a></li>
530<li><a href="#mp_not_fnp">mp_not_fn&lt;P&gt;</a></li>
531<li><a href="#mp_not_fn_qq">mp_not_fn_q&lt;Q&gt;</a></li>
532<li><a href="#mp_composef">mp_compose&lt;F&#8230;&#8203;&gt;</a></li>
533<li><a href="#mp_compose_qq">mp_compose_q&lt;Q&#8230;&#8203;&gt;</a></li>
534</ul>
535</li>
536<li><a href="#algorithm">Algorithms, &lt;boost/mp11/algorithm.hpp&gt;</a>
537<ul class="sectlevel3">
538<li><a href="#mp_transformf_l">mp_transform&lt;F, L&#8230;&#8203;&gt;</a></li>
539<li><a href="#mp_transform_qq_l">mp_transform_q&lt;Q, L&#8230;&#8203;&gt;</a></li>
540<li><a href="#mp_transform_ifp_f_l">mp_transform_if&lt;P, F, L&#8230;&#8203;&gt;</a></li>
541<li><a href="#mp_transform_if_qqp_qf_l">mp_transform_if_q&lt;Qp, Qf, L&#8230;&#8203;&gt;</a></li>
542<li><a href="#mp_filterp_l">mp_filter&lt;P, L&#8230;&#8203;&gt;</a></li>
543<li><a href="#mp_filter_qqp_l">mp_filter_q&lt;Qp, L&#8230;&#8203;&gt;</a></li>
544<li><a href="#mp_filll_v">mp_fill&lt;L, V&gt;</a></li>
545<li><a href="#mp_countl_v">mp_count&lt;L, V&gt;</a></li>
546<li><a href="#mp_count_ifl_p">mp_count_if&lt;L, P&gt;</a></li>
547<li><a href="#mp_count_if_ql_q">mp_count_if_q&lt;L, Q&gt;</a></li>
548<li><a href="#mp_containsl_v">mp_contains&lt;L, V&gt;</a></li>
549<li><a href="#mp_starts_withl1_l2">mp_starts_with&lt;L1, L2&gt;</a></li>
550<li><a href="#mp_repeat_cl_n">mp_repeat_c&lt;L, N&gt;</a></li>
551<li><a href="#mp_repeatl_n">mp_repeat&lt;L, N&gt;</a></li>
552<li><a href="#mp_productf_l">mp_product&lt;F, L&#8230;&#8203;&gt;</a></li>
553<li><a href="#mp_product_qq_l">mp_product_q&lt;Q, L&#8230;&#8203;&gt;</a></li>
554<li><a href="#mp_power_setl">mp_power_set&lt;L&gt;</a></li>
555<li><a href="#mp_drop_cl_n">mp_drop_c&lt;L, N&gt;</a></li>
556<li><a href="#mp_dropl_n">mp_drop&lt;L, N&gt;</a></li>
557<li><a href="#mp_from_sequences">mp_from_sequence&lt;S&gt;</a></li>
558<li><a href="#mp_iota_cn">mp_iota_c&lt;N&gt;</a></li>
559<li><a href="#mp_iotan">mp_iota&lt;N&gt;</a></li>
560<li><a href="#mp_at_cl_i">mp_at_c&lt;L, I&gt;</a></li>
561<li><a href="#mp_atl_i">mp_at&lt;L, I&gt;</a></li>
562<li><a href="#mp_take_cl_n">mp_take_c&lt;L, N&gt;</a></li>
563<li><a href="#mp_takel_n">mp_take&lt;L, N&gt;</a></li>
564<li><a href="#mp_backl">mp_back&lt;L&gt;</a></li>
565<li><a href="#mp_pop_backl">mp_pop_back&lt;L&gt;</a></li>
566<li><a href="#mp_insert_cl_i_t">mp_insert_c&lt;L, I, T&#8230;&#8203;&gt;</a></li>
567<li><a href="#mp_insertl_i_t">mp_insert&lt;L, I, T&#8230;&#8203;&gt;</a></li>
568<li><a href="#mp_erase_cl_i_j">mp_erase_c&lt;L, I, J&gt;</a></li>
569<li><a href="#mp_erasel_i_j">mp_erase&lt;L, I, J&gt;</a></li>
570<li><a href="#mp_replacel_v_w">mp_replace&lt;L, V, W&gt;</a></li>
571<li><a href="#mp_replace_ifl_p_w">mp_replace_if&lt;L, P, W&gt;</a></li>
572<li><a href="#mp_replace_if_ql_q_w">mp_replace_if_q&lt;L, Q, W&gt;</a></li>
573<li><a href="#mp_replace_at_cl_i_w">mp_replace_at_c&lt;L, I, W&gt;</a></li>
574<li><a href="#mp_replace_atl_i_w">mp_replace_at&lt;L, I, W&gt;</a></li>
575<li><a href="#mp_rotate_left_cl_n">mp_rotate_left_c&lt;L, N&gt;</a></li>
576<li><a href="#mp_rotate_leftl_n">mp_rotate_left&lt;L, N&gt;</a></li>
577<li><a href="#mp_rotate_right_cl_n">mp_rotate_right_c&lt;L, N&gt;</a></li>
578<li><a href="#mp_rotate_rightl_n">mp_rotate_right&lt;L, N&gt;</a></li>
579<li><a href="#mp_copy_ifl_p">mp_copy_if&lt;L, P&gt;</a></li>
580<li><a href="#mp_copy_if_ql_q">mp_copy_if_q&lt;L, Q&gt;</a></li>
581<li><a href="#mp_removel_v">mp_remove&lt;L, V&gt;</a></li>
582<li><a href="#mp_remove_ifl_p">mp_remove_if&lt;L, P&gt;</a></li>
583<li><a href="#mp_remove_if_ql_q">mp_remove_if_q&lt;L, Q&gt;</a></li>
584<li><a href="#mp_flattenl">mp_flatten&lt;L&gt;</a></li>
585<li><a href="#mp_partitionl_p">mp_partition&lt;L, P&gt;</a></li>
586<li><a href="#mp_partition_ql_q">mp_partition_q&lt;L, Q&gt;</a></li>
587<li><a href="#mp_sortl_p">mp_sort&lt;L, P&gt;</a></li>
588<li><a href="#mp_sort_ql_q">mp_sort_q&lt;L, Q&gt;</a></li>
589<li><a href="#mp_nth_element_cl_i_p">mp_nth_element_c&lt;L, I, P&gt;</a></li>
590<li><a href="#mp_nth_elementl_i_p">mp_nth_element&lt;L, I, P&gt;</a></li>
591<li><a href="#mp_nth_element_ql_i_q">mp_nth_element_q&lt;L, I, Q&gt;</a></li>
592<li><a href="#mp_min_elementl_p">mp_min_element&lt;L, P&gt;</a></li>
593<li><a href="#mp_min_element_ql_q">mp_min_element_q&lt;L, Q&gt;</a></li>
594<li><a href="#mp_max_elementl_p">mp_max_element&lt;L, P&gt;</a></li>
595<li><a href="#mp_max_element_ql_q">mp_max_element_q&lt;L, Q&gt;</a></li>
596<li><a href="#mp_findl_v">mp_find&lt;L, V&gt;</a></li>
597<li><a href="#mp_find_ifl_p">mp_find_if&lt;L, P&gt;</a></li>
598<li><a href="#mp_find_if_ql_q">mp_find_if_q&lt;L, Q&gt;</a></li>
599<li><a href="#mp_reversel">mp_reverse&lt;L&gt;</a></li>
600<li><a href="#mp_foldl_v_f">mp_fold&lt;L, V, F&gt;</a></li>
601<li><a href="#mp_fold_ql_v_q">mp_fold_q&lt;L, V, Q&gt;</a></li>
602<li><a href="#mp_reverse_foldl_v_f">mp_reverse_fold&lt;L, V, F&gt;</a></li>
603<li><a href="#mp_reverse_fold_ql_v_q">mp_reverse_fold_q&lt;L, V, Q&gt;</a></li>
604<li><a href="#mp_partial_suml_v_f">mp_partial_sum&lt;L, V, F&gt;</a></li>
605<li><a href="#mp_partial_sum_ql_v_q">mp_partial_sum_q&lt;L, V, Q&gt;</a></li>
606<li><a href="#mp_iteratev_f_r">mp_iterate&lt;V, F, R&gt;</a></li>
607<li><a href="#mp_iterate_qv_qf_qr">mp_iterate_q&lt;V, Qf, Qr&gt;</a></li>
608<li><a href="#mp_uniquel">mp_unique&lt;L&gt;</a></li>
609<li><a href="#mp_unique_ifl_p">mp_unique_if&lt;L, P&gt;</a></li>
610<li><a href="#mp_unique_if_ql_q">mp_unique_if_q&lt;L, Q&gt;</a></li>
611<li><a href="#mp_all_ofl_p">mp_all_of&lt;L, P&gt;</a></li>
612<li><a href="#mp_all_of_ql_q">mp_all_of_q&lt;L, Q&gt;</a></li>
613<li><a href="#mp_none_ofl_p">mp_none_of&lt;L, P&gt;</a></li>
614<li><a href="#mp_none_of_ql_q">mp_none_of_q&lt;L, Q&gt;</a></li>
615<li><a href="#mp_any_ofl_p">mp_any_of&lt;L, P&gt;</a></li>
616<li><a href="#mp_any_of_ql_q">mp_any_of_q&lt;L, Q&gt;</a></li>
617<li><a href="#mp_for_eachlf">mp_for_each&lt;L&gt;(f)</a></li>
618<li><a href="#mp_with_indexni_f">mp_with_index&lt;N&gt;(i, f)</a></li>
619</ul>
620</li>
621<li><a href="#set">Set Operations, &lt;boost/mp11/set.hpp&gt;</a>
622<ul class="sectlevel3">
623<li><a href="#mp_is_sets">mp_is_set&lt;S&gt;</a></li>
624<li><a href="#mp_set_containss_v">mp_set_contains&lt;S, V&gt;</a></li>
625<li><a href="#mp_set_push_backs_t">mp_set_push_back&lt;S, T&#8230;&#8203;&gt;</a></li>
626<li><a href="#mp_set_push_fronts_t">mp_set_push_front&lt;S, T&#8230;&#8203;&gt;</a></li>
627<li><a href="#mp_set_unionl">mp_set_union&lt;L&#8230;&#8203;&gt;</a></li>
628<li><a href="#mp_set_intersections">mp_set_intersection&lt;S&#8230;&#8203;&gt;</a></li>
629<li><a href="#mp_set_differencel_s">mp_set_difference&lt;L, S&#8230;&#8203;&gt;</a></li>
630</ul>
631</li>
632<li><a href="#map">Map Operations, &lt;boost/mp11/map.hpp&gt;</a>
633<ul class="sectlevel3">
634<li><a href="#mp_is_mapm">mp_is_map&lt;M&gt;</a></li>
635<li><a href="#mp_map_findm_k">mp_map_find&lt;M, K&gt;</a></li>
636<li><a href="#mp_map_containsm_k">mp_map_contains&lt;M, K&gt;</a></li>
637<li><a href="#mp_map_insertm_t">mp_map_insert&lt;M, T&gt;</a></li>
638<li><a href="#mp_map_replacem_t">mp_map_replace&lt;M, T&gt;</a></li>
639<li><a href="#mp_map_updatem_t_f">mp_map_update&lt;M, T, F&gt;</a></li>
640<li><a href="#mp_map_update_qm_t_q">mp_map_update_q&lt;M, T, Q&gt;</a></li>
641<li><a href="#mp_map_erasem_k">mp_map_erase&lt;M, K&gt;</a></li>
642<li><a href="#mp_map_keysm">mp_map_keys&lt;M&gt;</a></li>
643</ul>
644</li>
645<li><a href="#function">Helper Metafunctions, &lt;boost/mp11/function.hpp&gt;</a>
646<ul class="sectlevel3">
647<li><a href="#mp_voidt">mp_void&lt;T&#8230;&#8203;&gt;</a></li>
648<li><a href="#mp_andt">mp_and&lt;T&#8230;&#8203;&gt;</a></li>
649<li><a href="#mp_allt">mp_all&lt;T&#8230;&#8203;&gt;</a></li>
650<li><a href="#mp_ort">mp_or&lt;T&#8230;&#8203;&gt;</a></li>
651<li><a href="#mp_anyt">mp_any&lt;T&#8230;&#8203;&gt;</a></li>
652<li><a href="#mp_samet">mp_same&lt;T&#8230;&#8203;&gt;</a></li>
653<li><a href="#mp_similart">mp_similar&lt;T&#8230;&#8203;&gt;</a></li>
654<li><a href="#mp_plust">mp_plus&lt;T&#8230;&#8203;&gt;</a></li>
655<li><a href="#mp_lesst1_t2">mp_less&lt;T1, T2&gt;</a></li>
656<li><a href="#mp_mint1_t">mp_min&lt;T1, T&#8230;&#8203;&gt;</a></li>
657<li><a href="#mp_maxt1_t">mp_max&lt;T1, T&#8230;&#8203;&gt;</a></li>
658</ul>
659</li>
660<li><a href="#bind">Bind, &lt;boost/mp11/bind.hpp&gt;</a>
661<ul class="sectlevel3">
662<li><a href="#mp_argi">mp_arg&lt;I&gt;</a></li>
663<li><a href="#1_9">_1, &#8230;&#8203;, _9</a></li>
664<li><a href="#mp_bindf_t">mp_bind&lt;F, T&#8230;&#8203;&gt;</a></li>
665<li><a href="#mp_bind_qq_t">mp_bind_q&lt;Q, T&#8230;&#8203;&gt;</a></li>
666<li><a href="#mp_bind_frontf_t">mp_bind_front&lt;F, T&#8230;&#8203;&gt;</a></li>
667<li><a href="#mp_bind_front_qq_t">mp_bind_front_q&lt;Q, T&#8230;&#8203;&gt;</a></li>
668<li><a href="#mp_bind_backf_t">mp_bind_back&lt;F, T&#8230;&#8203;&gt;</a></li>
669<li><a href="#mp_bind_back_qq_t">mp_bind_back_q&lt;Q, T&#8230;&#8203;&gt;</a></li>
670</ul>
671</li>
672<li><a href="#integer_sequence">Integer Sequences, &lt;boost/mp11/integer_sequence.hpp&gt;</a>
673<ul class="sectlevel3">
674<li><a href="#integer_sequencet_i">integer_sequence&lt;T, I&#8230;&#8203;&gt;</a></li>
675<li><a href="#make_integer_sequencet_n">make_integer_sequence&lt;T, N&gt;</a></li>
676<li><a href="#index_sequencei">index_sequence&lt;I&#8230;&#8203;&gt;</a></li>
677<li><a href="#make_index_sequencen">make_index_sequence&lt;N&gt;</a></li>
678<li><a href="#index_sequence_fort">index_sequence_for&lt;T&#8230;&#8203;&gt;</a></li>
679</ul>
680</li>
681<li><a href="#tuple">Tuple Operations, &lt;boost/mp11/tuple.hpp&gt;</a>
682<ul class="sectlevel3">
683<li><a href="#tuple_applyf_tp">tuple_apply(f, tp)</a></li>
684<li><a href="#construct_from_tuplettp">construct_from_tuple&lt;T&gt;(tp)</a></li>
685<li><a href="#tuple_for_eachtp_f">tuple_for_each(tp, f)</a></li>
686<li><a href="#tuple_transformf_tp">tuple_transform(f, tp&#8230;&#8203;)</a></li>
687</ul>
688</li>
689<li><a href="#mp11">Convenience Header, &lt;boost/mp11.hpp&gt;</a></li>
690<li><a href="#mpl">MPL Support, &lt;boost/mp11/mpl.hpp&gt;</a></li>
691</ul>
692</li>
693<li><a href="#copyright_license_and_acknowledgments">Appendix A: Copyright, License, and Acknowledgments</a></li>
694</ul>
695</div>
696</div>
697<div id="content">
698<div class="sect1">
699<h2 id="overview">Overview</h2>
700<div class="sectionbody">
701<div class="paragraph">
702<p>Mp11 is a C++11 metaprogramming library for compile-time manipulation of data structures
703that contain types. It&#8217;s based on template aliases and variadic templates and implements the
704approach outlined in the article
705<a href="simple_cxx11_metaprogramming.html">"Simple C&#43;&#43; metaprogramming"</a>
706and <a href="simple_cxx11_metaprogramming_2.html">its sequel</a>. Reading these
707articles before proceeding with this documentation is <em>highly</em> recommended.</p>
708</div>
709<div class="paragraph">
710<p>The general principles upon which Mp11 is built are that algorithms and metafunctions are
711template aliases of the form <code>F&lt;T&#8230;&#8203;&gt;</code> and data structures are lists of the form <code>L&lt;T&#8230;&#8203;&gt;</code>,
712with the library placing no requirements on <code>L</code>. <code>mp_list&lt;T&#8230;&#8203;&gt;</code> is the built-in list type,
713but <code>std::tuple&lt;T&#8230;&#8203;&gt;</code>, <code>std::pair&lt;T1, T2&gt;</code> and <code>std::variant&lt;T&#8230;&#8203;&gt;</code> are also perfectly
714legitimate list types, although of course <code>std::pair&lt;T1, T2&gt;</code>, due to having exactly two elements,
715is not resizeable and will consequently not work with algorithms that need to add or remove
716elements.</p>
717</div>
718<div class="paragraph">
719<p>Another distinguishing feature of this approach is that lists (<code>L&lt;T&#8230;&#8203;&gt;</code>) have the same form as
720metafunctions (<code>F&lt;T&#8230;&#8203;&gt;</code>) and can therefore be used as such. For example, applying <code>std::add_pointer_t</code>
721to the list <code>std::tuple&lt;int, float&gt;</code> by way of <code>mp_transform&lt;std::add_pointer_t, std::tuple&lt;int, float&gt;&gt;</code>
722gives us <code>std::tuple&lt;int*, float*&gt;</code>, but we can also apply <code>mp_list</code> to the same tuple:</p>
723</div>
724<div class="literalblock">
725<div class="content">
726<pre>using R = mp_transform&lt;mp_list, std::tuple&lt;int, float&gt;&gt;;</pre>
727</div>
728</div>
729<div class="paragraph">
730<p>and get <code>std::tuple&lt;mp_list&lt;int&gt;, mp_list&lt;float&gt;&gt;</code>.</p>
731</div>
732</div>
733</div>
734<div class="sect1">
735<h2 id="definitions">Definitions</h2>
736<div class="sectionbody">
737<div class="paragraph">
738<p>A <em>list</em> is a&#8201;&#8212;&#8201;usually but not necessarily variadic&#8201;&#8212;&#8201;template class whose parameters are all types,
739for example <code>mp_list&lt;char[], void&gt;</code>, <code>mp_list&lt;&gt;</code>, <code>std::tuple&lt;int, float, char&gt;</code>, <code>std::pair&lt;int, float&gt;</code>, <code>std::shared_ptr&lt;X&gt;</code>.</p>
740</div>
741<div class="paragraph">
742<p>A <em>metafunction</em> is a class template or a template alias whose parameters are all types, for example <code>std::add_pointer_t</code>,
743<code>std::is_const</code>, <code>mp_second</code>, <code>mp_push_front</code>, <code>mp_list</code>, <code>std::tuple</code>, <code>std::pair</code>, <code>std::shared_ptr</code>, or</p>
744</div>
745<div class="listingblock">
746<div class="content">
747<pre class="highlight"><code>template&lt;class...&gt; using F1 = void;
748
749template&lt;class T&gt; using F2 = T*;
750
751template&lt;class... T&gt; using F3 = std::integral_constant&lt;std::size_t, sizeof...(T)&gt;;</code></pre>
752</div>
753</div>
754<div class="paragraph">
755<p>A <em>quoted metafunction</em> is a class with a public metafunction member called <code>fn</code>, for example</p>
756</div>
757<div class="listingblock">
758<div class="content">
759<pre class="highlight"><code>struct Q1 { template&lt;class...&gt; using fn = void; };
760
761struct Q2 { template&lt;class T&gt; using fn = T*; };
762
763struct Q3 { template&lt;class... T&gt; using fn =
764  std::integral_constant&lt;std::size_t, sizeof...(T)&gt;; };</code></pre>
765</div>
766</div>
767<div class="paragraph">
768<p>An <em>integral constant type</em> is a class with a public member <code>value</code> that is an integral constant in the C++ sense. For example,
769<code>std::integral_constant&lt;int, 7&gt;</code>, or</p>
770</div>
771<div class="literalblock">
772<div class="content">
773<pre>struct N { static int constexpr value = 2; };</pre>
774</div>
775</div>
776<div class="paragraph">
777<p>A <em>set</em> is a list whose elements are unique.</p>
778</div>
779<div class="paragraph">
780<p>A <em>map</em> is a list of lists, the inner lists having at least one element (the key.) The keys of the map must be unique. For example,</p>
781</div>
782<div class="listingblock">
783<div class="content">
784<pre class="highlight"><code>using M1 = std::tuple&lt;std::pair&lt;int, int*&gt;, std::pair&lt;float, float*&gt;,
785    std::pair&lt;void, void*&gt;&gt;;
786
787using M2 = mp_list&lt;mp_list&lt;int, int*&gt;, mp_list&lt;float&gt;,
788    mp_list&lt;char, char[1], char[2]&gt;&gt;;</code></pre>
789</div>
790</div>
791</div>
792</div>
793<div class="sect1">
794<h2 id="examples">Examples</h2>
795<div class="sectionbody">
796<div class="sect2">
797<h3 id="generating_test_cases">Generating Test Cases</h3>
798<div class="paragraph">
799<p>Let&#8217;s suppose that we have written a metafunction <code>result&lt;T, U&gt;</code>:</p>
800</div>
801<div class="listingblock">
802<div class="content">
803<pre class="highlight"><code>template&lt;class T&gt; using promote = typename std::common_type&lt;T, int&gt;::type;
804
805template&lt;class T, class U&gt; using result =
806    typename std::common_type&lt;promote&lt;T&gt;, promote&lt;U&gt;&gt;::type;</code></pre>
807</div>
808</div>
809<div class="paragraph">
810<p>that ought to represent the result of an arithmetic operation on the integer types <code>T</code> and <code>U</code>,
811for example <code>t + u</code>. We want to test whether <code>result&lt;T, U&gt;</code> gives correct results for various combinations
812of <code>T</code> and <code>U</code>, so we write the function</p>
813</div>
814<div class="listingblock">
815<div class="content">
816<pre class="highlight"><code>template&lt;class T1, class T2&gt; void test_result()
817{
818    using T3 = decltype( T1() + T2() );
819    using T4 = result&lt;T1, T2&gt;;
820
821    std::cout &lt;&lt; ( std::is_same&lt;T3, T4&gt;::value? "[PASS]": "[FAIL]" ) &lt;&lt; std::endl;
822}</code></pre>
823</div>
824</div>
825<div class="paragraph">
826<p>and then need to call it a substantial number of times:</p>
827</div>
828<div class="literalblock">
829<div class="content">
830<pre>int main()
831{
832    test_result&lt;char, char&gt;();
833    test_result&lt;char, short&gt;();
834    test_result&lt;char, int&gt;();
835    test_result&lt;char, unsigned&gt;();
836    // ...
837}</pre>
838</div>
839</div>
840<div class="paragraph">
841<p>Writing all those type combinations by hand is unwieldy, error prone, and worst of all, boring. This is
842how we can leverage Mp11 to automate the task:</p>
843</div>
844<div class="listingblock">
845<div class="content">
846<pre class="highlight"><code>#include &lt;boost/mp11.hpp&gt;
847#include &lt;boost/core/demangle.hpp&gt;
848#include &lt;type_traits&gt;
849#include &lt;iostream&gt;
850#include &lt;typeinfo&gt;
851
852using namespace boost::mp11;
853
854template&lt;class T&gt; std::string name()
855{
856    return boost::core::demangle( typeid(T).name() );
857}
858
859template&lt;class T&gt; using promote = typename std::common_type&lt;T, int&gt;::type;
860
861template&lt;class T, class U&gt; using result =
862    typename std::common_type&lt;promote&lt;T&gt;, promote&lt;U&gt;&gt;::type;
863
864template&lt;class T1, class T2&gt; void test_result( mp_list&lt;T1, T2&gt; const&amp; )
865{
866    using T3 = decltype( T1() + T2() );
867    using T4 = result&lt;T1, T2&gt;;
868
869    std::cout &lt;&lt; ( std::is_same&lt;T3, T4&gt;::value? "[PASS] ": "[FAIL] " )
870        &lt;&lt; name&lt;T1&gt;() &lt;&lt; " + " &lt;&lt; name&lt;T2&gt;() &lt;&lt; " -&gt; " &lt;&lt; name&lt;T3&gt;()
871        &lt;&lt; ", result: " &lt;&lt; name&lt;T4&gt;() &lt;&lt; std::endl;
872}
873
874int main()
875{
876    using L = std::tuple&lt;char, short, int, unsigned, long, unsigned long&gt;;
877    tuple_for_each( mp_product&lt;mp_list, L, L&gt;(), [](auto&amp;&amp; x){ test_result(x); } );
878}</code></pre>
879</div>
880</div>
881<div class="paragraph">
882<p>How does it work?</p>
883</div>
884<div class="paragraph">
885<p><code>mp_product&lt;F, L1, L2&gt;</code> calls <code>F&lt;T1, T2&gt;</code> where <code>T1</code> varies over the elements of <code>L1</code> and <code>T2</code> varies over
886the elements of <code>L2</code>, as if by executing two nested loops. It then returns a list of these results, of the same
887type as <code>L1</code>.</p>
888</div>
889<div class="paragraph">
890<p>In our case, both lists are the same <code>std::tuple</code>, and <code>F</code> is <code>mp_list</code>, so <code>mp_product&lt;mp_list, L, L&gt;</code> will get us
891<code>std::tuple&lt;mp_list&lt;char, char&gt;, mp_list&lt;char, short&gt;, mp_list&lt;char, int&gt;, &#8230;&#8203;, mp_list&lt;unsigned long, long&gt;, mp_list&lt;unsigned long, unsigned long&gt;&gt;</code>.</p>
892</div>
893<div class="paragraph">
894<p>We then default-construct this tuple and pass it to <code>tuple_for_each</code>. <code>tuple_for_each(tp, f)</code> calls <code>f</code> for every
895tuple element; we use a (C++14) lambda that calls <code>test_result</code>.</p>
896</div>
897<div class="paragraph">
898<p>In pure C++11, we can&#8217;t use a lambda with an <code>auto&amp;&amp;</code> parameter, so we&#8217;ll have to make <code>test_result</code> a function object with
899a templated <code>operator()</code> and pass that to <code>tuple_for_each</code> directly:</p>
900</div>
901<div class="listingblock">
902<div class="content">
903<pre class="highlight"><code>struct test_result
904{
905    template&lt;class T1, class T2&gt; void operator()( mp_list&lt;T1, T2&gt; const&amp; ) const
906    {
907        using T3 = decltype( T1() + T2() );
908        using T4 = result&lt;T1, T2&gt;;
909
910        std::cout &lt;&lt; ( std::is_same&lt;T3, T4&gt;::value? "[PASS] ": "[FAIL] " )
911            &lt;&lt; name&lt;T1&gt;() &lt;&lt; " + " &lt;&lt; name&lt;T2&gt;() &lt;&lt; " -&gt; " &lt;&lt; name&lt;T3&gt;()
912            &lt;&lt; ", result: " &lt;&lt; name&lt;T4&gt;() &lt;&lt; std::endl;
913    }
914};
915
916int main()
917{
918    using L = std::tuple&lt;char, short, int, unsigned, long, unsigned long&gt;;
919    tuple_for_each( mp_product&lt;mp_list, L, L&gt;(), test_result() );
920}</code></pre>
921</div>
922</div>
923</div>
924<div class="sect2">
925<h3 id="writing_common_type_specializations">Writing common_type Specializations</h3>
926<div class="paragraph">
927<p>The standard trait <code>std::common_type</code>, used to obtain a type to which all of its arguments can convert without
928unnecessary loss of precision, can be user-specialized when its default implementation (based on the ternary <code>?:</code>
929operator) is unsuitable.</p>
930</div>
931<div class="paragraph">
932<p>Let&#8217;s write a <code>common_type</code> specialization for two <code>std::tuple</code> arguments. For that, we need a metafunction that
933applies <code>std::common_type</code> to each pair of elements and gathers the results into a tuple:</p>
934</div>
935<div class="listingblock">
936<div class="content">
937<pre class="highlight"><code>template&lt;class... T&gt; using common_type_t =
938    typename std::common_type&lt;T...&gt;::type; // standard in C++14
939
940template&lt;class Tp1, class Tp2&gt; using common_tuple =
941    mp_transform&lt;common_type_t, Tp1, Tp2&gt;;</code></pre>
942</div>
943</div>
944<div class="paragraph">
945<p>then specialize <code>common_type</code> to use it:</p>
946</div>
947<div class="listingblock">
948<div class="content">
949<pre class="highlight"><code>namespace std
950{
951
952    template&lt;class... T1, class... T2&gt;
953    struct common_type&lt;std::tuple&lt;T1...&gt;, std::tuple&lt;T2...&gt;&gt;:
954        mp_defer&lt;common_tuple, std::tuple&lt;T1...&gt;, std::tuple&lt;T2...&gt;&gt;
955    {
956    };
957
958} // std</code></pre>
959</div>
960</div>
961<div class="paragraph">
962<p>(There is no need to specialize <code>std::common_type</code> for more than two arguments - it takes care of synthesizing the appropriate semantics from
963the binary case.)</p>
964</div>
965<div class="paragraph">
966<p>The subtlety here is the use of <code>mp_defer</code>. We could have defined a nested <code>type</code> to <code>common_tuple&lt;std::tuple&lt;T1&#8230;&#8203;&gt;, std::tuple&lt;T2&#8230;&#8203;&gt;&gt;</code>,
967and it would still have worked in all valid cases. By letting <code>mp_defer</code> define <code>type</code>, though, we make our specialization <em>SFINAE-friendly</em>.</p>
968</div>
969<div class="paragraph">
970<p>That is, when our <code>common_tuple</code> causes a substitution failure instead of a hard error, <code>mp_defer</code> will not define a nested <code>type</code>,
971and <code>common_type_t</code>, which is defined as <code>typename common_type&lt;&#8230;&#8203;&gt;::type</code>, will also cause a substitution failure.</p>
972</div>
973<div class="paragraph">
974<p>As another example, consider the hypothetical type <code>expected&lt;T, E&#8230;&#8203;&gt;</code> that represents either a successful return with a value of <code>T</code>,
975or an unsuccessful return with an error code of some type in the list <code>E&#8230;&#8203;</code>. The common type of <code>expected&lt;T1, E1, E2, E3&gt;</code> and
976<code>expected&lt;T2, E1, E4, E5&gt;</code> is <code>expected&lt;common_type_t&lt;T1, T2&gt;, E1, E2, E3, E4, E5&gt;</code>. That is, the possible return values are
977combined into their common type, and we take the union of the set of error types.</p>
978</div>
979<div class="paragraph">
980<p>Therefore,</p>
981</div>
982<div class="listingblock">
983<div class="content">
984<pre class="highlight"><code>template&lt;class T1, class E1, class T2, class E2&gt; using common_expected =
985    mp_rename&lt;mp_push_front&lt;mp_unique&lt;mp_append&lt;E1, E2&gt;&gt;, common_type_t&lt;T1, T2&gt;&gt;,
986        expected&gt;;
987
988namespace std
989{
990
991    template&lt;class T1, class... E1, class T2, class... E2&gt;
992    struct common_type&lt;expected&lt;T1, E1...&gt;, expected&lt;T2, E2...&gt;&gt;:
993        mp_defer&lt;common_expected, T1, mp_list&lt;E1...&gt;, T2, mp_list&lt;E2...&gt;&gt;
994    {
995    };
996
997} // std</code></pre>
998</div>
999</div>
1000<div class="paragraph">
1001<p>Here we&#8217;ve taken a different tack; instead of passing the <code>expected</code> types to <code>common_expected</code>, we&#8217;re passing the <code>T</code> types and lists of
1002the <code>E</code> types. This makes our job easier. <code>mp_unique&lt;mp_append&lt;E1, E2&gt;&gt;</code> gives us the concatenation of <code>E1</code> and <code>E2</code> with the duplicates
1003removed; we then add <code>common_type_t&lt;T1, T2&gt;</code> to the front via <code>mp_push_front</code>; and finally, we <code>mp_rename</code> the resultant <code>mp_list</code>
1004to <code>expected</code>.</p>
1005</div>
1006</div>
1007<div class="sect2">
1008<h3 id="fixing_tuple_cat">Fixing tuple_cat</h3>
1009<div class="paragraph">
1010<p>The article <a href="http://pdimov.com/cpp2/simple_cxx11_metaprogramming.html#">Simple C++11 metaprogramming</a> builds an
1011implementation of the standard function <code>tuple_cat</code>, with the end result given below:</p>
1012</div>
1013<div class="listingblock">
1014<div class="content">
1015<pre class="highlight"><code>template&lt;class L&gt; using F = mp_iota&lt;mp_size&lt;L&gt;&gt;;
1016
1017template&lt;class R, class...Is, class... Ks, class Tp&gt;
1018R tuple_cat_( mp_list&lt;Is...&gt;, mp_list&lt;Ks...&gt;, Tp tp )
1019{
1020    return R{ std::get&lt;Ks::value&gt;(std::get&lt;Is::value&gt;(tp))... };
1021}
1022
1023template&lt;class... Tp,
1024    class R = mp_append&lt;std::tuple&lt;&gt;, typename std::remove_reference&lt;Tp&gt;::type...&gt;&gt;
1025    R tuple_cat( Tp &amp;&amp;... tp )
1026{
1027    std::size_t const N = sizeof...(Tp);
1028
1029    // inner
1030
1031    using list1 = mp_list&lt;
1032        mp_rename&lt;typename std::remove_reference&lt;Tp&gt;::type, mp_list&gt;...&gt;;
1033
1034    using list2 = mp_iota_c&lt;N&gt;;
1035
1036    using list3 = mp_transform&lt;mp_fill, list1, list2&gt;;
1037
1038    using inner = mp_apply&lt;mp_append, list3&gt;;
1039
1040    // outer
1041
1042    using list4 = mp_transform&lt;F, list1&gt;;
1043
1044    using outer = mp_apply&lt;mp_append, list4&gt;;
1045
1046    //
1047
1048    return tuple_cat_&lt;R&gt;( inner(), outer(),
1049        std::forward_as_tuple( std::forward&lt;Tp&gt;(tp)... ) );
1050}</code></pre>
1051</div>
1052</div>
1053<div class="paragraph">
1054<p>This function, however, is not entirely correct, in that it doesn&#8217;t handle some cases properly. For example,
1055trying to concatenate tuples containing move-only elements such as <code>unique_ptr</code> fails:</p>
1056</div>
1057<div class="listingblock">
1058<div class="content">
1059<pre class="highlight"><code>std::tuple&lt;std::unique_ptr&lt;int&gt;&gt; t1;
1060std::tuple&lt;std::unique_ptr&lt;float&gt;&gt; t2;
1061
1062auto result = ::tuple_cat( std::move( t1 ), std::move( t2 ) );</code></pre>
1063</div>
1064</div>
1065<div class="paragraph">
1066<p>Trying to concatenate <code>const</code> tuples fails:</p>
1067</div>
1068<div class="listingblock">
1069<div class="content">
1070<pre class="highlight"><code>std::tuple&lt;int&gt; const t1;
1071std::tuple&lt;float&gt; const t2;
1072
1073auto result = ::tuple_cat( t1, t2 );</code></pre>
1074</div>
1075</div>
1076<div class="paragraph">
1077<p>And finally, the standard <code>tuple_cat</code> is specified to work on arbitrary tuple-like types (that is, all types
1078that support <code>tuple_size</code>, <code>tuple_element</code>, and <code>get</code>), while our implementation only works with <code>tuple</code> and
1079<code>pair</code>. <code>std::array</code>, for example, fails:</p>
1080</div>
1081<div class="listingblock">
1082<div class="content">
1083<pre class="highlight"><code>std::array&lt;int, 2&gt; t1{ 1, 2 };
1084std::array&lt;float, 3&gt; t2{ 3.0f, 4.0f, 5.0f };
1085
1086auto result = ::tuple_cat( t1, t2 );</code></pre>
1087</div>
1088</div>
1089<div class="paragraph">
1090<p>Let&#8217;s fix these one by one. Support for move-only types is easy, if one knows where to look. The problem is
1091that <code>Tp</code> that we&#8217;re passing to the helper <code>tuple_cat_</code> is (correctly) <code>tuple&lt;unique_ptr&lt;int&gt;&amp;&amp;, unique_ptr&lt;float&gt;&amp;&amp;&gt;</code>,
1092but <code>std::get&lt;0&gt;(tp)</code> still returns <code>unique_ptr&lt;int&gt;&amp;</code>, because <code>tp</code> is an lvalue. This behavior is a bit
1093surprising, but is intended to prevent inadvertent double moves.</p>
1094</div>
1095<div class="paragraph">
1096<p>Long story short, we need <code>std::move(tp)</code> in <code>tuple_cat_</code> to make <code>tp</code> an rvalue:</p>
1097</div>
1098<div class="literalblock">
1099<div class="content">
1100<pre>template&lt;class R, class...Is, class... Ks, class Tp&gt;
1101R tuple_cat_( mp_list&lt;Is...&gt;, mp_list&lt;Ks...&gt;, Tp tp )
1102{
1103    return R{ std::get&lt;Ks::value&gt;(std::get&lt;Is::value&gt;(std::move(tp)))... };
1104}</pre>
1105</div>
1106</div>
1107<div class="paragraph">
1108<p>Next, <code>const</code>-qualified tuples. The issue here is that we&#8217;re stripping references from the input tuples, but not
1109<code>const</code>. As a result, we&#8217;re trying to manipulate types such as <code>tuple&lt;int&gt; const</code> with Mp11 algorithms, and these
1110types do not fit the list concept. We just need to strip qualifiers as well, by defining the useful <code>remove_cv_ref</code>
1111primitive that is inexplicably missing from the standard library:</p>
1112</div>
1113<div class="literalblock">
1114<div class="content">
1115<pre>template&lt;class T&gt; using remove_cv_ref = typename std::remove_cv&lt;
1116    typename std::remove_reference&lt;T&gt;::type&gt;::type;</pre>
1117</div>
1118</div>
1119<div class="paragraph">
1120<p>and then by using <code>remove_cv_ref&lt;Tp&gt;</code> in place of <code>typename std::remove_reference&lt;Tp&gt;::type</code>:</p>
1121</div>
1122<div class="listingblock">
1123<div class="content">
1124<pre class="highlight"><code>template&lt;class... Tp,
1125    class R = mp_append&lt;std::tuple&lt;&gt;, remove_cv_ref&lt;Tp&gt;...&gt;&gt;
1126    R tuple_cat( Tp &amp;&amp;... tp )
1127{
1128    std::size_t const N = sizeof...(Tp);
1129
1130    // inner
1131
1132    using list1 = mp_list&lt;mp_rename&lt;remove_cv_ref&lt;Tp&gt;, mp_list&gt;...&gt;;
1133
1134    // ...</code></pre>
1135</div>
1136</div>
1137<div class="paragraph">
1138<p>Finally, tuple-like types. We&#8217;ve so far exploited the fact that <code>std::pair</code> and <code>std::tuple</code> are valid Mp11 lists,
1139but in general, arbitrary tuple-like types aren&#8217;t, so we need to convert them into such. For that, we&#8217;ll need to
1140define a metafunction <code>from_tuple_like</code> that will take an arbitrary tuple-like type and will return, in our case,
1141the corresponding <code>mp_list</code>.</p>
1142</div>
1143<div class="paragraph">
1144<p>Technically, a more principled approach would&#8217;ve been to return <code>std::tuple</code>, but here <code>mp_list</code> will prove more
1145convenient.</p>
1146</div>
1147<div class="paragraph">
1148<p>What we need is, given a tuple-like type <code>Tp</code>, to obtain <code>mp_list&lt;std::tuple_element&lt;0, Tp&gt;::type, std::tuple_element&lt;1, Tp&gt;::type,
1149&#8230;&#8203;, std::tuple_element&lt;N-1, Tp&gt;::type&gt;</code>, where <code>N</code> is <code>tuple_size&lt;Tp&gt;::value</code>. Here&#8217;s one way to do it:</p>
1150</div>
1151<div class="listingblock">
1152<div class="content">
1153<pre class="highlight"><code>template&lt;class T, class I&gt; using tuple_element =
1154    typename std::tuple_element&lt;I::value, T&gt;::type;
1155
1156template&lt;class T&gt; using from_tuple_like =
1157    mp_product&lt;tuple_element, mp_list&lt;T&gt;, mp_iota&lt;std::tuple_size&lt;T&gt;&gt;&gt;;</code></pre>
1158</div>
1159</div>
1160<div class="paragraph">
1161<p>(<code>mp_iota&lt;N&gt;</code> is an algorithm that returns an <code>mp_list</code> with elements <code>mp_size_t&lt;0&gt;</code>, <code>mp_size_t&lt;1&gt;</code>, &#8230;&#8203;, <code>mp_size_t&lt;N-1&gt;</code>.)</p>
1162</div>
1163<div class="paragraph">
1164<p>Remember that <code>mp_product&lt;F, L1, L2&gt;</code> performs the equivalent of two nested loops over the elements of <code>L1</code> and <code>L2</code>,
1165applying <code>F</code> to the two variables and gathering the result. In our case <code>L1</code> consists of the single element <code>T</code>, so
1166only the second loop (over <code>mp_iota&lt;N&gt;</code>, where <code>N</code> is <code>tuple_size&lt;T&gt;</code>), remains, and we get a list of the same type
1167as <code>L1</code> (an <code>mp_list</code>) with contents <code>tuple_element&lt;T, mp_size_t&lt;0&gt;&gt;</code>, <code>tuple_element&lt;T, mp_size_t&lt;1&gt;&gt;</code>, &#8230;&#8203;,
1168<code>tuple_element&lt;T, mp_size_t&lt;N-1&gt;&gt;</code>.</p>
1169</div>
1170<div class="paragraph">
1171<p>For completeness&#8217;s sake, here&#8217;s another, more traditional way to achieve the same result:</p>
1172</div>
1173<div class="literalblock">
1174<div class="content">
1175<pre>template&lt;class T&gt; using from_tuple_like =
1176    mp_transform_q&lt;mp_bind_front&lt;tuple_element, T&gt;, mp_iota&lt;std::tuple_size&lt;T&gt;&gt;&gt;;</pre>
1177</div>
1178</div>
1179<div class="paragraph">
1180<p>With all these fixes applied, our fully operational <code>tuple_cat</code> now looks like this:</p>
1181</div>
1182<div class="listingblock">
1183<div class="content">
1184<pre class="highlight"><code>template&lt;class L&gt; using F = mp_iota&lt;mp_size&lt;L&gt;&gt;;
1185
1186template&lt;class R, class...Is, class... Ks, class Tp&gt;
1187R tuple_cat_( mp_list&lt;Is...&gt;, mp_list&lt;Ks...&gt;, Tp tp )
1188{
1189    return R{ std::get&lt;Ks::value&gt;(std::get&lt;Is::value&gt;(std::move(tp)))... };
1190}
1191
1192template&lt;class T&gt; using remove_cv_ref = typename std::remove_cv&lt;
1193    typename std::remove_reference&lt;T&gt;::type&gt;::type;
1194
1195template&lt;class T, class I&gt; using tuple_element =
1196    typename std::tuple_element&lt;I::value, T&gt;::type;
1197
1198template&lt;class T&gt; using from_tuple_like =
1199    mp_product&lt;tuple_element, mp_list&lt;T&gt;, mp_iota&lt;std::tuple_size&lt;T&gt;&gt;&gt;;
1200
1201template&lt;class... Tp,
1202    class R = mp_append&lt;std::tuple&lt;&gt;, from_tuple_like&lt;remove_cv_ref&lt;Tp&gt;&gt;...&gt;&gt;
1203    R tuple_cat( Tp &amp;&amp;... tp )
1204{
1205    std::size_t const N = sizeof...(Tp);
1206
1207    // inner
1208
1209    using list1 = mp_list&lt;from_tuple_like&lt;remove_cv_ref&lt;Tp&gt;&gt;...&gt;;
1210    using list2 = mp_iota_c&lt;N&gt;;
1211
1212    using list3 = mp_transform&lt;mp_fill, list1, list2&gt;;
1213
1214    using inner = mp_apply&lt;mp_append, list3&gt;;
1215
1216    // outer
1217
1218    using list4 = mp_transform&lt;F, list1&gt;;
1219
1220    using outer = mp_apply&lt;mp_append, list4&gt;;
1221
1222    //
1223
1224    return tuple_cat_&lt;R&gt;( inner(), outer(),
1225        std::forward_as_tuple( std::forward&lt;Tp&gt;(tp)... ) );
1226}</code></pre>
1227</div>
1228</div>
1229</div>
1230<div class="sect2">
1231<h3 id="computing_return_types">Computing Return Types</h3>
1232<div class="paragraph">
1233<p>C&#43;&#43;17 has a standard variant type, called <code>std::variant</code>. It also defines a function template
1234<code>std::visit</code> that can be used to apply a function to the contained value of one or more variants.
1235So for instance, if the variant <code>v1</code> contains <code>1</code>, and the variant <code>v2</code> contains <code>2.0f</code>,
1236<code>std::visit(f, v1, v2)</code> will call <code>f(1, 2.0f)</code>.</p>
1237</div>
1238<div class="paragraph">
1239<p>However, <code>std::visit</code> has one limitation: it cannot return a result unless all
1240possible applications of the function have the same return type. If, for instance, <code>v1</code> and <code>v2</code>
1241are both of type <code>std::variant&lt;short, int, float&gt;</code>,</p>
1242</div>
1243<div class="literalblock">
1244<div class="content">
1245<pre>std::visit( []( auto const&amp; x, auto const&amp; y ){ return x + y; }, v1, v2 );</pre>
1246</div>
1247</div>
1248<div class="paragraph">
1249<p>will fail to compile because the result of <code>x + y</code> can be either <code>int</code> or <code>float</code> depending on
1250what <code>v1</code> and <code>v2</code> hold.</p>
1251</div>
1252<div class="paragraph">
1253<p>A type that can hold either <code>int</code> or <code>float</code> already exists, called, surprisingly enough, <code>std::variant&lt;int, float&gt;</code>.
1254Let&#8217;s write our own function template <code>rvisit</code> that is the same as <code>visit</code> but returns a <code>variant</code>:</p>
1255</div>
1256<div class="listingblock">
1257<div class="content">
1258<pre class="highlight"><code>template&lt;class F, class... V&gt; auto rvisit( F&amp;&amp; f, V&amp;&amp;... v )
1259{
1260    using R = /*...*/;
1261
1262    return std::visit( [&amp;]( auto&amp;&amp;... x )
1263        { return R( std::forward&lt;F&gt;(f)( std::forward&lt;decltype(x)&gt;(x)... ) ); },
1264        std::forward&lt;V&gt;( v )... );
1265}</code></pre>
1266</div>
1267</div>
1268<div class="paragraph">
1269<p>What this does is basically calls <code>std::visit</code> to do the work, but instead of passing it <code>f</code>, we pass a lambda that does the same as <code>f</code> except
1270it converts the result to a common type <code>R</code>. <code>R</code> is supposed to be <code>std::variant&lt;&#8230;&#8203;&gt;</code> where the ellipsis denotes the return types of
1271calling <code>f</code> with all possible combinations of variant values.</p>
1272</div>
1273<div class="paragraph">
1274<p>We&#8217;ll first define a helper quoted metafunction <code>Qret&lt;F&gt;</code> that returns the result of the application of <code>F</code> to arguments of type <code>T&#8230;&#8203;</code>:</p>
1275</div>
1276<div class="literalblock">
1277<div class="content">
1278<pre>template&lt;class F&gt; struct Qret
1279{
1280    template&lt;class... T&gt; using fn =
1281        decltype( std::declval&lt;F&gt;()( std::declval&lt;T&gt;()... ) );
1282};</pre>
1283</div>
1284</div>
1285<div class="paragraph">
1286<p>It turns out that C&#43;&#43;17 already contains a metafunction that returns the result of the application of a function <code>F</code> to arguments
1287of type <code>T&#8230;&#8203;</code>: <code>std::invoke_result_t&lt;F, T&#8230;&#8203;&gt;</code>. We can make use of it to simplify our <code>Qret</code> to</p>
1288</div>
1289<div class="literalblock">
1290<div class="content">
1291<pre>template&lt;class F&gt; struct Qret
1292{
1293    template&lt;class... T&gt; using fn = std::invoke_result_t&lt;F, T...&gt;;
1294};</pre>
1295</div>
1296</div>
1297<div class="paragraph">
1298<p>which in Mp11 can be expressed more concisely as</p>
1299</div>
1300<div class="literalblock">
1301<div class="content">
1302<pre>using Qret = mp_bind_front&lt;std::invoke_result_t, F&gt;;</pre>
1303</div>
1304</div>
1305<div class="paragraph">
1306<p>With <code>Qret</code> in hand, a <code>variant</code> of the possible return types is just a matter of applying it over the possible combinations of the variant values:</p>
1307</div>
1308<div class="literalblock">
1309<div class="content">
1310<pre>using R = mp_product_q&lt;Qret, remove_cv_ref&lt;V&gt;...&gt;;</pre>
1311</div>
1312</div>
1313<div class="paragraph">
1314<p>Why does this work? <code>mp_product&lt;F, L1&lt;T1&#8230;&#8203;&gt;, L2&lt;T2&#8230;&#8203;&gt;, &#8230;&#8203;, Ln&lt;Tn&#8230;&#8203;&gt;&gt;</code> returns <code>L1&lt;F&lt;U1, U2, &#8230;&#8203;, Un&gt;, &#8230;&#8203;&gt;</code>, where <code>Ui</code> traverse all
1315possible combinations of list values. Since in our case all <code>Li</code> are <code>std::variant</code>, the result will also be <code>std::variant</code>. (<code>mp_product_q</code> is
1316the same as <code>mp_product</code>, but for quoted metafunctions such as our <code>Qret</code>.)</p>
1317</div>
1318<div class="paragraph">
1319<p>One more step remains. Suppose that, as above, we&#8217;re passing two variants of type <code>std::variant&lt;short, int, float&gt;</code> and <code>F</code> is
1320<code>[]( auto const&amp; x, auto const&amp; y ){ return x + y; }</code>. This will generate <code>R</code> of length 9, one per each combination, but many of those
1321elements will be the same, either <code>int</code> or <code>float</code>, and we need to filter out the duplicates. So, we pass the result to <code>mp_unique</code>:</p>
1322</div>
1323<div class="literalblock">
1324<div class="content">
1325<pre>using R = mp_unique&lt;mp_product_q&lt;Qret, remove_cv_ref&lt;V&gt;...&gt;&gt;;</pre>
1326</div>
1327</div>
1328<div class="paragraph">
1329<p>and we&#8217;re done:</p>
1330</div>
1331<div class="listingblock">
1332<div class="content">
1333<pre class="highlight"><code>#include &lt;boost/mp11.hpp&gt;
1334#include &lt;boost/core/demangle.hpp&gt;
1335#include &lt;variant&gt;
1336#include &lt;type_traits&gt;
1337#include &lt;typeinfo&gt;
1338#include &lt;iostream&gt;
1339
1340using namespace boost::mp11;
1341
1342template&lt;class T&gt; using remove_cv_ref = typename std::remove_cv&lt;
1343    typename std::remove_reference&lt;T&gt;::type&gt;::type;
1344
1345template&lt;class F, class... V&gt; auto rvisit( F&amp;&amp; f, V&amp;&amp;... v )
1346{
1347    using Qret = mp_bind_front&lt;std::invoke_result_t, F&gt;;
1348
1349    using R = mp_unique&lt;mp_product_q&lt;Qret, remove_cv_ref&lt;V&gt;...&gt;&gt;;
1350
1351    return std::visit( [&amp;]( auto&amp;&amp;... x )
1352        { return R( std::forward&lt;F&gt;(f)( std::forward&lt;decltype(x)&gt;(x)... ) ); },
1353        std::forward&lt;V&gt;( v )... );
1354}
1355
1356template&lt;class T&gt; std::string name()
1357{
1358    return boost::core::demangle( typeid(T).name() );
1359}
1360
1361template&lt;class V&gt; void print_variant( char const * n, V const&amp; v )
1362{
1363    std::cout &lt;&lt; "(" &lt;&lt; name&lt;decltype(v)&gt;() &lt;&lt; ")" &lt;&lt; n &lt;&lt; ": ";
1364
1365    std::visit( []( auto const&amp; x )
1366        { std::cout &lt;&lt; "(" &lt;&lt; name&lt;decltype(x)&gt;() &lt;&lt; ")" &lt;&lt; x &lt;&lt; std::endl; }, v );
1367}
1368
1369int main()
1370{
1371    std::variant&lt;char, int, float&gt; v1( 1 );
1372
1373    print_variant( "v1", v1 );
1374
1375    std::variant&lt;short, int, double&gt; const v2( 3.14 );
1376
1377    print_variant( "v2", v2 );
1378
1379    auto v3 = rvisit( []( auto const&amp; x, auto const&amp; y ){ return x + y; }, v1, v2 );
1380
1381    print_variant( "v3", v3 );
1382}</code></pre>
1383</div>
1384</div>
1385</div>
1386</div>
1387</div>
1388<div class="sect1">
1389<h2 id="changelog">Revision History</h2>
1390<div class="sectionbody">
1391<div class="sect2">
1392<h3 id="changes_in_1_74_0">Changes in 1.74.0</h3>
1393<div class="ulist">
1394<ul>
1395<li>
1396<p>Improved compilation performance of <code>mp_with_index&lt;N&gt;</code> for large <code>N</code></p>
1397</li>
1398<li>
1399<p>Added <code>tuple_transform</code> (contributed by Hans Dembinski)</p>
1400</li>
1401</ul>
1402</div>
1403</div>
1404<div class="sect2">
1405<h3 id="changes_in_1_73_0">Changes in 1.73.0</h3>
1406<div class="ulist">
1407<ul>
1408<li>
1409<p>Added <code>mp_unique_if</code> (contributed by Kris Jusiak)</p>
1410</li>
1411<li>
1412<p>Added <code>mp_flatten</code></p>
1413</li>
1414<li>
1415<p>Added <code>mp_rotate_left</code>, <code>mp_rotate_right</code> (contributed by Duncan Barber)</p>
1416</li>
1417<li>
1418<p>Added <code>mp_compose</code></p>
1419</li>
1420<li>
1421<p>Added <code>mp_power_set</code></p>
1422</li>
1423<li>
1424<p>Added <code>mp_partial_sum</code></p>
1425</li>
1426<li>
1427<p>Added <code>mp_iterate</code></p>
1428</li>
1429</ul>
1430</div>
1431</div>
1432<div class="sect2">
1433<h3 id="changes_in_1_70_0">Changes in 1.70.0</h3>
1434<div class="ulist">
1435<ul>
1436<li>
1437<p>Renamed <code>mp_invoke</code> to <code>mp_invoke_q</code></p>
1438</li>
1439<li>
1440<p>Added <code>mp_similar</code></p>
1441</li>
1442<li>
1443<p>Added <code>mp_set_union</code>, <code>mp_set_intersection</code>, <code>mp_set_difference</code></p>
1444</li>
1445<li>
1446<p>Added <code>mp_not_fn</code></p>
1447</li>
1448<li>
1449<p>Added <code>mp_transform_first</code>, <code>mp_transform_second</code>, <code>mp_transform_third</code></p>
1450</li>
1451<li>
1452<p>Added <code>mp_filter</code></p>
1453</li>
1454<li>
1455<p>Added <code>mp_eval_if_not</code>, <code>mp_eval_or</code>, <code>mp_valid_q</code></p>
1456</li>
1457<li>
1458<p>Added <code>mp_back</code>, <code>mp_pop_back</code></p>
1459</li>
1460<li>
1461<p>Added <code>BOOST_MP11_VERSION</code></p>
1462</li>
1463</ul>
1464</div>
1465</div>
1466<div class="sect2">
1467<h3 id="changes_in_1_69_0">Changes in 1.69.0</h3>
1468<div class="ulist">
1469<ul>
1470<li>
1471<p>Removed dependency on Boost.Config; Mp11 is now standalone</p>
1472</li>
1473<li>
1474<p>Improved code generation for <code>mp_with_index</code></p>
1475</li>
1476<li>
1477<p>Added <code>mp_starts_with</code> (contributed by Glen Fernandes)</p>
1478</li>
1479<li>
1480<p>Added CMake support</p>
1481</li>
1482</ul>
1483</div>
1484</div>
1485</div>
1486</div>
1487<div class="sect1">
1488<h2 id="reference">Reference</h2>
1489<div class="sectionbody">
1490<div class="paragraph">
1491<p>The contents of the library are in namespace <code>boost::mp11</code>.</p>
1492</div>
1493<div class="sect2">
1494<h3 id="integral">Integral Constants, &lt;boost/mp11/integral.hpp&gt;</h3>
1495<div class="paragraph">
1496<p>For an Mp11 integral constant type <code>T</code>, <code>T::value</code> is an integral constant in the C++ sense.</p>
1497</div>
1498<div class="sect3">
1499<h4 id="mp_boolb">mp_bool&lt;B&gt;</h4>
1500<div class="literalblock">
1501<div class="content">
1502<pre>template&lt;bool B&gt; using mp_bool = std::integral_constant&lt;bool, B&gt;;</pre>
1503</div>
1504</div>
1505<div class="paragraph">
1506<p>Same as <code>std::bool_constant</code> in C++17.</p>
1507</div>
1508</div>
1509<div class="sect3">
1510<h4 id="mp_true">mp_true</h4>
1511<div class="literalblock">
1512<div class="content">
1513<pre>using mp_true = mp_bool&lt;true&gt;;</pre>
1514</div>
1515</div>
1516<div class="paragraph">
1517<p>Same as <code>std::true_type</code>.</p>
1518</div>
1519</div>
1520<div class="sect3">
1521<h4 id="mp_false">mp_false</h4>
1522<div class="literalblock">
1523<div class="content">
1524<pre>using mp_false = mp_bool&lt;false&gt;;</pre>
1525</div>
1526</div>
1527<div class="paragraph">
1528<p>Same as <code>std::false_type</code>.</p>
1529</div>
1530</div>
1531<div class="sect3">
1532<h4 id="mp_to_boolt">mp_to_bool&lt;T&gt;</h4>
1533<div class="literalblock">
1534<div class="content">
1535<pre>template&lt;class T&gt; using mp_to_bool = mp_bool&lt;static_cast&lt;bool&gt;(T::value)&gt;;</pre>
1536</div>
1537</div>
1538</div>
1539<div class="sect3">
1540<h4 id="mp_nott">mp_not&lt;T&gt;</h4>
1541<div class="literalblock">
1542<div class="content">
1543<pre>template&lt;class T&gt; using mp_not = mp_bool&lt; !T::value &gt;;</pre>
1544</div>
1545</div>
1546</div>
1547<div class="sect3">
1548<h4 id="mp_inti">mp_int&lt;I&gt;</h4>
1549<div class="literalblock">
1550<div class="content">
1551<pre>template&lt;int I&gt; using mp_int = std::integral_constant&lt;int, I&gt;;</pre>
1552</div>
1553</div>
1554</div>
1555<div class="sect3">
1556<h4 id="mp_size_tn">mp_size_t&lt;N&gt;</h4>
1557<div class="literalblock">
1558<div class="content">
1559<pre>template&lt;std::size_t N&gt; using mp_size_t = std::integral_constant&lt;std::size_t, N&gt;;</pre>
1560</div>
1561</div>
1562</div>
1563</div>
1564<div class="sect2">
1565<h3 id="list">List Operations, &lt;boost/mp11/list.hpp&gt;</h3>
1566<div class="sect3">
1567<h4 id="mp_listt">mp_list&lt;T&#8230;&#8203;&gt;</h4>
1568<div class="literalblock">
1569<div class="content">
1570<pre>template&lt;class... T&gt; struct mp_list {};</pre>
1571</div>
1572</div>
1573<div class="paragraph">
1574<p><code>mp_list</code> is the standard list type of Mp11, although the library is not restricted to it and can operate on arbitrary class templates
1575such as <code>std::tuple</code> or <code>std::variant</code>. Even <code>std::pair</code> can be used if the transformation does not alter the number of the elements in
1576the list.</p>
1577</div>
1578</div>
1579<div class="sect3">
1580<h4 id="mp_list_ct_i">mp_list_c&lt;T, I&#8230;&#8203;&gt;</h4>
1581<div class="literalblock">
1582<div class="content">
1583<pre>template&lt;class T, T... I&gt; using mp_list_c =
1584    mp_list&lt;std::integral_constant&lt;T, I&gt;...&gt;;</pre>
1585</div>
1586</div>
1587<div class="paragraph">
1588<p><code>mp_list_c</code> produces an <code>mp_list</code> of the <code>std::integral_constant</code> types corresponding to its integer template arguments.</p>
1589</div>
1590<div class="listingblock">
1591<div class="title">Code Example 1. Using mp_list_c</div>
1592<div class="content">
1593<pre class="highlight"><code>using L1 = mp_list_c&lt;int, 2, 3&gt;; // mp_list&lt;mp_int&lt;2&gt;, mp_int&lt;3&gt;&gt;</code></pre>
1594</div>
1595</div>
1596</div>
1597<div class="sect3">
1598<h4 id="mp_is_listl">mp_is_list&lt;L&gt;</h4>
1599<div class="literalblock">
1600<div class="content">
1601<pre>template&lt;class L&gt; using mp_is_list = /*...*/;</pre>
1602</div>
1603</div>
1604<div class="paragraph">
1605<p><code>mp_is_list&lt;L&gt;</code> is <code>mp_true</code> if <code>L</code> is a list (an instantiation of a class template whose template parameters are types), <code>mp_false</code> otherwise.</p>
1606</div>
1607</div>
1608<div class="sect3">
1609<h4 id="mp_sizel">mp_size&lt;L&gt;</h4>
1610<div class="literalblock">
1611<div class="content">
1612<pre>template&lt;class L&gt; using mp_size = /*...*/;</pre>
1613</div>
1614</div>
1615<div class="paragraph">
1616<p><code>mp_size&lt;L&gt;</code> returns the number of elements in the list <code>L</code>, as a <code>mp_size_t</code>. In other words, <code>mp_size&lt;L&lt;T&#8230;&#8203;&gt;&gt;</code> is an alias for
1617<code>mp_size_t&lt;sizeof&#8230;&#8203;(T)&gt;</code>.</p>
1618</div>
1619<div class="listingblock">
1620<div class="title">Code Example 2. Using mp_size with mp_list</div>
1621<div class="content">
1622<pre class="highlight"><code>using L1 = mp_list&lt;&gt;;
1623using R1 = mp_size&lt;L1&gt;; // mp_size_t&lt;0&gt;</code></pre>
1624</div>
1625</div>
1626<div class="listingblock">
1627<div class="title">Code Example 3. Using mp_size with std::pair</div>
1628<div class="content">
1629<pre class="highlight"><code>using L2 = std::pair&lt;int, int&gt;;
1630using R2 = mp_size&lt;L2&gt;; // mp_size_t&lt;2&gt;</code></pre>
1631</div>
1632</div>
1633<div class="listingblock">
1634<div class="title">Code Example 4. Using mp_size with std::tuple</div>
1635<div class="content">
1636<pre class="highlight"><code>using L3 = std::tuple&lt;float&gt;;
1637using R3 = mp_size&lt;L3&gt;; // mp_size_t&lt;1&gt;</code></pre>
1638</div>
1639</div>
1640</div>
1641<div class="sect3">
1642<h4 id="mp_emptyl">mp_empty&lt;L&gt;</h4>
1643<div class="literalblock">
1644<div class="content">
1645<pre>template&lt;class L&gt; using mp_empty = mp_bool&lt;mp_size&lt;L&gt;::value == 0&gt;;</pre>
1646</div>
1647</div>
1648<div class="paragraph">
1649<p><code>mp_empty&lt;L&gt;</code> is an alias for <code>mp_true</code> if the list <code>L</code> is empty, for <code>mp_false</code> otherwise.</p>
1650</div>
1651<div class="listingblock">
1652<div class="title">Code Example 5. Using mp_empty with std::tuple</div>
1653<div class="content">
1654<pre class="highlight"><code>using L1 = std::tuple&lt;float&gt;;
1655using R1 = mp_empty&lt;L1&gt;; // mp_false
1656
1657using L2 = std::tuple&lt;&gt;;
1658using R2 = mp_empty&lt;L2&gt;; // mp_true</code></pre>
1659</div>
1660</div>
1661</div>
1662<div class="sect3">
1663<h4 id="mp_assignl1_l2">mp_assign&lt;L1, L2&gt;</h4>
1664<div class="literalblock">
1665<div class="content">
1666<pre>template&lt;class L1, class L2&gt; using mp_assign = /*...*/;</pre>
1667</div>
1668</div>
1669<div class="paragraph">
1670<p><code>mp_assign&lt;L1&lt;T1&#8230;&#8203;&gt;, L2&lt;T2&#8230;&#8203;&gt;&gt;</code> is an alias for <code>L1&lt;T2&#8230;&#8203;&gt;</code>. That is, it replaces the elements of <code>L1</code> with those of <code>L2</code>.</p>
1671</div>
1672<div class="listingblock">
1673<div class="title">Code Example 6. Using mp_assign with mp_list and std::tuple</div>
1674<div class="content">
1675<pre class="highlight"><code>using L1 = std::tuple&lt;long&gt;;
1676using L2 = mp_list&lt;int, float&gt;;
1677
1678using R1 = mp_assign&lt;L1, L2&gt;; // std::tuple&lt;int, float&gt;</code></pre>
1679</div>
1680</div>
1681<div class="listingblock">
1682<div class="title">Code Example 7. Using mp_assign with mp_list and std::pair</div>
1683<div class="content">
1684<pre class="highlight"><code>using L1 = std::pair&lt;long, char&gt;;
1685using L2 = mp_list&lt;int, float&gt;;
1686
1687using R1 = mp_assign&lt;L1, L2&gt;; // std::pair&lt;int, float&gt;</code></pre>
1688</div>
1689</div>
1690</div>
1691<div class="sect3">
1692<h4 id="mp_clearl">mp_clear&lt;L&gt;</h4>
1693<div class="literalblock">
1694<div class="content">
1695<pre>template&lt;class L&gt; using mp_clear = mp_assign&lt;L, mp_list&lt;&gt;&gt;;</pre>
1696</div>
1697</div>
1698<div class="paragraph">
1699<p><code>mp_clear&lt;L&lt;T&#8230;&#8203;&gt;&gt;</code> is an alias for <code>L&lt;&gt;</code>, that is, it removes the elements of <code>L</code>.</p>
1700</div>
1701<div class="listingblock">
1702<div class="title">Code Example 8. Using mp_clear with std::tuple</div>
1703<div class="content">
1704<pre class="highlight"><code>using L1 = std::tuple&lt;int, float&gt;;
1705using R1 = mp_clear&lt;L1&gt;; // std::tuple&lt;&gt;</code></pre>
1706</div>
1707</div>
1708</div>
1709<div class="sect3">
1710<h4 id="mp_frontl">mp_front&lt;L&gt;</h4>
1711<div class="literalblock">
1712<div class="content">
1713<pre>template&lt;class L&gt; using mp_front = /*...*/;</pre>
1714</div>
1715</div>
1716<div class="paragraph">
1717<p><code>mp_front&lt;L&gt;</code> is the first element of the list <code>L</code>. That is, <code>mp_front&lt;L&lt;T1, T&#8230;&#8203;&gt;&gt;</code> is an alias for <code>T1</code>.</p>
1718</div>
1719<div class="listingblock">
1720<div class="title">Code Example 9. Using mp_front with std::pair</div>
1721<div class="content">
1722<pre class="highlight"><code>using L1 = std::pair&lt;int, float&gt;;
1723using R1 = mp_front&lt;L1&gt;; // int</code></pre>
1724</div>
1725</div>
1726<div class="listingblock">
1727<div class="title">Code Example 10. Using mp_front with std::tuple</div>
1728<div class="content">
1729<pre class="highlight"><code>using L2 = std::tuple&lt;float, double, long double&gt;;
1730using R2 = mp_front&lt;L2&gt;; // float</code></pre>
1731</div>
1732</div>
1733<div class="listingblock">
1734<div class="title">Code Example 11. Using mp_front with mp_list</div>
1735<div class="content">
1736<pre class="highlight"><code>using L3 = mp_list&lt;char[1], char[2], char[3], char[4]&gt;;
1737using R3 = mp_front&lt;L3&gt;; // char[1]</code></pre>
1738</div>
1739</div>
1740</div>
1741<div class="sect3">
1742<h4 id="mp_pop_frontl">mp_pop_front&lt;L&gt;</h4>
1743<div class="literalblock">
1744<div class="content">
1745<pre>template&lt;class L&gt; using mp_pop_front = /*...*/;</pre>
1746</div>
1747</div>
1748<div class="paragraph">
1749<p><code>mp_pop_front&lt;L&gt;</code> removes the first element of the list <code>L</code>. That is, <code>mp_pop_front&lt;L&lt;T1, T&#8230;&#8203;&gt;&gt;</code> is an alias for <code>L&lt;T&#8230;&#8203;&gt;</code>.</p>
1750</div>
1751<div class="listingblock">
1752<div class="title">Code Example 12. Using mp_pop_front with std::tuple</div>
1753<div class="content">
1754<pre class="highlight"><code>using L1 = std::tuple&lt;float, double, long double&gt;;
1755using R1 = mp_pop_front&lt;L1&gt;; // std::tuple&lt;double, long double&gt;</code></pre>
1756</div>
1757</div>
1758<div class="listingblock">
1759<div class="title">Code Example 13. Using mp_pop_front with mp_list</div>
1760<div class="content">
1761<pre class="highlight"><code>using L2 = mp_list&lt;void&gt;;
1762using R2 = mp_pop_front&lt;L2&gt;; // mp_list&lt;&gt;</code></pre>
1763</div>
1764</div>
1765</div>
1766<div class="sect3">
1767<h4 id="mp_firstl">mp_first&lt;L&gt;</h4>
1768<div class="literalblock">
1769<div class="content">
1770<pre>template&lt;class L&gt; using mp_first = mp_front&lt;L&gt;;</pre>
1771</div>
1772</div>
1773<div class="paragraph">
1774<p><code>mp_first</code> is another name for <code>mp_front</code>.</p>
1775</div>
1776</div>
1777<div class="sect3">
1778<h4 id="mp_restl">mp_rest&lt;L&gt;</h4>
1779<div class="literalblock">
1780<div class="content">
1781<pre>template&lt;class L&gt; using mp_rest = mp_pop_front&lt;L&gt;;</pre>
1782</div>
1783</div>
1784<div class="paragraph">
1785<p><code>mp_rest</code> is another name for <code>mp_pop_front</code>.</p>
1786</div>
1787</div>
1788<div class="sect3">
1789<h4 id="mp_secondl">mp_second&lt;L&gt;</h4>
1790<div class="literalblock">
1791<div class="content">
1792<pre>template&lt;class L&gt; using mp_second = /*...*/;</pre>
1793</div>
1794</div>
1795<div class="paragraph">
1796<p><code>mp_second&lt;L&gt;</code> is the second element of the list <code>L</code>. That is, <code>mp_second&lt;L&lt;T1, T2, T&#8230;&#8203;&gt;&gt;</code> is an alias for <code>T2</code>.</p>
1797</div>
1798<div class="listingblock">
1799<div class="title">Code Example 14. Using mp_second with std::pair</div>
1800<div class="content">
1801<pre class="highlight"><code>using L1 = std::pair&lt;int, float&gt;;
1802using R1 = mp_second&lt;L1&gt;; // float</code></pre>
1803</div>
1804</div>
1805<div class="listingblock">
1806<div class="title">Code Example 15. Using mp_second with std::tuple</div>
1807<div class="content">
1808<pre class="highlight"><code>using L2 = std::tuple&lt;float, double, long double&gt;;
1809using R2 = mp_second&lt;L2&gt;; // double</code></pre>
1810</div>
1811</div>
1812<div class="listingblock">
1813<div class="title">Code Example 16. Using mp_second with mp_list</div>
1814<div class="content">
1815<pre class="highlight"><code>using L3 = mp_list&lt;char[1], char[2], char[3], char[4]&gt;;
1816using R3 = mp_second&lt;L3&gt;; // char[2]</code></pre>
1817</div>
1818</div>
1819</div>
1820<div class="sect3">
1821<h4 id="mp_thirdl">mp_third&lt;L&gt;</h4>
1822<div class="literalblock">
1823<div class="content">
1824<pre>template&lt;class L&gt; using mp_third = /*...*/;</pre>
1825</div>
1826</div>
1827<div class="paragraph">
1828<p><code>mp_third&lt;L&gt;</code> is the third element of the list <code>L</code>. That is, <code>mp_third&lt;L&lt;T1, T2, T3, T&#8230;&#8203;&gt;&gt;</code> is an alias for <code>T3</code>.</p>
1829</div>
1830<div class="listingblock">
1831<div class="title">Code Example 17. Using mp_third with std::tuple</div>
1832<div class="content">
1833<pre class="highlight"><code>using L1 = std::tuple&lt;float, double, long double&gt;;
1834using R1 = mp_third&lt;L1&gt;; // long double</code></pre>
1835</div>
1836</div>
1837<div class="listingblock">
1838<div class="title">Code Example 18. Using mp_third with mp_list</div>
1839<div class="content">
1840<pre class="highlight"><code>using L2 = mp_list&lt;char[1], char[2], char[3], char[4]&gt;;
1841using R2 = mp_third&lt;L2&gt;; // char[3]</code></pre>
1842</div>
1843</div>
1844</div>
1845<div class="sect3">
1846<h4 id="mp_push_frontl_t">mp_push_front&lt;L, T&#8230;&#8203;&gt;</h4>
1847<div class="literalblock">
1848<div class="content">
1849<pre>template&lt;class L, class... T&gt; using mp_push_front = /*...*/;</pre>
1850</div>
1851</div>
1852<div class="paragraph">
1853<p><code>mp_push_front&lt;L, T&#8230;&#8203;&gt;</code> inserts the elements <code>T&#8230;&#8203;</code> at the front of the list <code>L</code>. That is, <code>mp_push_front&lt;L&lt;U&#8230;&#8203;&gt;, T&#8230;&#8203;&gt;</code>
1854is an alias for <code>L&lt;T&#8230;&#8203;, U&#8230;&#8203;&gt;</code>.</p>
1855</div>
1856<div class="listingblock">
1857<div class="title">Code Example 19. Using mp_push_front with std::tuple</div>
1858<div class="content">
1859<pre class="highlight"><code>using L1 = std::tuple&lt;double, long double&gt;;
1860using R1 = mp_push_front&lt;L1, float&gt;; // std::tuple&lt;float, double, long double&gt;</code></pre>
1861</div>
1862</div>
1863<div class="listingblock">
1864<div class="title">Code Example 20. Using mp_push_front with mp_list</div>
1865<div class="content">
1866<pre class="highlight"><code>using L2 = mp_list&lt;void&gt;;
1867using R2 = mp_push_front&lt;L2, char[1], char[2]&gt;; // mp_list&lt;char[1], char[2], void&gt;</code></pre>
1868</div>
1869</div>
1870</div>
1871<div class="sect3">
1872<h4 id="mp_push_backl_t">mp_push_back&lt;L, T&#8230;&#8203;&gt;</h4>
1873<div class="literalblock">
1874<div class="content">
1875<pre>template&lt;class L, class... T&gt; using mp_push_back = /*...*/;</pre>
1876</div>
1877</div>
1878<div class="paragraph">
1879<p><code>mp_push_back&lt;L, T&#8230;&#8203;&gt;</code> inserts the elements <code>T&#8230;&#8203;</code> at the back of the list <code>L</code>. That is, <code>mp_push_back&lt;L&lt;U&#8230;&#8203;&gt;, T&#8230;&#8203;&gt;</code>
1880is an alias for <code>L&lt;U&#8230;&#8203;, T&#8230;&#8203;&gt;</code>.</p>
1881</div>
1882<div class="listingblock">
1883<div class="title">Code Example 21. Using mp_push_back with std::tuple</div>
1884<div class="content">
1885<pre class="highlight"><code>using L1 = std::tuple&lt;double, long double&gt;;
1886using R1 = mp_push_back&lt;L1, float&gt;; // std::tuple&lt;double, long double, float&gt;</code></pre>
1887</div>
1888</div>
1889<div class="listingblock">
1890<div class="title">Code Example 22. Using mp_push_back with mp_list</div>
1891<div class="content">
1892<pre class="highlight"><code>using L2 = mp_list&lt;void&gt;;
1893using R2 = mp_push_back&lt;L2, char[1], char[2]&gt;; // mp_list&lt;void, char[1], char[2]&gt;</code></pre>
1894</div>
1895</div>
1896</div>
1897<div class="sect3">
1898<h4 id="mp_renamel_y">mp_rename&lt;L, Y&gt;</h4>
1899<div class="literalblock">
1900<div class="content">
1901<pre>template&lt;class L, template&lt;class...&gt; class Y&gt; using mp_rename = /*...*/;</pre>
1902</div>
1903</div>
1904<div class="paragraph">
1905<p><code>mp_rename&lt;L, Y&gt;</code> changes the type of the list <code>L</code> to <code>Y</code>. That is, <code>mp_rename&lt;L&lt;T&#8230;&#8203;&gt;, Y&gt;</code> is an alias for <code>Y&lt;T&#8230;&#8203;&gt;</code>.</p>
1906</div>
1907<div class="listingblock">
1908<div class="title">Code Example 23. Using mp_rename to rename std::pair to std::tuple</div>
1909<div class="content">
1910<pre class="highlight"><code>using L1 = std::pair&lt;double, long double&gt;;
1911using R1 = mp_rename&lt;L1, std::tuple&gt;; // std::tuple&lt;double, long double&gt;</code></pre>
1912</div>
1913</div>
1914<div class="listingblock">
1915<div class="title">Code Example 24. Using mp_rename to rename std::tuple to mp_list</div>
1916<div class="content">
1917<pre class="highlight"><code>using L2 = std::tuple&lt;void&gt;;
1918using R2 = mp_rename&lt;L2, mp_list&gt;; // mp_list&lt;void&gt;</code></pre>
1919</div>
1920</div>
1921</div>
1922<div class="sect3">
1923<h4 id="mp_applyf_l">mp_apply&lt;F, L&gt;</h4>
1924<div class="literalblock">
1925<div class="content">
1926<pre>template&lt;template&lt;class...&gt; class F, class L&gt; using mp_apply = mp_rename&lt;L, F&gt;;</pre>
1927</div>
1928</div>
1929<div class="paragraph">
1930<p><code>mp_apply&lt;F, L&gt;</code> applies the metafunction <code>F</code> to the contents of the list <code>L</code>, that is, <code>mp_apply&lt;F, L&lt;T&#8230;&#8203;&gt;&gt;</code> is an alias for <code>F&lt;T&#8230;&#8203;&gt;</code>.
1931(<code>mp_apply</code> is the same as <code>mp_rename</code> with the arguments reversed.)</p>
1932</div>
1933<div class="listingblock">
1934<div class="title">Code Example 25. Using mp_apply with std::pair</div>
1935<div class="content">
1936<pre class="highlight"><code>using L1 = std::pair&lt;double, long double&gt;;
1937using R1 = mp_apply&lt;std::is_same, L1&gt;; // std::is_same&lt;double, long double&gt;</code></pre>
1938</div>
1939</div>
1940</div>
1941<div class="sect3">
1942<h4 id="mp_apply_qq_l">mp_apply_q&lt;Q, L&gt;</h4>
1943<div class="literalblock">
1944<div class="content">
1945<pre>template&lt;class Q, class L&gt; using mp_apply_q = mp_apply&lt;Q::template fn, L&gt;;</pre>
1946</div>
1947</div>
1948<div class="paragraph">
1949<p>Same as <code>mp_apply</code>, but takes a quoted metafunction.</p>
1950</div>
1951<div class="listingblock">
1952<div class="title">Code Example 26. Using mp_apply_q with mp_bind_front</div>
1953<div class="content">
1954<pre class="highlight"><code>using L1 = std::tuple&lt;double, long double&gt;;
1955using L2 = mp_list&lt;int, long&gt;;
1956
1957using R1 = mp_apply_q&lt;mp_bind_front&lt;mp_push_back, L1&gt;, L2&gt;;
1958  // R1 is std::tuple&lt;double, long double, int, long&gt;</code></pre>
1959</div>
1960</div>
1961</div>
1962<div class="sect3">
1963<h4 id="mp_appendl">mp_append&lt;L&#8230;&#8203;&gt;</h4>
1964<div class="literalblock">
1965<div class="content">
1966<pre>template&lt;class... L&gt; using mp_append = /*...*/;</pre>
1967</div>
1968</div>
1969<div class="paragraph">
1970<p><code>mp_append&lt;L&#8230;&#8203;&gt;</code> concatenates the lists in <code>L&#8230;&#8203;</code> into a single list that has the same type as the first list. <code>mp_append&lt;&gt;</code>
1971is an alias for <code>mp_list&lt;&gt;</code>. <code>mp_append&lt;L1&lt;T1&#8230;&#8203;&gt;, L2&lt;T2&#8230;&#8203;&gt;, &#8230;&#8203;, Ln&lt;Tn&#8230;&#8203;&gt;&gt;</code> is an alias for <code>L1&lt;T1&#8230;&#8203;, T2&#8230;&#8203;, &#8230;&#8203;, Tn&#8230;&#8203;&gt;</code>.</p>
1972</div>
1973<div class="listingblock">
1974<div class="title">Code Example 27. Using mp_append with lists of various types</div>
1975<div class="content">
1976<pre class="highlight"><code>using L1 = std::tuple&lt;double, long double&gt;;
1977using L2 = mp_list&lt;int&gt;;
1978using L3 = std::pair&lt;short, long&gt;;
1979using L4 = mp_list&lt;&gt;;
1980
1981using R1 = mp_append&lt;L1, L2, L3, L4&gt;;
1982  // std::tuple&lt;double, long double, int, short, long&gt;</code></pre>
1983</div>
1984</div>
1985</div>
1986<div class="sect3">
1987<h4 id="mp_replace_frontl_t">mp_replace_front&lt;L, T&gt;</h4>
1988<div class="literalblock">
1989<div class="content">
1990<pre>template&lt;class L, class T&gt; using mp_replace_front = /*...*/;</pre>
1991</div>
1992</div>
1993<div class="paragraph">
1994<p><code>mp_replace_front&lt;L, T&gt;</code> replaces the first element of the list <code>L</code> with <code>T</code>. That is, <code>mp_replace_front&lt;L&lt;U1, U&#8230;&#8203;&gt;, T&gt;</code> is
1995an alias for <code>L&lt;T, U&#8230;&#8203;&gt;</code>.</p>
1996</div>
1997<div class="listingblock">
1998<div class="title">Code Example 28. Using mp_replace_front with std::pair</div>
1999<div class="content">
2000<pre class="highlight"><code>using L1 = std::pair&lt;int, float&gt;;
2001using R1 = mp_replace_front&lt;L1, void&gt;; // std::pair&lt;void, float&gt;</code></pre>
2002</div>
2003</div>
2004<div class="listingblock">
2005<div class="title">Code Example 29. Using mp_replace_front with std::tuple</div>
2006<div class="content">
2007<pre class="highlight"><code>using L2 = std::tuple&lt;float, double, long double&gt;;
2008using R2 = mp_replace_front&lt;L2, void&gt;; // std::tuple&lt;void, double, long double&gt;</code></pre>
2009</div>
2010</div>
2011<div class="listingblock">
2012<div class="title">Code Example 30. Using mp_replace_front with mp_list</div>
2013<div class="content">
2014<pre class="highlight"><code>using L3 = mp_list&lt;char[1], char[2], char[3], char[4]&gt;;
2015using R3 = mp_replace_front&lt;L3, void&gt;; // mp_list&lt;void, char[2], char[3], char[4]&gt;;</code></pre>
2016</div>
2017</div>
2018</div>
2019<div class="sect3">
2020<h4 id="mp_replace_firstl_t">mp_replace_first&lt;L, T&gt;</h4>
2021<div class="literalblock">
2022<div class="content">
2023<pre>template&lt;class L, class T&gt; using mp_replace_first = mp_replace_front&lt;L, T&gt;;</pre>
2024</div>
2025</div>
2026<div class="paragraph">
2027<p><code>mp_replace_first</code> is another name for <code>mp_replace_front</code>.</p>
2028</div>
2029</div>
2030<div class="sect3">
2031<h4 id="mp_replace_secondl_t">mp_replace_second&lt;L, T&gt;</h4>
2032<div class="literalblock">
2033<div class="content">
2034<pre>template&lt;class L, class T&gt; using mp_replace_second = /*...*/;</pre>
2035</div>
2036</div>
2037<div class="paragraph">
2038<p><code>mp_replace_second&lt;L, T&gt;</code> replaces the second element of the list <code>L</code> with <code>T</code>. That is, <code>mp_replace_second&lt;L&lt;U1, U2, U&#8230;&#8203;&gt;, T&gt;</code>
2039is an alias for <code>L&lt;U1, T, U&#8230;&#8203;&gt;</code>.</p>
2040</div>
2041<div class="listingblock">
2042<div class="title">Code Example 31. Using mp_replace_second with std::pair</div>
2043<div class="content">
2044<pre class="highlight"><code>using L1 = std::pair&lt;int, float&gt;;
2045using R1 = mp_replace_second&lt;L1, void&gt;; // std::pair&lt;int, void&gt;</code></pre>
2046</div>
2047</div>
2048<div class="listingblock">
2049<div class="title">Code Example 32. Using mp_replace_second with std::tuple</div>
2050<div class="content">
2051<pre class="highlight"><code>using L2 = std::tuple&lt;float, double, long double&gt;;
2052using R2 = mp_replace_second&lt;L2, void&gt;; // std::tuple&lt;float, void, long double&gt;</code></pre>
2053</div>
2054</div>
2055<div class="listingblock">
2056<div class="title">Code Example 33. Using mp_replace_front with mp_list</div>
2057<div class="content">
2058<pre class="highlight"><code>using L3 = mp_list&lt;char[1], char[2], char[3], char[4]&gt;;
2059using R3 = mp_replace_second&lt;L3, void&gt;; // mp_list&lt;char[1], void, char[3], char[4]&gt;;</code></pre>
2060</div>
2061</div>
2062</div>
2063<div class="sect3">
2064<h4 id="mp_replace_thirdl_t">mp_replace_third&lt;L, T&gt;</h4>
2065<div class="literalblock">
2066<div class="content">
2067<pre>template&lt;class L, class T&gt; using mp_replace_third = /*...*/;</pre>
2068</div>
2069</div>
2070<div class="paragraph">
2071<p><code>mp_replace_third&lt;L, T&gt;</code> replaces the third element of the list <code>L</code> with <code>T</code>. That is, <code>mp_replace_third&lt;L&lt;U1, U2, U3, U&#8230;&#8203;&gt;, T&gt;</code>
2072is an alias for <code>L&lt;U1, U2, T, U&#8230;&#8203;&gt;</code>.</p>
2073</div>
2074<div class="listingblock">
2075<div class="title">Code Example 34. Using mp_replace_third with std::tuple</div>
2076<div class="content">
2077<pre class="highlight"><code>using L1 = std::tuple&lt;float, double, long double&gt;;
2078using R1 = mp_replace_third&lt;L1, void&gt;; // std::tuple&lt;float, double, void&gt;</code></pre>
2079</div>
2080</div>
2081<div class="listingblock">
2082<div class="title">Code Example 35. Using mp_replace_third with mp_list</div>
2083<div class="content">
2084<pre class="highlight"><code>using L2 = mp_list&lt;char[1], char[2], char[3], char[4]&gt;;
2085using R2 = mp_replace_third&lt;L2, void&gt;; // mp_list&lt;char[1], char[2], void, char[4]&gt;;</code></pre>
2086</div>
2087</div>
2088</div>
2089<div class="sect3">
2090<h4 id="mp_transform_frontl_f">mp_transform_front&lt;L, F&gt;</h4>
2091<div class="literalblock">
2092<div class="content">
2093<pre>template&lt;class L, template&lt;class...&gt; class F&gt; using mp_transform_front =
2094    /*...*/;</pre>
2095</div>
2096</div>
2097<div class="paragraph">
2098<p><code>mp_transform_front&lt;L, F&gt;</code> replaces the first element <code>T1</code> of the list <code>L</code> with <code>F&lt;T1&gt;</code>.</p>
2099</div>
2100</div>
2101<div class="sect3">
2102<h4 id="mp_transform_front_ql_q">mp_transform_front_q&lt;L, Q&gt;</h4>
2103<div class="literalblock">
2104<div class="content">
2105<pre>template&lt;class L, class Q&gt; using mp_transform_front_q =
2106    mp_transform_front&lt;L, Q::template fn&gt;;</pre>
2107</div>
2108</div>
2109<div class="paragraph">
2110<p>As <code>mp_transform_front</code>, but takes a quoted metafunction.</p>
2111</div>
2112</div>
2113<div class="sect3">
2114<h4 id="mp_transform_firstl_f">mp_transform_first&lt;L, F&gt;</h4>
2115<div class="literalblock">
2116<div class="content">
2117<pre>template&lt;class L, template&lt;class...&gt; class F&gt; using mp_transform_first =
2118    mp_transform_front&lt;L, F&gt;;</pre>
2119</div>
2120</div>
2121<div class="paragraph">
2122<p><code>mp_transform_first</code> is another name for <code>mp_transform_front</code>.</p>
2123</div>
2124</div>
2125<div class="sect3">
2126<h4 id="mp_transform_first_ql_q">mp_transform_first_q&lt;L, Q&gt;</h4>
2127<div class="literalblock">
2128<div class="content">
2129<pre>template&lt;class L, class Q&gt; using mp_transform_first_q =
2130    mp_transform_first&lt;L, Q::template fn&gt;;</pre>
2131</div>
2132</div>
2133<div class="paragraph">
2134<p>As <code>mp_transform_first</code>, but takes a quoted metafunction.</p>
2135</div>
2136</div>
2137<div class="sect3">
2138<h4 id="mp_transform_secondl_f">mp_transform_second&lt;L, F&gt;</h4>
2139<div class="literalblock">
2140<div class="content">
2141<pre>template&lt;class L, template&lt;class...&gt; class F&gt; using mp_transform_second =
2142    /*...*/;</pre>
2143</div>
2144</div>
2145<div class="paragraph">
2146<p><code>mp_transform_second&lt;L, F&gt;</code> replaces the second element <code>T2</code> of the list <code>L</code> with <code>F&lt;T2&gt;</code>.</p>
2147</div>
2148</div>
2149<div class="sect3">
2150<h4 id="mp_transform_second_ql_q">mp_transform_second_q&lt;L, Q&gt;</h4>
2151<div class="literalblock">
2152<div class="content">
2153<pre>template&lt;class L, class Q&gt; using mp_transform_second_q =
2154    mp_transform_second&lt;L, Q::template fn&gt;;</pre>
2155</div>
2156</div>
2157<div class="paragraph">
2158<p>As <code>mp_transform_second</code>, but takes a quoted metafunction.</p>
2159</div>
2160</div>
2161<div class="sect3">
2162<h4 id="mp_transform_thirdl_f">mp_transform_third&lt;L, F&gt;</h4>
2163<div class="literalblock">
2164<div class="content">
2165<pre>template&lt;class L, template&lt;class...&gt; class F&gt; using mp_transform_third =
2166    /*...*/;</pre>
2167</div>
2168</div>
2169<div class="paragraph">
2170<p><code>mp_transform_third&lt;L, F&gt;</code> replaces the third element <code>T3</code> of the list <code>L</code> with <code>F&lt;T3&gt;</code>.</p>
2171</div>
2172</div>
2173<div class="sect3">
2174<h4 id="mp_transform_third_ql_q">mp_transform_third_q&lt;L, Q&gt;</h4>
2175<div class="literalblock">
2176<div class="content">
2177<pre>template&lt;class L, class Q&gt; using mp_transform_third_q =
2178    mp_transform_third&lt;L, Q::template fn&gt;;</pre>
2179</div>
2180</div>
2181<div class="paragraph">
2182<p>As <code>mp_transform_third</code>, but takes a quoted metafunction.</p>
2183</div>
2184</div>
2185</div>
2186<div class="sect2">
2187<h3 id="utility">Utility Components, &lt;boost/mp11/utility.hpp&gt;</h3>
2188<div class="sect3">
2189<h4 id="mp_identityt">mp_identity&lt;T&gt;</h4>
2190<div class="literalblock">
2191<div class="content">
2192<pre>template&lt;class T&gt; struct mp_identity
2193{
2194    using type = T;
2195};</pre>
2196</div>
2197</div>
2198<div class="paragraph">
2199<p><code>mp_identity</code> is a simple <em>transformation type trait</em> (as per the C++ standard)
2200that just returns the same type. It&#8217;s useful both as such, and as a type wrapper
2201for passing types as values to functions.</p>
2202</div>
2203<div class="listingblock">
2204<div class="title">Code Example 36. Using mp_identity as a type trait</div>
2205<div class="content">
2206<pre class="highlight"><code>template&lt;class T&gt; using addp_if_not_ref =
2207    typename mp_if&lt;std::is_reference&lt;T&gt;, mp_identity&lt;T&gt;, std::add_pointer&lt;T&gt;&gt;::type;</code></pre>
2208</div>
2209</div>
2210<div class="listingblock">
2211<div class="title">Code Example 37. Using mp_identity to protect qualifiers and references</div>
2212<div class="content">
2213<pre class="highlight"><code>template&lt;class T&gt; void print1()
2214{
2215    std::cout &lt;&lt; typeid(T).name() &lt;&lt; std::endl;
2216}
2217
2218template&lt;class T&gt; void print2()
2219{
2220    std::cout &lt;&lt; typeid(mp_identity&lt;T&gt;).name() &lt;&lt; std::endl;
2221}
2222
2223int main()
2224{
2225    print1&lt;int const&amp;&gt;(); // 'int'
2226    print2&lt;int const&amp;&gt;(); // 'mp_identity&lt;int const &amp;&gt;'
2227}</code></pre>
2228</div>
2229</div>
2230</div>
2231<div class="sect3">
2232<h4 id="mp_identity_tt">mp_identity_t&lt;T&gt;</h4>
2233<div class="literalblock">
2234<div class="content">
2235<pre>template&lt;class T&gt; using mp_identity_t = typename mp_identity&lt;T&gt;::type;</pre>
2236</div>
2237</div>
2238</div>
2239<div class="sect3">
2240<h4 id="mp_inheritt">mp_inherit&lt;T&#8230;&#8203;&gt;</h4>
2241<div class="literalblock">
2242<div class="content">
2243<pre>template&lt;class... T&gt; struct mp_inherit: T... {};</pre>
2244</div>
2245</div>
2246</div>
2247<div class="sect3">
2248<h4 id="mp_if_cc_t_e">mp_if_c&lt;C, T, E&#8230;&#8203;&gt;</h4>
2249<div class="literalblock">
2250<div class="content">
2251<pre>template&lt;bool C, class T, class... E&gt; using mp_if_c = /*...*/;</pre>
2252</div>
2253</div>
2254<div class="paragraph">
2255<p><code>mp_if_c&lt;true, T, E&#8230;&#8203;&gt;</code> is an alias for <code>T</code>. <code>mp_if_c&lt;false, T, E&gt;</code> is an alias for <code>E</code>. Otherwise, the result is a substitution failure.</p>
2256</div>
2257<div class="listingblock">
2258<div class="title">Code Example 38. Using mp_if_c to select between two alternatives</div>
2259<div class="content">
2260<pre class="highlight"><code>using R1 = mp_if_c&lt;true, int, void&gt;;  // int
2261
2262using R2 = mp_if_c&lt;false, int, void&gt;; // void</code></pre>
2263</div>
2264</div>
2265<div class="listingblock">
2266<div class="title">Code Example 39. Using mp_if_c to fail substitution when a condition is not met</div>
2267<div class="content">
2268<pre class="highlight"><code>template&lt;class I&gt; using void_if_5 = mp_if_c&lt;I::value == 5, void&gt;;</code></pre>
2269</div>
2270</div>
2271<div class="paragraph">
2272<p>This example returns <code>void</code> when <code>I::value</code> is 5, and generates a substitution failure
2273otherwise. It&#8217;s the same as <code>std::enable_if_t&lt;I::value == 5&gt;</code> in C&#43;&#43;14, or
2274<code>typename std::enable_if&lt;I::value == 5&gt;::type</code> in C&#43;&#43;11.</p>
2275</div>
2276</div>
2277<div class="sect3">
2278<h4 id="mp_ifc_t_e">mp_if&lt;C, T, E&#8230;&#8203;&gt;</h4>
2279<div class="literalblock">
2280<div class="content">
2281<pre>template&lt;class C, class T, class... E&gt; using mp_if =
2282    mp_if_c&lt;static_cast&lt;bool&gt;(C::value), T, E...&gt;;</pre>
2283</div>
2284</div>
2285<div class="paragraph">
2286<p>Like <code>mp_if_c</code>, but the first argument is a type.</p>
2287</div>
2288<div class="listingblock">
2289<div class="title">Code Example 40. Using mp_if to select between two alternatives</div>
2290<div class="content">
2291<pre class="highlight"><code>using R1 = mp_if&lt;mp_true, int, void&gt;;  // int
2292
2293using R2 = mp_if&lt;mp_false, int, void&gt;; // void</code></pre>
2294</div>
2295</div>
2296<div class="listingblock">
2297<div class="title">Code Example 41. Using mp_if to fail substitution when a condition is not met</div>
2298<div class="content">
2299<pre class="highlight"><code>template&lt;class T&gt; using void_if_const = mp_if&lt;std::is_const&lt;T&gt;, void&gt;;
2300
2301template&lt;class... T&gt; using void_if_all_const =
2302    mp_if&lt;mp_all&lt;std::is_const&lt;T&gt;...&gt;, void&gt;;
2303
2304template&lt;class T&gt; using if_non_const = mp_if&lt;mp_not&lt;std::is_const&lt;T&gt;&gt;, T&gt;;</code></pre>
2305</div>
2306</div>
2307</div>
2308<div class="sect3">
2309<h4 id="mp_eval_if_cc_t_f_u">mp_eval_if_c&lt;C, T, F, U&#8230;&#8203;&gt;</h4>
2310<div class="literalblock">
2311<div class="content">
2312<pre>template&lt;bool C, class T, template&lt;class...&gt; class F, class... U&gt; using mp_eval_if_c =
2313    /*...*/;</pre>
2314</div>
2315</div>
2316<div class="paragraph">
2317<p><code>mp_eval_if_c&lt;C, T, F, U&#8230;&#8203;&gt;</code> is an alias for <code>T</code> when <code>C</code> is <code>true</code>, for <code>F&lt;U&#8230;&#8203;&gt;</code> otherwise. Its purpose
2318is to avoid evaluating <code>F&lt;U&#8230;&#8203;&gt;</code> when the condition is <code>true</code> as it may not be valid in this case.</p>
2319</div>
2320<div class="listingblock">
2321<div class="title">Code Example 42. Using mp_eval_if_c to select the first pack element, or void</div>
2322<div class="content">
2323<pre class="highlight"><code>template&lt;class... T&gt; using first_or_void =
2324    mp_eval_if_c&lt;sizeof...(T) == 0, void, mp_first, mp_list&lt;T...&gt;&gt;;</code></pre>
2325</div>
2326</div>
2327</div>
2328<div class="sect3">
2329<h4 id="mp_eval_ifc_t_f_u">mp_eval_if&lt;C, T, F, U&#8230;&#8203;&gt;</h4>
2330<div class="literalblock">
2331<div class="content">
2332<pre>template&lt;class C, class T, template&lt;class...&gt; class F, class... U&gt; using mp_eval_if =
2333    mp_eval_if_c&lt;static_cast&lt;bool&gt;(C::value), T, F, U...&gt;;</pre>
2334</div>
2335</div>
2336<div class="paragraph">
2337<p>Like <code>mp_eval_if_c</code>, but the first argument is a type.</p>
2338</div>
2339<div class="listingblock">
2340<div class="title">Code Example 43. Using mp_eval_if to select the first list element, or void</div>
2341<div class="content">
2342<pre class="highlight"><code>template&lt;class L&gt; using first_or_void = mp_eval_if&lt;mp_empty&lt;L&gt;, void, mp_first, L&gt;;</code></pre>
2343</div>
2344</div>
2345</div>
2346<div class="sect3">
2347<h4 id="mp_eval_if_qc_t_q_u">mp_eval_if_q&lt;C, T, Q, U&#8230;&#8203;&gt;</h4>
2348<div class="literalblock">
2349<div class="content">
2350<pre>template&lt;class C, class T, class Q, class... U&gt; using mp_eval_if_q =
2351    mp_eval_if&lt;C, T, Q::template fn, U...&gt;;</pre>
2352</div>
2353</div>
2354<div class="paragraph">
2355<p>Like <code>mp_eval_if</code>, but takes a quoted metafunction.</p>
2356</div>
2357</div>
2358<div class="sect3">
2359<h4 id="mp_eval_if_notc_t_f_u">mp_eval_if_not&lt;C, T, F, U&#8230;&#8203;&gt;</h4>
2360<div class="literalblock">
2361<div class="content">
2362<pre>template&lt;class C, class T, template&lt;class...&gt; class F, class... U&gt;
2363    using mp_eval_if_not = mp_eval_if&lt;mp_not&lt;C&gt;, T, F, U...&gt;;</pre>
2364</div>
2365</div>
2366<div class="paragraph">
2367<p>Same as <code>mp_eval_if</code>, but the condition is reversed.</p>
2368</div>
2369</div>
2370<div class="sect3">
2371<h4 id="mp_eval_if_not_qc_t_q_u">mp_eval_if_not_q&lt;C, T, Q, U&#8230;&#8203;&gt;</h4>
2372<div class="literalblock">
2373<div class="content">
2374<pre>template&lt;class C, class T, class Q, class... U&gt; using mp_eval_if_not_q =
2375    mp_eval_if_not&lt;C, T, Q::template fn, U...&gt;;</pre>
2376</div>
2377</div>
2378<div class="paragraph">
2379<p>Same as <code>mp_eval_if_not</code>, but takes a quoted metafunction.</p>
2380</div>
2381</div>
2382<div class="sect3">
2383<h4 id="mp_validf_t">mp_valid&lt;F, T&#8230;&#8203;&gt;</h4>
2384<div class="literalblock">
2385<div class="content">
2386<pre>template&lt;template&lt;class...&gt; class F, class... T&gt; using mp_valid = /*...*/;</pre>
2387</div>
2388</div>
2389<div class="paragraph">
2390<p><code>mp_valid&lt;F, T&#8230;&#8203;&gt;</code> is an alias for <code>mp_true</code> when <code>F&lt;T&#8230;&#8203;&gt;</code> is a valid expression, for <code>mp_false</code> otherwise.</p>
2391</div>
2392<div class="listingblock">
2393<div class="title">Code Example 44. Using mp_valid to write a metafunction that checks for the existence of a nested type</div>
2394<div class="content">
2395<pre class="highlight"><code>template&lt;class T&gt; using get_nested_type = typename T::type;
2396
2397template&lt;class T&gt; struct has_nested_type: mp_valid&lt;get_nested_type, T&gt; {};</code></pre>
2398</div>
2399</div>
2400</div>
2401<div class="sect3">
2402<h4 id="mp_valid_qq_t">mp_valid_q&lt;Q, T&#8230;&#8203;&gt;</h4>
2403<div class="literalblock">
2404<div class="content">
2405<pre>template&lt;class Q, class... T&gt; using mp_valid_q = mp_valid&lt;Q::template fn, T...&gt;;</pre>
2406</div>
2407</div>
2408<div class="paragraph">
2409<p>Like <code>mp_valid</code>, but takes a quoted metafunction.</p>
2410</div>
2411</div>
2412<div class="sect3">
2413<h4 id="mp_eval_ort_f_u">mp_eval_or&lt;T, F, U&#8230;&#8203;&gt;</h4>
2414<div class="literalblock">
2415<div class="content">
2416<pre>template&lt;class T, template&lt;class...&gt; class F, class... U&gt; using mp_eval_or =
2417    mp_eval_if_not&lt;mp_valid&lt;F, U...&gt;, T, F, U...&gt;;</pre>
2418</div>
2419</div>
2420<div class="paragraph">
2421<p><code>mp_eval_or&lt;T, F, U&#8230;&#8203;&gt;</code> is an alias for <code>F&lt;U&#8230;&#8203;&gt;</code> when this expression is valid, for <code>T</code> otherwise.</p>
2422</div>
2423<div class="listingblock">
2424<div class="title">Code Example 45. Using mp_eval_or to select the first pack element, or void</div>
2425<div class="content">
2426<pre class="highlight"><code>template&lt;class... T&gt; using first_or_void =
2427    mp_eval_or&lt;void, mp_first, mp_list&lt;T...&gt;&gt;;</code></pre>
2428</div>
2429</div>
2430</div>
2431<div class="sect3">
2432<h4 id="mp_eval_or_qt_q_u">mp_eval_or_q&lt;T, Q, U&#8230;&#8203;&gt;</h4>
2433<div class="literalblock">
2434<div class="content">
2435<pre>template&lt;class T, class Q, class... U&gt; using mp_eval_or_q =
2436    mp_eval_or&lt;T, Q::template fn, U...&gt;;</pre>
2437</div>
2438</div>
2439<div class="paragraph">
2440<p>Like <code>mp_eval_or</code>, but takes a quoted metafunction.</p>
2441</div>
2442</div>
2443<div class="sect3">
2444<h4 id="mp_condc_t_r">mp_cond&lt;C, T, R&#8230;&#8203;&gt;</h4>
2445<div class="literalblock">
2446<div class="content">
2447<pre>template&lt;class C, class T, class... R&gt; using mp_cond = /*...*/;</pre>
2448</div>
2449</div>
2450<div class="paragraph">
2451<p><code>mp_cond&lt;C, T, R&#8230;&#8203;&gt;</code> is an alias for <code>T</code> when <code>static_cast&lt;bool&gt;(C::value)</code> is <code>true</code>.
2452When <code>static_cast&lt;bool&gt;(C::value)</code> is <code>false</code>, it&#8217;s an alias for <code>mp_cond&lt;R&#8230;&#8203;&gt;</code>.</p>
2453</div>
2454<div class="paragraph">
2455<p>(If <code>static_cast&lt;bool&gt;(C::value)</code> is a substitution failure, the result is too a substitution
2456failure.)</p>
2457</div>
2458<div class="listingblock">
2459<div class="title">Code Example 46. Using mp_cond</div>
2460<div class="content">
2461<pre class="highlight"><code>template&lt;int N&gt; using unsigned_ = mp_cond&lt;
2462    mp_bool&lt;N ==  8&gt;, uint8_t,
2463    mp_bool&lt;N == 16&gt;, uint16_t,
2464    mp_bool&lt;N == 32&gt;, uint32_t,
2465    mp_bool&lt;N == 64&gt;, uint64_t,
2466    mp_true, unsigned // default case
2467&gt;;</code></pre>
2468</div>
2469</div>
2470</div>
2471<div class="sect3">
2472<h4 id="mp_deferf_t">mp_defer&lt;F, T&#8230;&#8203;&gt;</h4>
2473<div class="literalblock">
2474<div class="content">
2475<pre>template&lt;template&lt;class...&gt; class F, class... T&gt; using mp_defer = /*...*/;</pre>
2476</div>
2477</div>
2478<div class="paragraph">
2479<p>When <code>mp_valid&lt;F, T&#8230;&#8203;&gt;</code> is <code>mp_true</code>, <code>mp_defer&lt;F, T&#8230;&#8203;&gt;</code> is a struct with a nested type <code>type</code> which is an alias for <code>F&lt;T&#8230;&#8203;&gt;</code>. Otherwise,
2480<code>mp_defer&lt;F, T&#8230;&#8203;&gt;</code> is an empty struct.</p>
2481</div>
2482</div>
2483<div class="sect3">
2484<h4 id="mp_quotef">mp_quote&lt;F&gt;</h4>
2485<div class="literalblock">
2486<div class="content">
2487<pre>template&lt;template&lt;class...&gt; class F&gt; struct mp_quote
2488{
2489    template&lt;class... T&gt; using fn = F&lt;T...&gt;;
2490};</pre>
2491</div>
2492</div>
2493<div class="paragraph">
2494<p><code>mp_quote&lt;F&gt;</code> transforms the template <code>F</code> into a <em>quoted metafunction</em>, a type with a nested template <code>fn</code> such that <code>fn&lt;T&#8230;&#8203;&gt;</code> returns <code>F&lt;T&#8230;&#8203;&gt;</code>.</p>
2495</div>
2496<div class="listingblock">
2497<div class="title">Code Example 47. Using mp_quote to make a list of metafunctions</div>
2498<div class="content">
2499<pre class="highlight"><code>using LQ = mp_list&lt;mp_quote&lt;std::is_const&gt;, mp_quote&lt;std::is_volatile&gt;&gt;;</code></pre>
2500</div>
2501</div>
2502</div>
2503<div class="sect3">
2504<h4 id="mp_quote_traitf">mp_quote_trait&lt;F&gt;</h4>
2505<div class="literalblock">
2506<div class="content">
2507<pre>template&lt;template&lt;class...&gt; class F&gt; struct mp_quote_trait
2508{
2509    template&lt;class... T&gt; using fn = typename F&lt;T...&gt;::type;
2510};</pre>
2511</div>
2512</div>
2513<div class="paragraph">
2514<p><code>mp_quote_trait&lt;F&gt;</code> transforms the C++03-style trait <code>F</code> into a quoted metafunction.</p>
2515</div>
2516<div class="listingblock">
2517<div class="title">Code Example 48. Using mp_quote_trait with std::add_pointer</div>
2518<div class="content">
2519<pre class="highlight"><code>using L1 = mp_list&lt;int, void, float&gt;;
2520using R1 = mp_transform_q&lt;mp_quote_trait&lt;std::add_pointer&gt;, L1&gt;;
2521  // mp_list&lt;int*, void*, float*&gt;</code></pre>
2522</div>
2523</div>
2524</div>
2525<div class="sect3">
2526<h4 id="mp_invoke_qq_t">mp_invoke_q&lt;Q, T&#8230;&#8203;&gt;</h4>
2527<div class="literalblock">
2528<div class="content">
2529<pre>template&lt;class Q, class... T&gt; using mp_invoke_q = typename Q::template fn&lt;T...&gt;;</pre>
2530</div>
2531</div>
2532<div class="paragraph">
2533<p><code>mp_invoke_q&lt;Q, T&#8230;&#8203;&gt;</code> evaluates the nested template <code>fn</code> of a quoted metafunction. <code>mp_invoke_q&lt;mp_quote&lt;F&gt;, T&#8230;&#8203;&gt;</code> returns <code>F&lt;T&#8230;&#8203;&gt;</code>.</p>
2534</div>
2535<div class="listingblock">
2536<div class="title">Code Example 49. Using mp_invoke_q to invoke a list of metafunctions, technique 1</div>
2537<div class="content">
2538<pre class="highlight"><code>using LQ = mp_list&lt;mp_quote&lt;std::is_const&gt;, mp_quote&lt;std::is_volatile&gt;&gt;;
2539
2540template&lt;class T&gt; using is_const_and_volatile =
2541    mp_apply&lt;mp_all, mp_product&lt;mp_invoke_q, LQ, mp_list&lt;T&gt;&gt;&gt;;</code></pre>
2542</div>
2543</div>
2544<div class="listingblock">
2545<div class="title">Code Example 50. Using mp_invoke_q to invoke a list of metafunctions, technique 2</div>
2546<div class="content">
2547<pre class="highlight"><code>template&lt;class T&gt; using is_const_and_volatile =
2548    mp_apply&lt;mp_all, mp_transform_q&lt;mp_bind_back&lt;mp_invoke_q, T&gt;, LQ&gt;&gt;;</code></pre>
2549</div>
2550</div>
2551<div class="listingblock">
2552<div class="title">Code Example 51. Using mp_invoke_q to invoke a list of metafunctions, technique 3</div>
2553<div class="content">
2554<pre class="highlight"><code>template&lt;class T&gt; using is_const_and_volatile =
2555    mp_apply&lt;mp_all, mp_transform&lt;mp_invoke_q, LQ, mp_fill&lt;LQ, T&gt;&gt;&gt;;</code></pre>
2556</div>
2557</div>
2558</div>
2559<div class="sect3">
2560<h4 id="mp_not_fnp">mp_not_fn&lt;P&gt;</h4>
2561<div class="literalblock">
2562<div class="content">
2563<pre>template&lt;template&lt;class...&gt; class P&gt; struct mp_not_fn
2564{
2565    template&lt;class... T&gt; using fn = mp_not&lt;P&lt;T...&gt;&gt;;
2566};</pre>
2567</div>
2568</div>
2569<div class="paragraph">
2570<p><code>mp_not_fn&lt;P&gt;</code> returns a quoted metafunction <code>Q</code> such that <code>Q::fn&lt;T&#8230;&#8203;&gt;</code> returns <code>mp_not&lt;P&lt;T&#8230;&#8203;&gt;&gt;</code>.</p>
2571</div>
2572<div class="paragraph">
2573<p>That is, it negates the result of <code>P</code>.</p>
2574</div>
2575</div>
2576<div class="sect3">
2577<h4 id="mp_not_fn_qq">mp_not_fn_q&lt;Q&gt;</h4>
2578<div class="literalblock">
2579<div class="content">
2580<pre>template&lt;class Q&gt; using mp_not_fn_q = mp_not_fn&lt;Q::template fn&gt;;</pre>
2581</div>
2582</div>
2583<div class="paragraph">
2584<p>As <code>mp_not_fn</code>, but takes a quoted metafunction.</p>
2585</div>
2586</div>
2587<div class="sect3">
2588<h4 id="mp_composef">mp_compose&lt;F&#8230;&#8203;&gt;</h4>
2589<div class="literalblock">
2590<div class="content">
2591<pre>template&lt;template&lt;class...&gt; class... F&gt; struct mp_compose;</pre>
2592</div>
2593</div>
2594<div class="paragraph">
2595<p><code>mp_compose&lt;F1, F2, &#8230;&#8203;, Fn&gt;</code> is a quoted metafunction that applies
2596<code>F1</code>, <code>F2</code>, &#8230;&#8203;, <code>Fn</code> to its argument, in sequence. That is,
2597<code>mp_compose&lt;F1, F2, &#8230;&#8203;, Fn&gt;::fn&lt;T&gt;</code> is <code>Fn&lt;&#8230;&#8203;F2&lt;F1&lt;T&gt;&gt;&#8230;&#8203;&gt;</code>.</p>
2598</div>
2599</div>
2600<div class="sect3">
2601<h4 id="mp_compose_qq">mp_compose_q&lt;Q&#8230;&#8203;&gt;</h4>
2602<div class="literalblock">
2603<div class="content">
2604<pre>template&lt;class... Q&gt; struct mp_compose_q;</pre>
2605</div>
2606</div>
2607<div class="paragraph">
2608<p>As <code>mp_compose</code>, but takes quoted metafunctions.</p>
2609</div>
2610</div>
2611</div>
2612<div class="sect2">
2613<h3 id="algorithm">Algorithms, &lt;boost/mp11/algorithm.hpp&gt;</h3>
2614<div class="sect3">
2615<h4 id="mp_transformf_l">mp_transform&lt;F, L&#8230;&#8203;&gt;</h4>
2616<div class="literalblock">
2617<div class="content">
2618<pre>template&lt;template&lt;class...&gt; class F, class... L&gt; using mp_transform = /*...*/;</pre>
2619</div>
2620</div>
2621<div class="paragraph">
2622<p><code>mp_transform&lt;F, L1&lt;T1&#8230;&#8203;&gt;, L2&lt;T2&#8230;&#8203;&gt;, &#8230;&#8203;, Ln&lt;Tn&#8230;&#8203;&gt;&gt;</code> applies <code>F</code> to each successive tuple of elements and returns <code>L1&lt;F&lt;T1, T2, &#8230;&#8203;, Tn&gt;&#8230;&#8203;&gt;</code>.</p>
2623</div>
2624<div class="listingblock">
2625<div class="title">Code Example 52. Using mp_transform to produce a list of pointers from a list of pointees</div>
2626<div class="content">
2627<pre class="highlight"><code>template&lt;class T&gt; using add_pointer_t =
2628    typename std::add_pointer&lt;T&gt;::type;  // std::add_pointer_t in C++14
2629
2630using L1 = std::tuple&lt;void, int, float&gt;;
2631using R1 = mp_transform&lt;add_pointer_t, L1&gt;; // std::tuple&lt;void*, int*, float*&gt;</code></pre>
2632</div>
2633</div>
2634<div class="listingblock">
2635<div class="title">Code Example 53. Using mp_transform to compare the contents of two lists of types</div>
2636<div class="content">
2637<pre class="highlight"><code>using L1 = std::tuple&lt;void, int, float&gt;;
2638using L2 = mp_list&lt;void, int, float&gt;;
2639
2640using R1 = mp_apply&lt;mp_all, mp_transform&lt;std::is_same, L1, L2&gt;&gt;; // mp_true</code></pre>
2641</div>
2642</div>
2643<div class="listingblock">
2644<div class="title">Code Example 54. Using mp_transform to compare the contents of two lists of integral constants</div>
2645<div class="content">
2646<pre class="highlight"><code>template&lt;class T1, class T2&gt; using eq = mp_bool&lt;T1::value == T2::value&gt;;
2647
2648using L1 = std::tuple&lt;mp_int&lt;1&gt;, mp_int&lt;2&gt;, mp_int&lt;3&gt;&gt;;
2649using L2 = mp_list&lt;mp_size_t&lt;1&gt;, mp_size_t&lt;2&gt;, mp_size_t&lt;3&gt;&gt;;
2650
2651using R1 = mp_apply&lt;mp_all, mp_transform&lt;eq, L1, L2&gt;&gt;; // mp_true</code></pre>
2652</div>
2653</div>
2654<table class="tableblock frame-all grid-all" style="width: 85%;">
2655<caption class="title">Illustration 1. mp_transform on one list</caption>
2656<colgroup>
2657<col style="width: 50%;">
2658<col style="width: 12.5%;">
2659<col style="width: 12.5%;">
2660<col style="width: 12.5%;">
2661<col style="width: 12.5%;">
2662</colgroup>
2663<tbody>
2664<tr>
2665<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2666<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2667<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2668<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2669<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2670</tr>
2671<tr>
2672<td class="tableblock halign-left valign-middle" colspan="5"></td>
2673</tr>
2674<tr>
2675<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform&lt;F, L1&gt;</strong></code></p></td>
2676<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>1</sub>&gt;</code></p></td>
2677<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>2</sub>&gt;</code></p></td>
2678<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2679<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>n</sub>&gt;</code></p></td>
2680</tr>
2681</tbody>
2682</table>
2683<table class="tableblock frame-all grid-all" style="width: 85%;">
2684<caption class="title">Illustration 2. mp_transform on two lists</caption>
2685<colgroup>
2686<col style="width: 50%;">
2687<col style="width: 12.5%;">
2688<col style="width: 12.5%;">
2689<col style="width: 12.5%;">
2690<col style="width: 12.5%;">
2691</colgroup>
2692<tbody>
2693<tr>
2694<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2695<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2696<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2697<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2698<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2699</tr>
2700<tr>
2701<td class="tableblock halign-left valign-middle" colspan="5"></td>
2702</tr>
2703<tr>
2704<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
2705<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
2706<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2707<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2708<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>n</sub></code></p></td>
2709</tr>
2710<tr>
2711<td class="tableblock halign-left valign-middle" colspan="5"></td>
2712</tr>
2713<tr>
2714<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform&lt;F, L1, L2&gt;</strong></code></p></td>
2715<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>1</sub>,B<sub>1</sub>&gt;</code></p></td>
2716<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>2</sub>,B<sub>2</sub>&gt;</code></p></td>
2717<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2718<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>n</sub>,B<sub>n</sub>&gt;</code></p></td>
2719</tr>
2720</tbody>
2721</table>
2722</div>
2723<div class="sect3">
2724<h4 id="mp_transform_qq_l">mp_transform_q&lt;Q, L&#8230;&#8203;&gt;</h4>
2725<div class="literalblock">
2726<div class="content">
2727<pre>template&lt;class Q, class... L&gt; using mp_transform_q =
2728    mp_transform&lt;Q::template fn, L...&gt;;</pre>
2729</div>
2730</div>
2731<div class="paragraph">
2732<p>As <code>mp_transform</code>, but takes a quoted metafunction.</p>
2733</div>
2734<div class="listingblock">
2735<div class="title">Code Example 55. Using mp_transform_q to count the occurrences of <code>void</code> in a list</div>
2736<div class="content">
2737<pre class="highlight"><code>using L1 = std::tuple&lt;void, int, float, void, int&gt;;
2738
2739using R1 = mp_apply&lt;mp_plus,
2740    mp_transform_q&lt;mp_bind_front&lt;std::is_same, void&gt;, L1&gt;&gt;; // mp_int&lt;2&gt;</code></pre>
2741</div>
2742</div>
2743<table class="tableblock frame-all grid-all" style="width: 85%;">
2744<caption class="title">Illustration 3. mp_transform_q on two lists</caption>
2745<colgroup>
2746<col style="width: 50%;">
2747<col style="width: 12.5%;">
2748<col style="width: 12.5%;">
2749<col style="width: 12.5%;">
2750<col style="width: 12.5%;">
2751</colgroup>
2752<tbody>
2753<tr>
2754<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2755<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2756<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2757<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2758<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2759</tr>
2760<tr>
2761<td class="tableblock halign-left valign-middle" colspan="5"></td>
2762</tr>
2763<tr>
2764<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
2765<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
2766<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2767<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2768<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>n</sub></code></p></td>
2769</tr>
2770<tr>
2771<td class="tableblock halign-left valign-middle" colspan="5"></td>
2772</tr>
2773<tr>
2774<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform_q&lt;Q, L1, L2&gt;</strong></code></p></td>
2775<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>Q::fn&lt;A<sub>1</sub>,B<sub>1</sub>&gt;</code></p></td>
2776<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>Q::fn&lt;A<sub>2</sub>,B<sub>2</sub>&gt;</code></p></td>
2777<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2778<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>Q::fn&lt;A<sub>n</sub>,B<sub>n</sub>&gt;</code></p></td>
2779</tr>
2780</tbody>
2781</table>
2782</div>
2783<div class="sect3">
2784<h4 id="mp_transform_ifp_f_l">mp_transform_if&lt;P, F, L&#8230;&#8203;&gt;</h4>
2785<div class="literalblock">
2786<div class="content">
2787<pre>template&lt;template&lt;class...&gt; class P, template&lt;class...&gt; class F, class... L&gt;
2788    using mp_transform_if = /*...*/;</pre>
2789</div>
2790</div>
2791<div class="paragraph">
2792<p><code>mp_transform_if&lt;P, F, L1, L2, &#8230;&#8203;, Ln&gt;</code> replaces the elements of the list <code>L1</code> for which <code>mp_to_bool&lt;P&lt;T1, T2, &#8230;&#8203;, Tn&gt;&gt;</code> is <code>mp_true</code> with
2793<code>F&lt;T1, T2, &#8230;&#8203;, Tn&gt;</code>, and returns the result, where <code>Ti</code> are the corresponding elements of <code>Li</code>.</p>
2794</div>
2795<div class="listingblock">
2796<div class="title">Code Example 56. Using mp_transform_if to replace the occurrences of 'void' in a list with the corresponding elements of a second list</div>
2797<div class="content">
2798<pre class="highlight"><code>using L1 = std::tuple&lt;void, int, float, void, int&gt;;
2799using L2 = std::tuple&lt;char[1], char[2], char[3], char[4], char[5]&gt;;
2800
2801template&lt;class T1, class T2&gt; using first_is_void = std::is_same&lt;T1, void&gt;;
2802template&lt;class T1, class T2&gt; using second = T2;
2803
2804using R1 = mp_transform_if&lt;first_is_void, second, L1, L2&gt;;
2805  // std::tuple&lt;char[1], int, float, char[4], int&gt;</code></pre>
2806</div>
2807</div>
2808<table class="tableblock frame-all grid-all" style="width: 85%;">
2809<caption class="title">Illustration 4. mp_transform_if</caption>
2810<colgroup>
2811<col style="width: 50%;">
2812<col style="width: 12.5%;">
2813<col style="width: 12.5%;">
2814<col style="width: 12.5%;">
2815<col style="width: 12.5%;">
2816</colgroup>
2817<tbody>
2818<tr>
2819<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2820<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2821<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2822<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2823<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2824</tr>
2825<tr>
2826<td class="tableblock halign-left valign-middle" colspan="5"></td>
2827</tr>
2828<tr>
2829<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
2830<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
2831<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2832<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2833<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>n</sub></code></p></td>
2834</tr>
2835<tr>
2836<td class="tableblock halign-left valign-middle" colspan="5"></td>
2837</tr>
2838<tr>
2839<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>P&lt;A<sub>i</sub>, B<sub>i</sub>&gt;</strong></code></p></td>
2840<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
2841<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_true</code></p></td>
2842<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2843<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
2844</tr>
2845<tr>
2846<td class="tableblock halign-left valign-middle" colspan="5"></td>
2847</tr>
2848<tr>
2849<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform_if&lt;P, F, L1, L2&gt;</strong></code></p></td>
2850<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2851<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>2</sub>,B<sub>2</sub>&gt;</code></p></td>
2852<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2853<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2854</tr>
2855</tbody>
2856</table>
2857</div>
2858<div class="sect3">
2859<h4 id="mp_transform_if_qqp_qf_l">mp_transform_if_q&lt;Qp, Qf, L&#8230;&#8203;&gt;</h4>
2860<div class="literalblock">
2861<div class="content">
2862<pre>template&lt;class Qp, class Qf, class... L&gt; using mp_transform_if_q =
2863    mp_transform_if&lt;Qp::template fn, Qf::template fn, L...&gt;;</pre>
2864</div>
2865</div>
2866<div class="paragraph">
2867<p>As <code>mp_transform_if</code>, but takes quoted metafunctions.</p>
2868</div>
2869<div class="listingblock">
2870<div class="title">Code Example 57. Using mp_transform_if_q to replace the occurrences of 'void' in a list with the corresponding elements of a second list</div>
2871<div class="content">
2872<pre class="highlight"><code>using L1 = std::tuple&lt;void, int, float, void, int&gt;;
2873using L2 = std::tuple&lt;char[1], char[2], char[3], char[4], char[5]&gt;;
2874
2875using R1 = mp_transform_if_q&lt;mp_bind&lt;std::is_same, _1, void&gt;, _2, L1, L2&gt;;
2876  // std::tuple&lt;char[1], int, float, char[4], int&gt;</code></pre>
2877</div>
2878</div>
2879<table class="tableblock frame-all grid-all" style="width: 85%;">
2880<caption class="title">Illustration 5. mp_transform_if_q</caption>
2881<colgroup>
2882<col style="width: 50%;">
2883<col style="width: 12.5%;">
2884<col style="width: 12.5%;">
2885<col style="width: 12.5%;">
2886<col style="width: 12.5%;">
2887</colgroup>
2888<tbody>
2889<tr>
2890<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2891<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2892<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2893<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2894<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2895</tr>
2896<tr>
2897<td class="tableblock halign-left valign-middle" colspan="5"></td>
2898</tr>
2899<tr>
2900<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
2901<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
2902<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2903<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2904<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>n</sub></code></p></td>
2905</tr>
2906<tr>
2907<td class="tableblock halign-left valign-middle" colspan="5"></td>
2908</tr>
2909<tr>
2910<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>Qp::fn&lt;A<sub>i</sub>, B<sub>i</sub>&gt;</strong></code></p></td>
2911<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
2912<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_true</code></p></td>
2913<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2914<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
2915</tr>
2916<tr>
2917<td class="tableblock halign-left valign-middle" colspan="5"></td>
2918</tr>
2919<tr>
2920<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform_if_q&lt;Qp, _2, L1, L2&gt;</strong></code></p></td>
2921<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2922<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2923<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
2924<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2925</tr>
2926</tbody>
2927</table>
2928</div>
2929<div class="sect3">
2930<h4 id="mp_filterp_l">mp_filter&lt;P, L&#8230;&#8203;&gt;</h4>
2931<div class="literalblock">
2932<div class="content">
2933<pre>template&lt;template&lt;class...&gt; class P, class... L&gt; using mp_filter = /*...*/;</pre>
2934</div>
2935</div>
2936<div class="paragraph">
2937<p><code>mp_filter&lt;P, L1, L2, &#8230;&#8203;, Ln&gt;</code> removes the elements of the list <code>L1</code> for which <code>mp_to_bool&lt;P&lt;T1, T2, &#8230;&#8203;, Tn&gt;&gt;</code>
2938is <code>mp_false</code> and returns the result, where <code>Ti</code> are the corresponding elements of <code>Li</code>.</p>
2939</div>
2940<div class="paragraph">
2941<p>See also <code>mp_copy_if</code> and <code>mp_remove_if</code>, less general variants of <code>mp_filter</code> that only take a single list.</p>
2942</div>
2943</div>
2944<div class="sect3">
2945<h4 id="mp_filter_qqp_l">mp_filter_q&lt;Qp, L&#8230;&#8203;&gt;</h4>
2946<div class="literalblock">
2947<div class="content">
2948<pre>template&lt;class Qp, class... L&gt; using mp_filter_q =
2949    mp_filter&lt;Qp::template fn, L...&gt;;</pre>
2950</div>
2951</div>
2952<div class="paragraph">
2953<p>As <code>mp_filter</code>, but takes a quoted metafunction.</p>
2954</div>
2955<div class="listingblock">
2956<div class="title">Code Example 58. Using mp_filter_q to pick elements of a list based on a mask in another list</div>
2957<div class="content">
2958<pre class="highlight"><code>using L1 = std::tuple&lt;void, int, float&gt;;
2959using L2 = mp_list&lt;mp_true, mp_false, mp_true&gt;;
2960using R1 = mp_filter_q&lt;_2, L1, L2&gt;; // std::tuple&lt;void, float&gt;</code></pre>
2961</div>
2962</div>
2963</div>
2964<div class="sect3">
2965<h4 id="mp_filll_v">mp_fill&lt;L, V&gt;</h4>
2966<div class="literalblock">
2967<div class="content">
2968<pre>template&lt;class L, class V&gt; using mp_fill = /*...*/;</pre>
2969</div>
2970</div>
2971<div class="paragraph">
2972<p><code>mp_fill&lt;L&lt;T&#8230;&#8203;&gt;, V&gt;</code> returns <code>L&lt;V, V, &#8230;&#8203;, V&gt;</code>, with the result having the same size as the input.</p>
2973</div>
2974<div class="listingblock">
2975<div class="title">Code Example 59. Using mp_fill with std::tuple</div>
2976<div class="content">
2977<pre class="highlight"><code>using L1 = std::tuple&lt;void, int, float&gt;;
2978using R1 = mp_fill&lt;L1, double&gt;; // std::tuple&lt;double, double, double&gt;</code></pre>
2979</div>
2980</div>
2981<div class="listingblock">
2982<div class="title">Code Example 60. Using mp_fill with std::pair</div>
2983<div class="content">
2984<pre class="highlight"><code>using L1 = std::pair&lt;int, float&gt;;
2985using R1 = mp_fill&lt;L1, void&gt;; // std::pair&lt;void, void&gt;</code></pre>
2986</div>
2987</div>
2988<table class="tableblock frame-all grid-all" style="width: 85%;">
2989<caption class="title">Illustration 6. mp_fill</caption>
2990<colgroup>
2991<col style="width: 50%;">
2992<col style="width: 12.5%;">
2993<col style="width: 12.5%;">
2994<col style="width: 12.5%;">
2995<col style="width: 12.5%;">
2996</colgroup>
2997<tbody>
2998<tr>
2999<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3000<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3001<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
3002<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3003<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3004</tr>
3005<tr>
3006<td class="tableblock halign-left valign-middle" colspan="5"></td>
3007</tr>
3008<tr>
3009<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_fill&lt;L1, V&gt;</strong></code></p></td>
3010<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>V</code></p></td>
3011<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>V</code></p></td>
3012<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3013<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>V</code></p></td>
3014</tr>
3015</tbody>
3016</table>
3017</div>
3018<div class="sect3">
3019<h4 id="mp_countl_v">mp_count&lt;L, V&gt;</h4>
3020<div class="literalblock">
3021<div class="content">
3022<pre>template&lt;class L, class V&gt; using mp_count = /*...*/;</pre>
3023</div>
3024</div>
3025<div class="paragraph">
3026<p><code>mp_count&lt;L, V&gt;</code> returns <code>mp_size_t&lt;N&gt;</code>, where <code>N</code> is the number of elements of <code>L</code> same as <code>V</code>.</p>
3027</div>
3028</div>
3029<div class="sect3">
3030<h4 id="mp_count_ifl_p">mp_count_if&lt;L, P&gt;</h4>
3031<div class="literalblock">
3032<div class="content">
3033<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_count_if = /*...*/;</pre>
3034</div>
3035</div>
3036<div class="paragraph">
3037<p><code>mp_count_if&lt;L, P&gt;</code> returns <code>mp_size_t&lt;N&gt;</code>, where <code>N</code> is the number of elements <code>T</code> of <code>L</code> for which <code>mp_to_bool&lt;P&lt;T&gt;&gt;</code> is <code>mp_true</code>.</p>
3038</div>
3039</div>
3040<div class="sect3">
3041<h4 id="mp_count_if_ql_q">mp_count_if_q&lt;L, Q&gt;</h4>
3042<div class="literalblock">
3043<div class="content">
3044<pre>template&lt;class L, class Q&gt; using mp_count_if_q = mp_count_if&lt;L, Q::template fn&gt;;</pre>
3045</div>
3046</div>
3047<div class="paragraph">
3048<p>As <code>mp_count_if</code>, but takes a quoted metafunction.</p>
3049</div>
3050</div>
3051<div class="sect3">
3052<h4 id="mp_containsl_v">mp_contains&lt;L, V&gt;</h4>
3053<div class="literalblock">
3054<div class="content">
3055<pre>template&lt;class L, class V&gt; using mp_contains = mp_to_bool&lt;mp_count&lt;L, V&gt;&gt;;</pre>
3056</div>
3057</div>
3058<div class="paragraph">
3059<p><code>mp_contains&lt;L, V&gt;</code> is <code>mp_true</code> when <code>L</code> contains an element <code>V</code>, <code>mp_false</code> otherwise.</p>
3060</div>
3061</div>
3062<div class="sect3">
3063<h4 id="mp_starts_withl1_l2">mp_starts_with&lt;L1, L2&gt;</h4>
3064<div class="literalblock">
3065<div class="content">
3066<pre>template&lt;class L1, class L2&gt; using mp_starts_with = /*...*/;</pre>
3067</div>
3068</div>
3069<div class="paragraph">
3070<p><code>mp_starts_with&lt;L1, L2&gt;</code> is <code>mp_true</code> when <code>L1</code> starts with <code>L2</code>, <code>mp_false</code>
3071otherwise.</p>
3072</div>
3073</div>
3074<div class="sect3">
3075<h4 id="mp_repeat_cl_n">mp_repeat_c&lt;L, N&gt;</h4>
3076<div class="literalblock">
3077<div class="content">
3078<pre>template&lt;class L, std::size_t N&gt; using mp_repeat_c = /*...*/;</pre>
3079</div>
3080</div>
3081<div class="paragraph">
3082<p><code>mp_repeat_c&lt;L, N&gt;</code> returns a list of the same form as <code>L</code> that consists of <code>N</code> concatenated copies of <code>L</code>.</p>
3083</div>
3084<div class="listingblock">
3085<div class="title">Code Example 61. Using mp_repeat_c</div>
3086<div class="content">
3087<pre class="highlight"><code>using L1 = tuple&lt;int&gt;;
3088using R1 = mp_repeat_c&lt;L1, 3&gt;; // tuple&lt;int, int, int&gt;
3089
3090using L2 = pair&lt;int, float&gt;;
3091using R2 = mp_repeat_c&lt;L2, 1&gt;; // pair&lt;int, float&gt;
3092
3093using L3 = mp_list&lt;int, float&gt;;
3094using R3 = mp_repeat_c&lt;L3, 2&gt;; // mp_list&lt;int, float, int, float&gt;
3095
3096using L4 = mp_list&lt;int, float, double&gt;;
3097using R4 = mp_repeat_c&lt;L4, 0&gt;; // mp_list&lt;&gt;</code></pre>
3098</div>
3099</div>
3100</div>
3101<div class="sect3">
3102<h4 id="mp_repeatl_n">mp_repeat&lt;L, N&gt;</h4>
3103<div class="literalblock">
3104<div class="content">
3105<pre>template&lt;class L, class N&gt; using mp_repeat = /*...*/;</pre>
3106</div>
3107</div>
3108<div class="paragraph">
3109<p>Same as <code>mp_repeat_c</code> but with a type argument <code>N</code>. The number of copies is <code>N::value</code> and must be nonnegative.</p>
3110</div>
3111</div>
3112<div class="sect3">
3113<h4 id="mp_productf_l">mp_product&lt;F, L&#8230;&#8203;&gt;</h4>
3114<div class="literalblock">
3115<div class="content">
3116<pre>template&lt;template&lt;class...&gt; class F, class... L&gt; using mp_product = /*...*/;</pre>
3117</div>
3118</div>
3119<div class="paragraph">
3120<p><code>mp_product&lt;F, L1&lt;T1&#8230;&#8203;&gt;, L2&lt;T2&#8230;&#8203;&gt;, &#8230;&#8203;, Ln&lt;Tn&#8230;&#8203;&gt;&gt;</code> evaluates <code>F&lt;U1, U2, &#8230;&#8203;, Un&gt;</code> for values <code>Ui</code> taken from
3121the Cartesian product of the lists, as if the elements <code>Ui</code> are formed by <code>n</code> nested loops, each traversing <code>Li</code>.
3122It returns a list of the form <code>L1&lt;V&#8230;&#8203;&gt;</code> containing the results of the application of <code>F</code>. The degenerate case
3123of zero lists, <code>mp_product&lt;F&gt;</code>, returns <code>mp_list&lt;F&lt;&gt;&gt;</code>.</p>
3124</div>
3125<table class="tableblock frame-all grid-all" style="width: 85%;">
3126<caption class="title">Illustration 7. mp_product on two lists</caption>
3127<colgroup>
3128<col style="width: 50%;">
3129<col style="width: 12.5%;">
3130<col style="width: 12.5%;">
3131<col style="width: 12.5%;">
3132<col style="width: 12.5%;">
3133</colgroup>
3134<tbody>
3135<tr>
3136<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3137<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3138<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
3139<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3140<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3141</tr>
3142<tr>
3143<td class="tableblock halign-left valign-middle" colspan="5"></td>
3144</tr>
3145<tr>
3146<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
3147<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
3148<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
3149<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3150<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>m</sub></code></p></td>
3151</tr>
3152<tr>
3153<td class="tableblock halign-left valign-middle" colspan="5"></td>
3154</tr>
3155<tr>
3156<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_product&lt;F, L1, L2&gt;</strong></code></p></td>
3157<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>1</sub>,B<sub>1</sub>&gt;</code></p></td>
3158<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>1</sub>,B<sub>2</sub>&gt;</code></p></td>
3159<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3160<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>1</sub>,B<sub>m</sub>&gt;</code></p></td>
3161</tr>
3162<tr>
3163<td class="tableblock halign-left valign-middle"></td>
3164<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>2</sub>,B<sub>1</sub>&gt;</code></p></td>
3165<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>2</sub>,B<sub>2</sub>&gt;</code></p></td>
3166<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3167<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>2</sub>,B<sub>m</sub>&gt;</code></p></td>
3168</tr>
3169<tr>
3170<td class="tableblock halign-left valign-middle"></td>
3171<td class="tableblock halign-center valign-middle" colspan="4"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3172</tr>
3173<tr>
3174<td class="tableblock halign-left valign-middle"></td>
3175<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>n</sub>,B<sub>1</sub>&gt;</code></p></td>
3176<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>n</sub>,B<sub>2</sub>&gt;</code></p></td>
3177<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3178<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F&lt;A<sub>n</sub>,B<sub>m</sub>&gt;</code></p></td>
3179</tr>
3180</tbody>
3181</table>
3182</div>
3183<div class="sect3">
3184<h4 id="mp_product_qq_l">mp_product_q&lt;Q, L&#8230;&#8203;&gt;</h4>
3185<div class="literalblock">
3186<div class="content">
3187<pre>template&lt;class Q, class... L&gt; using mp_product_q = mp_product&lt;Q::template fn, L...&gt;;</pre>
3188</div>
3189</div>
3190<div class="paragraph">
3191<p>As <code>mp_product</code>, but takes a quoted metafunction.</p>
3192</div>
3193</div>
3194<div class="sect3">
3195<h4 id="mp_power_setl">mp_power_set&lt;L&gt;</h4>
3196<div class="literalblock">
3197<div class="content">
3198<pre>template&lt;class L&gt; using mp_power_set = /*...*/;</pre>
3199</div>
3200</div>
3201<div class="paragraph">
3202<p><code>mp_power_set&lt;L&gt;</code> returns a list (of the same form as <code>L</code>) of all possible 2<sup>n</sup> subsets of <code>L</code> (where <code>n</code> is the length of <code>L</code>.)</p>
3203</div>
3204<div class="paragraph">
3205<p><code>mp_power_set&lt;L&lt;&gt;&gt;</code> returns <code>L&lt;L&lt;&gt;&gt;</code>.</p>
3206</div>
3207<div class="paragraph">
3208<p><code>mp_power_set&lt;L&lt;T1&gt;&gt;</code> returns <code>L&lt;L&lt;&gt;, L&lt;T1&gt;&gt;</code>.</p>
3209</div>
3210<div class="paragraph">
3211<p><code>mp_power_set&lt;L&lt;T1, T2&gt;&gt;</code> returns <code>L&lt;L&lt;&gt;, L&lt;T2&gt;, L&lt;T1&gt;, L&lt;T1, T2&gt;&gt;</code>.</p>
3212</div>
3213<div class="paragraph">
3214<p><code>mp_power_set&lt;L&lt;T1, T&#8230;&#8203;&gt;&gt;</code> returns the concatenation of <code>mp_power_set&lt;L&lt;T&#8230;&#8203;&gt;&gt;</code> and that same list with <code>T1</code> prepended to each element.</p>
3215</div>
3216</div>
3217<div class="sect3">
3218<h4 id="mp_drop_cl_n">mp_drop_c&lt;L, N&gt;</h4>
3219<div class="literalblock">
3220<div class="content">
3221<pre>template&lt;class L, std::size_t N&gt; using mp_drop_c = /*...*/;</pre>
3222</div>
3223</div>
3224<div class="paragraph">
3225<p><code>mp_drop_c&lt;L, N&gt;</code> removes the first <code>N</code> elements of <code>L</code> and returns the result.</p>
3226</div>
3227<table class="tableblock frame-all grid-all" style="width: 85%;">
3228<caption class="title">Illustration 8. mp_drop_c</caption>
3229<colgroup>
3230<col style="width: 40%;">
3231<col style="width: 10%;">
3232<col style="width: 10%;">
3233<col style="width: 10%;">
3234<col style="width: 10%;">
3235<col style="width: 10%;">
3236<col style="width: 10%;">
3237</colgroup>
3238<tbody>
3239<tr>
3240<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3241<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3242<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3243<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3244<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3245<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3246<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3247</tr>
3248<tr>
3249<td class="tableblock halign-left valign-middle" colspan="7"></td>
3250</tr>
3251<tr>
3252<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_drop_c&lt;L1, M&gt;</strong></code></p></td>
3253<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3254<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3255<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3256<td class="tableblock halign-center valign-middle" colspan="3"></td>
3257</tr>
3258</tbody>
3259</table>
3260</div>
3261<div class="sect3">
3262<h4 id="mp_dropl_n">mp_drop&lt;L, N&gt;</h4>
3263<div class="literalblock">
3264<div class="content">
3265<pre>template&lt;class L, class N&gt; using mp_drop = /*...*/;</pre>
3266</div>
3267</div>
3268<div class="paragraph">
3269<p>Same as <code>mp_drop_c</code>, but with a type argument <code>N</code>. <code>N::value</code> must be a nonnegative number.</p>
3270</div>
3271</div>
3272<div class="sect3">
3273<h4 id="mp_from_sequences">mp_from_sequence&lt;S&gt;</h4>
3274<div class="literalblock">
3275<div class="content">
3276<pre>template&lt;class S&gt; using mp_from_sequence = /*...*/</pre>
3277</div>
3278</div>
3279<div class="paragraph">
3280<p><code>mp_from_sequence</code> transforms an integer sequence produced by <code>make_integer_sequence</code> into an <code>mp_list</code>
3281of the corresponding <code>std::integral_constant</code> types. Given</p>
3282</div>
3283<div class="literalblock">
3284<div class="content">
3285<pre>template&lt;class T, T... I&gt; struct S;</pre>
3286</div>
3287</div>
3288<div class="paragraph">
3289<p><code>mp_from_sequence&lt;S&lt;T, I&#8230;&#8203;&gt;&gt;</code> is an alias for <code>mp_list&lt;std::integral_constant&lt;T, I&gt;&#8230;&#8203;&gt;</code>.</p>
3290</div>
3291</div>
3292<div class="sect3">
3293<h4 id="mp_iota_cn">mp_iota_c&lt;N&gt;</h4>
3294<div class="literalblock">
3295<div class="content">
3296<pre>template&lt;std::size_t N&gt; using mp_iota_c = /*...*/;</pre>
3297</div>
3298</div>
3299<div class="paragraph">
3300<p><code>mp_iota_c&lt;N&gt;</code> is an alias for <code>mp_list&lt;mp_size_t&lt;0&gt;, mp_size_t&lt;1&gt;, &#8230;&#8203;, mp_size_t&lt;N-1&gt;&gt;</code>.</p>
3301</div>
3302</div>
3303<div class="sect3">
3304<h4 id="mp_iotan">mp_iota&lt;N&gt;</h4>
3305<div class="literalblock">
3306<div class="content">
3307<pre>template&lt;class N&gt; using mp_iota = /*...*/;</pre>
3308</div>
3309</div>
3310<div class="paragraph">
3311<p>Same as <code>mp_iota_c</code>, but with a type argument <code>N</code>. <code>N::value</code> must be a nonnegative number. Returns
3312<code>mp_list&lt;std::integral_constant&lt;T, 0&gt;, std::integral_constant&lt;T, 1&gt;, &#8230;&#8203;, std::integral_constant&lt;T, N::value-1&gt;&gt;</code>
3313where <code>T</code> is the type of <code>N::value</code>.</p>
3314</div>
3315<table class="tableblock frame-all grid-all" style="width: 85%;">
3316<caption class="title">Illustration 9. mp_iota</caption>
3317<colgroup>
3318<col style="width: 50%;">
3319<col style="width: 12.5%;">
3320<col style="width: 12.5%;">
3321<col style="width: 12.5%;">
3322<col style="width: 12.5%;">
3323</colgroup>
3324<tbody>
3325<tr>
3326<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_iota&lt;mp_int&lt;4&gt;&gt;</strong></code></p></td>
3327<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_int&lt;0&gt;</code></p></td>
3328<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_int&lt;1&gt;</code></p></td>
3329<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_int&lt;2&gt;</code></p></td>
3330<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_int&lt;3&gt;</code></p></td>
3331</tr>
3332</tbody>
3333</table>
3334</div>
3335<div class="sect3">
3336<h4 id="mp_at_cl_i">mp_at_c&lt;L, I&gt;</h4>
3337<div class="literalblock">
3338<div class="content">
3339<pre>template&lt;class L, std::size_t I&gt; using mp_at_c = /*...*/;</pre>
3340</div>
3341</div>
3342<div class="paragraph">
3343<p><code>mp_at_c&lt;L, I&gt;</code> returns the <code>I</code>-th element of <code>L</code>, zero-based.</p>
3344</div>
3345</div>
3346<div class="sect3">
3347<h4 id="mp_atl_i">mp_at&lt;L, I&gt;</h4>
3348<div class="literalblock">
3349<div class="content">
3350<pre>template&lt;class L, class I&gt; using mp_at = /*...*/;</pre>
3351</div>
3352</div>
3353<div class="paragraph">
3354<p>Same as <code>mp_at_c</code>, but with a type argument <code>I</code>. <code>I::value</code> must be a nonnegative number.</p>
3355</div>
3356</div>
3357<div class="sect3">
3358<h4 id="mp_take_cl_n">mp_take_c&lt;L, N&gt;</h4>
3359<div class="literalblock">
3360<div class="content">
3361<pre>template&lt;class L, std::size_t N&gt; using mp_take_c = /*...*/;</pre>
3362</div>
3363</div>
3364<div class="paragraph">
3365<p><code>mp_take_c&lt;L, N&gt;</code> returns a list of the same form as <code>L</code> containing the first <code>N</code> elements of <code>L</code>.</p>
3366</div>
3367<table class="tableblock frame-all grid-all" style="width: 85%;">
3368<caption class="title">Illustration 10. mp_take_c</caption>
3369<colgroup>
3370<col style="width: 40%;">
3371<col style="width: 10%;">
3372<col style="width: 10%;">
3373<col style="width: 10%;">
3374<col style="width: 10%;">
3375<col style="width: 10%;">
3376<col style="width: 10%;">
3377</colgroup>
3378<tbody>
3379<tr>
3380<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3381<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3382<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3383<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3384<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3385<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3386<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3387</tr>
3388<tr>
3389<td class="tableblock halign-left valign-middle" colspan="7"></td>
3390</tr>
3391<tr>
3392<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_take_c&lt;L1, M&gt;</strong></code></p></td>
3393<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3394<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3395<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3396<td class="tableblock halign-center valign-middle" colspan="3"></td>
3397</tr>
3398</tbody>
3399</table>
3400</div>
3401<div class="sect3">
3402<h4 id="mp_takel_n">mp_take&lt;L, N&gt;</h4>
3403<div class="literalblock">
3404<div class="content">
3405<pre>template&lt;class L, class N&gt; using mp_take = /*...*/;</pre>
3406</div>
3407</div>
3408<div class="paragraph">
3409<p>Same as <code>mp_take_c</code>, but with a type argument <code>N</code>. <code>N::value</code> must be a nonnegative number.</p>
3410</div>
3411</div>
3412<div class="sect3">
3413<h4 id="mp_backl">mp_back&lt;L&gt;</h4>
3414<div class="literalblock">
3415<div class="content">
3416<pre>template&lt;class L&gt; using mp_back = mp_at_c&lt;L, mp_size&lt;L&gt;::value - 1&gt;;</pre>
3417</div>
3418</div>
3419<div class="paragraph">
3420<p><code>mp_back&lt;L&gt;</code> returns the last element of the list <code>L</code>.</p>
3421</div>
3422</div>
3423<div class="sect3">
3424<h4 id="mp_pop_backl">mp_pop_back&lt;L&gt;</h4>
3425<div class="literalblock">
3426<div class="content">
3427<pre>template&lt;class L&gt; using mp_pop_back = mp_take_c&lt;L, mp_size&lt;L&gt;::value - 1&gt;;</pre>
3428</div>
3429</div>
3430<div class="paragraph">
3431<p><code>mp_pop_back&lt;L&gt;</code> removes the last element of the list <code>L</code> and returns the result.</p>
3432</div>
3433</div>
3434<div class="sect3">
3435<h4 id="mp_insert_cl_i_t">mp_insert_c&lt;L, I, T&#8230;&#8203;&gt;</h4>
3436<div class="literalblock">
3437<div class="content">
3438<pre>template&lt;class L, std::size_t I, class... T&gt; using mp_insert_c =
3439    mp_append&lt;mp_take_c&lt;L, I&gt;, mp_push_front&lt;mp_drop_c&lt;L, I&gt;, T...&gt;&gt;;</pre>
3440</div>
3441</div>
3442<div class="paragraph">
3443<p>Inserts the elements <code>T&#8230;&#8203;</code> into the list <code>L</code> at position <code>I</code> (a zero-based index).</p>
3444</div>
3445<table class="tableblock frame-all grid-all" style="width: 85%;">
3446<caption class="title">Illustration 11. mp_insert_c with two elements</caption>
3447<colgroup>
3448<col style="width: 33.3333%;">
3449<col style="width: 8.3333%;">
3450<col style="width: 8.3333%;">
3451<col style="width: 8.3333%;">
3452<col style="width: 8.3333%;">
3453<col style="width: 8.3333%;">
3454<col style="width: 8.3333%;">
3455<col style="width: 8.3333%;">
3456<col style="width: 8.3336%;">
3457</colgroup>
3458<tbody>
3459<tr>
3460<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3461<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3462<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3463<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3464<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3465<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3466<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3467<td class="tableblock halign-center valign-middle" colspan="2"></td>
3468</tr>
3469<tr>
3470<td class="tableblock halign-left valign-middle" colspan="9"></td>
3471</tr>
3472<tr>
3473<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_insert_c&lt;L1, M, B<sub>1</sub>, B<sub>2</sub>&gt;</strong></code></p></td>
3474<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3475<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3476<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3477<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
3478<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
3479<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3480<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3481<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3482</tr>
3483</tbody>
3484</table>
3485</div>
3486<div class="sect3">
3487<h4 id="mp_insertl_i_t">mp_insert&lt;L, I, T&#8230;&#8203;&gt;</h4>
3488<div class="literalblock">
3489<div class="content">
3490<pre>template&lt;class L, class I, class... T&gt; using mp_insert =
3491    mp_append&lt;mp_take&lt;L, I&gt;, mp_push_front&lt;mp_drop&lt;L, I&gt;, T...&gt;&gt;;</pre>
3492</div>
3493</div>
3494<div class="paragraph">
3495<p>Same as <code>mp_insert_c</code>, but with a type argument <code>I</code>.</p>
3496</div>
3497</div>
3498<div class="sect3">
3499<h4 id="mp_erase_cl_i_j">mp_erase_c&lt;L, I, J&gt;</h4>
3500<div class="literalblock">
3501<div class="content">
3502<pre>template&lt;class L, std::size_t I, std::size_t J&gt; using mp_erase_c =
3503    mp_append&lt;mp_take_c&lt;L, I&gt;, mp_drop_c&lt;L, J&gt;&gt;;</pre>
3504</div>
3505</div>
3506<div class="paragraph">
3507<p>Removes from the list <code>L</code> the elements with indices from <code>I</code> (inclusive) to <code>J</code> (exclusive).</p>
3508</div>
3509<table class="tableblock frame-all grid-all" style="width: 85%;">
3510<caption class="title">Illustration 12. mp_erase_c</caption>
3511<colgroup>
3512<col style="width: 30.7692%;">
3513<col style="width: 7.6923%;">
3514<col style="width: 7.6923%;">
3515<col style="width: 7.6923%;">
3516<col style="width: 7.6923%;">
3517<col style="width: 7.6923%;">
3518<col style="width: 7.6923%;">
3519<col style="width: 7.6923%;">
3520<col style="width: 7.6923%;">
3521<col style="width: 7.6924%;">
3522</colgroup>
3523<tbody>
3524<tr>
3525<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3526<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>0</sub></code></p></td>
3527<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3528<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>i-1</sub></code></p></td>
3529<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>i</sub></code></p></td>
3530<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3531<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>j-1</sub></code></p></td>
3532<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>j</sub></code></p></td>
3533<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3534<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n-1</sub></code></p></td>
3535</tr>
3536<tr>
3537<td class="tableblock halign-left valign-middle" colspan="10"></td>
3538</tr>
3539<tr>
3540<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_erase_c&lt;L1, I, J&gt;</strong></code></p></td>
3541<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>0</sub></code></p></td>
3542<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3543<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>i-1</sub></code></p></td>
3544<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>j</sub></code></p></td>
3545<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3546<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n-1</sub></code></p></td>
3547<td class="tableblock halign-center valign-middle" colspan="3"></td>
3548</tr>
3549</tbody>
3550</table>
3551</div>
3552<div class="sect3">
3553<h4 id="mp_erasel_i_j">mp_erase&lt;L, I, J&gt;</h4>
3554<div class="literalblock">
3555<div class="content">
3556<pre>template&lt;class L, class I, class J&gt; using mp_erase =
3557    mp_append&lt;mp_take&lt;L, I&gt;, mp_drop&lt;L, J&gt;&gt;;</pre>
3558</div>
3559</div>
3560<div class="paragraph">
3561<p>Same as <code>mp_erase_c</code>, but with a type arguments <code>I</code> and <code>J</code>.</p>
3562</div>
3563</div>
3564<div class="sect3">
3565<h4 id="mp_replacel_v_w">mp_replace&lt;L, V, W&gt;</h4>
3566<div class="literalblock">
3567<div class="content">
3568<pre>template&lt;class L, class V, class W&gt; using mp_replace = /*...*/;</pre>
3569</div>
3570</div>
3571<div class="paragraph">
3572<p>Replaces all <code>V</code> elements of <code>L</code> with <code>W</code> and returns the result.</p>
3573</div>
3574<table class="tableblock frame-all grid-all" style="width: 85%;">
3575<caption class="title">Illustration 13. mp_replace</caption>
3576<colgroup>
3577<col style="width: 50%;">
3578<col style="width: 12.5%;">
3579<col style="width: 12.5%;">
3580<col style="width: 12.5%;">
3581<col style="width: 12.5%;">
3582</colgroup>
3583<tbody>
3584<tr>
3585<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3586<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3587<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>V</code></p></td>
3588<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3589<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3590</tr>
3591<tr>
3592<td class="tableblock halign-left valign-middle" colspan="5"></td>
3593</tr>
3594<tr>
3595<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_replace&lt;L1, V, W&gt;</strong></code></p></td>
3596<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3597<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>W</code></p></td>
3598<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3599<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3600</tr>
3601</tbody>
3602</table>
3603</div>
3604<div class="sect3">
3605<h4 id="mp_replace_ifl_p_w">mp_replace_if&lt;L, P, W&gt;</h4>
3606<div class="literalblock">
3607<div class="content">
3608<pre>template&lt;class L, template&lt;class...&gt; class P, class W&gt; using mp_replace_if = /*...*/;</pre>
3609</div>
3610</div>
3611<div class="paragraph">
3612<p>Replaces all <code>T</code> elements of <code>L</code> for which <code>mp_to_bool&lt;P&lt;T&gt;&gt;</code> is <code>mp_true</code> with <code>W</code> and returns the result.</p>
3613</div>
3614<table class="tableblock frame-all grid-all" style="width: 85%;">
3615<caption class="title">Illustration 14. mp_replace_if</caption>
3616<colgroup>
3617<col style="width: 50%;">
3618<col style="width: 12.5%;">
3619<col style="width: 12.5%;">
3620<col style="width: 12.5%;">
3621<col style="width: 12.5%;">
3622</colgroup>
3623<tbody>
3624<tr>
3625<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3626<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3627<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
3628<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3629<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3630</tr>
3631<tr>
3632<td class="tableblock halign-left valign-middle" colspan="5"></td>
3633</tr>
3634<tr>
3635<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>P&lt;A<sub>i</sub>&gt;</strong></code></p></td>
3636<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
3637<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_true</code></p></td>
3638<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3639<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
3640</tr>
3641<tr>
3642<td class="tableblock halign-left valign-middle" colspan="5"></td>
3643</tr>
3644<tr>
3645<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_replace_if&lt;L1, P, W&gt;</strong></code></p></td>
3646<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3647<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>W</code></p></td>
3648<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
3649<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3650</tr>
3651</tbody>
3652</table>
3653</div>
3654<div class="sect3">
3655<h4 id="mp_replace_if_ql_q_w">mp_replace_if_q&lt;L, Q, W&gt;</h4>
3656<div class="literalblock">
3657<div class="content">
3658<pre>template&lt;class L, class Q, class W&gt; using mp_replace_if_q =
3659    mp_replace_if&lt;L, Q::template fn, W&gt;;</pre>
3660</div>
3661</div>
3662<div class="paragraph">
3663<p>As <code>mp_replace_if</code>, but takes a quoted metafunction.</p>
3664</div>
3665</div>
3666<div class="sect3">
3667<h4 id="mp_replace_at_cl_i_w">mp_replace_at_c&lt;L, I, W&gt;</h4>
3668<div class="literalblock">
3669<div class="content">
3670<pre>template&lt;class L, std::size_t I, class W&gt; using mp_replace_at_c = /*...*/;</pre>
3671</div>
3672</div>
3673<div class="paragraph">
3674<p>Replaces the element of <code>L</code> at zero-based index <code>I</code> with <code>W</code> and returns the result.</p>
3675</div>
3676</div>
3677<div class="sect3">
3678<h4 id="mp_replace_atl_i_w">mp_replace_at&lt;L, I, W&gt;</h4>
3679<div class="literalblock">
3680<div class="content">
3681<pre>template&lt;class L, class I, class W&gt; using mp_replace_at = /*...*/;</pre>
3682</div>
3683</div>
3684<div class="paragraph">
3685<p>Same as <code>mp_replace_at_c</code>, but with a type argument <code>I</code>. <code>I::value</code> must be a nonnegative number.</p>
3686</div>
3687</div>
3688<div class="sect3">
3689<h4 id="mp_rotate_left_cl_n">mp_rotate_left_c&lt;L, N&gt;</h4>
3690<div class="literalblock">
3691<div class="content">
3692<pre>template&lt;class L, std::size_t N&gt; using mp_rotate_left_c = /*...*/;</pre>
3693</div>
3694</div>
3695<div class="paragraph">
3696<p>Moves the <code>N % M</code> initial elements of the list <code>L</code> to the back, where <code>M</code> is the size of <code>L</code>. Empty
3697lists are unchanged.</p>
3698</div>
3699</div>
3700<div class="sect3">
3701<h4 id="mp_rotate_leftl_n">mp_rotate_left&lt;L, N&gt;</h4>
3702<div class="literalblock">
3703<div class="content">
3704<pre>template&lt;class L, class N&gt; using mp_rotate_left = /*...*/;</pre>
3705</div>
3706</div>
3707<div class="paragraph">
3708<p>Same as <code>mp_rotate_left_c</code>, but with a type argument <code>N</code>. <code>N::value</code> must be a nonnegative number.</p>
3709</div>
3710</div>
3711<div class="sect3">
3712<h4 id="mp_rotate_right_cl_n">mp_rotate_right_c&lt;L, N&gt;</h4>
3713<div class="literalblock">
3714<div class="content">
3715<pre>template&lt;class L, std::size_t N&gt; using mp_rotate_right_c = /*...*/;</pre>
3716</div>
3717</div>
3718<div class="paragraph">
3719<p>Moves the <code>N % M</code> trailing elements of the list <code>L</code> to the front, where <code>M</code> is the size of <code>L</code>. Empty
3720lists are unchanged.</p>
3721</div>
3722</div>
3723<div class="sect3">
3724<h4 id="mp_rotate_rightl_n">mp_rotate_right&lt;L, N&gt;</h4>
3725<div class="literalblock">
3726<div class="content">
3727<pre>template&lt;class L, class N&gt; using mp_rotate_right = /*...*/;</pre>
3728</div>
3729</div>
3730<div class="paragraph">
3731<p>Same as <code>mp_rotate_right_c</code>, but with a type argument <code>N</code>. <code>N::value</code> must be a nonnegative number.</p>
3732</div>
3733</div>
3734<div class="sect3">
3735<h4 id="mp_copy_ifl_p">mp_copy_if&lt;L, P&gt;</h4>
3736<div class="literalblock">
3737<div class="content">
3738<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_copy_if = /*...*/;</pre>
3739</div>
3740</div>
3741<div class="paragraph">
3742<p>Copies the elements <code>T</code> of <code>L</code> for which <code>mp_to_bool&lt;P&lt;T&gt;&gt;</code> is <code>mp_true</code> to a new list of the same form and returns it.</p>
3743</div>
3744</div>
3745<div class="sect3">
3746<h4 id="mp_copy_if_ql_q">mp_copy_if_q&lt;L, Q&gt;</h4>
3747<div class="literalblock">
3748<div class="content">
3749<pre>template&lt;class L, class Q&gt; using mp_copy_if_q = mp_copy_if&lt;L, Q::template fn&gt;;</pre>
3750</div>
3751</div>
3752<div class="paragraph">
3753<p>As <code>mp_copy_if</code>, but takes a quoted metafunction.</p>
3754</div>
3755</div>
3756<div class="sect3">
3757<h4 id="mp_removel_v">mp_remove&lt;L, V&gt;</h4>
3758<div class="literalblock">
3759<div class="content">
3760<pre>template&lt;class L, class V&gt; using mp_remove = /*...*/;</pre>
3761</div>
3762</div>
3763<div class="paragraph">
3764<p>Removes all <code>V</code> elements of <code>L</code> and returns the result.</p>
3765</div>
3766</div>
3767<div class="sect3">
3768<h4 id="mp_remove_ifl_p">mp_remove_if&lt;L, P&gt;</h4>
3769<div class="literalblock">
3770<div class="content">
3771<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_remove_if = /*...*/;</pre>
3772</div>
3773</div>
3774<div class="paragraph">
3775<p>Removes all elements <code>T</code> of <code>L</code> for which <code>mp_to_bool&lt;P&lt;T&gt;&gt;</code> is <code>mp_true</code> and returns the result.</p>
3776</div>
3777</div>
3778<div class="sect3">
3779<h4 id="mp_remove_if_ql_q">mp_remove_if_q&lt;L, Q&gt;</h4>
3780<div class="literalblock">
3781<div class="content">
3782<pre>template&lt;class L, class Q&gt; using mp_remove_if_q = mp_remove_if&lt;L, Q::template fn&gt;;</pre>
3783</div>
3784</div>
3785<div class="paragraph">
3786<p>As <code>mp_remove_if</code>, but takes a quoted metafunction.</p>
3787</div>
3788</div>
3789<div class="sect3">
3790<h4 id="mp_flattenl">mp_flatten&lt;L&gt;</h4>
3791<div class="literalblock">
3792<div class="content">
3793<pre>template&lt;class L, class L2 = mp_clear&lt;L&gt;&gt; using mp_flatten = /*...*/;</pre>
3794</div>
3795</div>
3796<div class="paragraph">
3797<p>Replaces all elements <code>T</code> of <code>L</code> that are lists of the same form as <code>L2</code> (that is, those for which
3798<code>mp_similar&lt;T, L2&gt;</code> is <code>mp_true</code>) with their elements and returns the result.</p>
3799</div>
3800<div class="listingblock">
3801<div class="title">Code Example 62. Using mp_flatten</div>
3802<div class="content">
3803<pre class="highlight"><code>using L1 = tuple&lt;int, tuple&lt;&gt;, void, tuple&lt;float, double&gt;&gt;;
3804using R1 = mp_flatten&lt;L1&gt;; // tuple&lt;int, void, float, double&gt;
3805
3806using L2 = mp_list&lt;int, mp_list&lt;float&gt;, tuple&lt;void&gt;&gt;;
3807using R2a = mp_flatten&lt;L2&gt;; // mp_list&lt;int, float, tuple&lt;void&gt;&gt;
3808using R2b = mp_flatten&lt;L2, tuple&lt;&gt;&gt;; // mp_list&lt;int, mp_list&lt;float&gt;, void&gt;
3809
3810using L3 = mp_list&lt;mp_list&lt;float&gt;, mp_list&lt;mp_list&lt;void&gt;&gt;&gt;;
3811using R3 = mp_flatten&lt;L3&gt;; // mp_list&lt;float, mp_list&lt;void&gt;&gt;</code></pre>
3812</div>
3813</div>
3814</div>
3815<div class="sect3">
3816<h4 id="mp_partitionl_p">mp_partition&lt;L, P&gt;</h4>
3817<div class="literalblock">
3818<div class="content">
3819<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_partition = /*...*/;</pre>
3820</div>
3821</div>
3822<div class="paragraph">
3823<p><code>mp_partition&lt;L&lt;T&#8230;&#8203;&gt;, P&gt;</code> partitions <code>L</code> into two lists <code>L&lt;U1&#8230;&#8203;&gt;</code> and <code>L&lt;U2&#8230;&#8203;&gt;</code> such that <code>mp_to_bool&lt;P&lt;T&gt;&gt;</code> is <code>mp_true</code>
3824for the elements of <code>L&lt;U1&#8230;&#8203;&gt;</code> and <code>mp_false</code> for the elements of <code>L&lt;U2&#8230;&#8203;&gt;</code>. Returns <code>L&lt;L&lt;U1&#8230;&#8203;&gt;, L&lt;U2&#8230;&#8203;&gt;&gt;</code>.</p>
3825</div>
3826</div>
3827<div class="sect3">
3828<h4 id="mp_partition_ql_q">mp_partition_q&lt;L, Q&gt;</h4>
3829<div class="literalblock">
3830<div class="content">
3831<pre>template&lt;class L, class Q&gt; using mp_partition_q = mp_partition&lt;L, Q::template fn&gt;;</pre>
3832</div>
3833</div>
3834<div class="paragraph">
3835<p>As <code>mp_partition</code>, but takes a quoted metafunction.</p>
3836</div>
3837</div>
3838<div class="sect3">
3839<h4 id="mp_sortl_p">mp_sort&lt;L, P&gt;</h4>
3840<div class="literalblock">
3841<div class="content">
3842<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_sort = /*...*/;</pre>
3843</div>
3844</div>
3845<div class="paragraph">
3846<p><code>mp_sort&lt;L, P&gt;</code> sorts the list <code>L</code> according to the strict weak ordering <code>mp_to_bool&lt;P&lt;T, U&gt;&gt;</code>.</p>
3847</div>
3848<div class="listingblock">
3849<div class="title">Code Example 63. Using mp_sort to sort a list of std::ratio values</div>
3850<div class="content">
3851<pre>#include &lt;ratio&gt;
3852
3853using L1 = mp_list&lt;std::ratio&lt;1,2&gt;, std::ratio&lt;1,4&gt;&gt;;
3854using R1 = mp_sort&lt;L1, std::ratio_less&gt;; // mp_list&lt;ratio&lt;1,4&gt;, ratio&lt;1,2&gt;&gt;</pre>
3855</div>
3856</div>
3857</div>
3858<div class="sect3">
3859<h4 id="mp_sort_ql_q">mp_sort_q&lt;L, Q&gt;</h4>
3860<div class="literalblock">
3861<div class="content">
3862<pre>template&lt;class L, class Q&gt; using mp_sort_q = mp_sort&lt;L, Q::template fn&gt;;</pre>
3863</div>
3864</div>
3865<div class="paragraph">
3866<p>As <code>mp_sort</code>, but takes a quoted metafunction.</p>
3867</div>
3868</div>
3869<div class="sect3">
3870<h4 id="mp_nth_element_cl_i_p">mp_nth_element_c&lt;L, I, P&gt;</h4>
3871<div class="literalblock">
3872<div class="content">
3873<pre>template&lt;class L, std::size_t I, template&lt;class...&gt; class P&gt; using mp_nth_element_c =
3874    /*...*/;</pre>
3875</div>
3876</div>
3877<div class="paragraph">
3878<p>Returns the element at position <code>I</code> in <code>mp_sort&lt;L, P&gt;</code>.</p>
3879</div>
3880</div>
3881<div class="sect3">
3882<h4 id="mp_nth_elementl_i_p">mp_nth_element&lt;L, I, P&gt;</h4>
3883<div class="literalblock">
3884<div class="content">
3885<pre>template&lt;class L, class I, template&lt;class...&gt; class P&gt; using mp_nth_element = /*...*/;</pre>
3886</div>
3887</div>
3888<div class="paragraph">
3889<p>Like <code>mp_nth_element_c</code>, but with a type argument <code>I</code>. <code>I::value</code> must be a nonnegative number.</p>
3890</div>
3891</div>
3892<div class="sect3">
3893<h4 id="mp_nth_element_ql_i_q">mp_nth_element_q&lt;L, I, Q&gt;</h4>
3894<div class="literalblock">
3895<div class="content">
3896<pre>template&lt;class L, class I, class Q&gt; using mp_nth_element_q =
3897    mp_nth_element&lt;L, I, Q::template fn&gt;;</pre>
3898</div>
3899</div>
3900<div class="paragraph">
3901<p>Like <code>mp_nth_element</code>, but takes a quoted metafunction.</p>
3902</div>
3903</div>
3904<div class="sect3">
3905<h4 id="mp_min_elementl_p">mp_min_element&lt;L, P&gt;</h4>
3906<div class="literalblock">
3907<div class="content">
3908<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_min_element = /*...*/;</pre>
3909</div>
3910</div>
3911<div class="paragraph">
3912<p><code>mp_min_element&lt;L, P&gt;</code> returns the minimal element of the list <code>L</code> according to the ordering <code>mp_to_bool&lt;P&lt;T, U&gt;&gt;</code>.</p>
3913</div>
3914<div class="paragraph">
3915<p>It&#8217;s equivalent to <code>mp_fold&lt;mp_rest&lt;L&gt;, mp_first&lt;L&gt;, F&gt;</code>, where <code>F&lt;T, U&gt;</code> returns <code>mp_if&lt;P&lt;T, U&gt;, T, U&gt;</code>.</p>
3916</div>
3917</div>
3918<div class="sect3">
3919<h4 id="mp_min_element_ql_q">mp_min_element_q&lt;L, Q&gt;</h4>
3920<div class="literalblock">
3921<div class="content">
3922<pre>template&lt;class L, class Q&gt; using mp_min_element_q = mp_min_element&lt;L, Q::template fn&gt;;</pre>
3923</div>
3924</div>
3925<div class="paragraph">
3926<p>As <code>mp_min_element</code>, but takes a quoted metafunction.</p>
3927</div>
3928</div>
3929<div class="sect3">
3930<h4 id="mp_max_elementl_p">mp_max_element&lt;L, P&gt;</h4>
3931<div class="literalblock">
3932<div class="content">
3933<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_max_element = /*...*/;</pre>
3934</div>
3935</div>
3936<div class="paragraph">
3937<p><code>mp_max_element&lt;L, P&gt;</code> returns the maximal element of the list <code>L</code> according to the ordering <code>mp_to_bool&lt;P&lt;T, U&gt;&gt;</code>.</p>
3938</div>
3939<div class="paragraph">
3940<p>It&#8217;s equivalent to <code>mp_fold&lt;mp_rest&lt;L&gt;, mp_first&lt;L&gt;, F&gt;</code>, where <code>F&lt;T, U&gt;</code> returns <code>mp_if&lt;P&lt;U, T&gt;, T, U&gt;</code>.</p>
3941</div>
3942</div>
3943<div class="sect3">
3944<h4 id="mp_max_element_ql_q">mp_max_element_q&lt;L, Q&gt;</h4>
3945<div class="literalblock">
3946<div class="content">
3947<pre>template&lt;class L, class Q&gt; using mp_max_element_q = mp_max_element&lt;L, Q::template fn&gt;;</pre>
3948</div>
3949</div>
3950<div class="paragraph">
3951<p>As <code>mp_max_element</code>, but takes a quoted metafunction.</p>
3952</div>
3953</div>
3954<div class="sect3">
3955<h4 id="mp_findl_v">mp_find&lt;L, V&gt;</h4>
3956<div class="literalblock">
3957<div class="content">
3958<pre>template&lt;class L, class V&gt; using mp_find = /*...*/;</pre>
3959</div>
3960</div>
3961<div class="paragraph">
3962<p><code>mp_find&lt;L, V&gt;</code> returns the index at which the type <code>V</code> is located in the list <code>L</code>. It&#8217;s an alias for <code>mp_size_t&lt;I&gt;</code>,
3963where <code>I</code> is the zero-based index of the first occurrence of <code>V</code> in <code>L</code>. If <code>L</code> does not contain <code>V</code>, <code>mp_find&lt;L, V&gt;</code>
3964is <code>mp_size&lt;L&gt;</code>.</p>
3965</div>
3966</div>
3967<div class="sect3">
3968<h4 id="mp_find_ifl_p">mp_find_if&lt;L, P&gt;</h4>
3969<div class="literalblock">
3970<div class="content">
3971<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_find_if = /*...*/;</pre>
3972</div>
3973</div>
3974<div class="paragraph">
3975<p><code>mp_find_f&lt;L, P&gt;</code> is an alias for <code>mp_size_t&lt;I&gt;</code>, where <code>I</code> is the zero-based index of the first element <code>T</code> in <code>L</code> for which
3976<code>mp_to_bool&lt;P&lt;T&gt;&gt;</code> is <code>mp_true</code>. If there is no such element, <code>mp_find_if&lt;L, P&gt;</code> is <code>mp_size&lt;L&gt;</code>.</p>
3977</div>
3978</div>
3979<div class="sect3">
3980<h4 id="mp_find_if_ql_q">mp_find_if_q&lt;L, Q&gt;</h4>
3981<div class="literalblock">
3982<div class="content">
3983<pre>template&lt;class L, class Q&gt; using mp_find_if_q = mp_find_if&lt;L, Q::template fn&gt;;</pre>
3984</div>
3985</div>
3986<div class="paragraph">
3987<p>As <code>mp_find_if</code>, but takes a quoted metafunction.</p>
3988</div>
3989</div>
3990<div class="sect3">
3991<h4 id="mp_reversel">mp_reverse&lt;L&gt;</h4>
3992<div class="literalblock">
3993<div class="content">
3994<pre>template&lt;class L&gt; using mp_reverse = /*...*/;</pre>
3995</div>
3996</div>
3997<div class="paragraph">
3998<p><code>mp_reverse&lt;L&lt;T1, T2, &#8230;&#8203;, Tn&gt;&gt;</code> is <code>L&lt;Tn, &#8230;&#8203;, T2, T1&gt;</code>.</p>
3999</div>
4000<table class="tableblock frame-all grid-all" style="width: 85%;">
4001<caption class="title">Illustration 15. mp_reverse</caption>
4002<colgroup>
4003<col style="width: 50%;">
4004<col style="width: 12.5%;">
4005<col style="width: 12.5%;">
4006<col style="width: 12.5%;">
4007<col style="width: 12.5%;">
4008</colgroup>
4009<tbody>
4010<tr>
4011<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
4012<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
4013<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
4014<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
4015<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
4016</tr>
4017<tr>
4018<td class="tableblock halign-left valign-middle" colspan="5"></td>
4019</tr>
4020<tr>
4021<td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_reverse&lt;L1&gt;</strong></code></p></td>
4022<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
4023<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n-1</sub></code></p></td>
4024<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>&#8230;&#8203;</code></p></td>
4025<td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
4026</tr>
4027</tbody>
4028</table>
4029</div>
4030<div class="sect3">
4031<h4 id="mp_foldl_v_f">mp_fold&lt;L, V, F&gt;</h4>
4032<div class="literalblock">
4033<div class="content">
4034<pre>template&lt;class L, class V, template&lt;class...&gt; class F&gt; using mp_fold = /*...*/;</pre>
4035</div>
4036</div>
4037<div class="paragraph">
4038<p><code>mp_fold&lt;L&lt;T1, T2, &#8230;&#8203;, Tn&gt;, V, F&gt;</code> is <code>F&lt; F&lt; F&lt; F&lt;V, T1&gt;, T2&gt;, &#8230;&#8203;&gt;, Tn&gt;</code>, or <code>V</code>, if <code>L</code> is empty.</p>
4039</div>
4040<div class="listingblock">
4041<div class="title">Code Example 64. Using mp_fold to add the contents of a list of std::ratio values</div>
4042<div class="content">
4043<pre>#include &lt;ratio&gt;
4044
4045using L1 = mp_list&lt;std::ratio&lt;1,8&gt;, std::ratio&lt;1,4&gt;, std::ratio&lt;1,2&gt;&gt;;
4046using R1 = mp_fold&lt;L1, std::ratio&lt;0,1&gt;, std::ratio_add&gt;; // std::ratio&lt;7,8&gt;</pre>
4047</div>
4048</div>
4049</div>
4050<div class="sect3">
4051<h4 id="mp_fold_ql_v_q">mp_fold_q&lt;L, V, Q&gt;</h4>
4052<div class="literalblock">
4053<div class="content">
4054<pre>template&lt;class L, class V, class Q&gt; using mp_fold_q =
4055    mp_fold&lt;L, V, Q::template fn&gt;;</pre>
4056</div>
4057</div>
4058<div class="paragraph">
4059<p>As <code>mp_fold</code>, but takes a quoted metafunction.</p>
4060</div>
4061</div>
4062<div class="sect3">
4063<h4 id="mp_reverse_foldl_v_f">mp_reverse_fold&lt;L, V, F&gt;</h4>
4064<div class="literalblock">
4065<div class="content">
4066<pre>template&lt;class L, class V, template&lt;class...&gt; class F&gt; using mp_reverse_fold =
4067    /*...*/;</pre>
4068</div>
4069</div>
4070<div class="paragraph">
4071<p><code>mp_reverse_fold&lt;L&lt;T1, T2, &#8230;&#8203;, Tn&gt;, V, F&gt;</code> is <code>F&lt;T1, F&lt;T2, F&lt;&#8230;&#8203;, F&lt;Tn, V&gt;&gt;&gt;&gt;</code>, or <code>V</code>, if <code>L</code> is empty.</p>
4072</div>
4073</div>
4074<div class="sect3">
4075<h4 id="mp_reverse_fold_ql_v_q">mp_reverse_fold_q&lt;L, V, Q&gt;</h4>
4076<div class="literalblock">
4077<div class="content">
4078<pre>template&lt;class L, class V, class Q&gt; using mp_reverse_fold_q =
4079    mp_reverse_fold&lt;L, V, Q::template fn&gt;;</pre>
4080</div>
4081</div>
4082<div class="paragraph">
4083<p>As <code>mp_reverse_fold</code>, but takes a quoted metafunction.</p>
4084</div>
4085</div>
4086<div class="sect3">
4087<h4 id="mp_partial_suml_v_f">mp_partial_sum&lt;L, V, F&gt;</h4>
4088<div class="literalblock">
4089<div class="content">
4090<pre>template&lt;class L, class V, template&lt;class...&gt; class F&gt; using mp_partial_sum = /*...*/;</pre>
4091</div>
4092</div>
4093<div class="paragraph">
4094<p><code>mp_partial_sum&lt;L, V, F&gt;</code> is similar to <code>mp_fold&lt;L, V, F&gt;</code>, but instead of its final result, it returns
4095a list (of the same form as <code>L</code>) holding the intermediate results of the fold. The last element of the
4096result of <code>mp_partial_sum</code> is the same as the result of <code>mp_fold</code>.</p>
4097</div>
4098<div class="paragraph">
4099<p>For example, <code>mp_fold&lt;mp_list&lt;X1, X2, X3&gt;, V, F&gt;</code> is <code>F&lt;F&lt;F&lt;V, X1&gt;, X2&gt;, X3&gt;</code>, but
4100<code>mp_partial_sum&lt;mp_list&lt;X1, X2, X3&gt;, V, F&gt;</code> is <code>mp_list&lt;F&lt;V, X1&gt;, F&lt;F&lt;V, X1&gt;, X2&gt;, F&lt;F&lt;F&lt;V, X1&gt;, X2&gt;, X3&gt;&gt;</code>.</p>
4101</div>
4102<div class="paragraph">
4103<p>It&#8217;s common for <code>F</code> to be <code>mp_plus</code>, in which case the result contains the partial sums of <code>L</code>.</p>
4104</div>
4105<div class="listingblock">
4106<div class="title">Code Example 65. Using mp_partial_sum</div>
4107<div class="content">
4108<pre>using L1 = mp_list_c&lt;int, 1, 2, 3, 4&gt;;
4109using R1 = mp_partial_sum&lt;L1, mp_int&lt;0&gt;, mp_plus&gt;; // mp_list_c&lt;int, 1, 3, 6, 10&gt;</pre>
4110</div>
4111</div>
4112</div>
4113<div class="sect3">
4114<h4 id="mp_partial_sum_ql_v_q">mp_partial_sum_q&lt;L, V, Q&gt;</h4>
4115<div class="literalblock">
4116<div class="content">
4117<pre>template&lt;class L, class V, class Q&gt; using mp_partial_sum_q =
4118    mp_partial_sum&lt;L, V, Q::template fn&gt;;</pre>
4119</div>
4120</div>
4121<div class="paragraph">
4122<p>As <code>mp_partial_sum</code>, but takes a quoted metafunction.</p>
4123</div>
4124</div>
4125<div class="sect3">
4126<h4 id="mp_iteratev_f_r">mp_iterate&lt;V, F, R&gt;</h4>
4127<div class="literalblock">
4128<div class="content">
4129<pre>template&lt;class V, template&lt;class...&gt; class F, template&lt;class...&gt; class R&gt;
4130    using mp_iterate = /*...*/;</pre>
4131</div>
4132</div>
4133<div class="paragraph">
4134<p><code>mp_iterate&lt;V, F, R&gt;</code> applies <code>R</code> to <code>V</code> successively until that&#8217;s no longer possible,
4135yielding the sequence <code>V</code>, <code>R&lt;V&gt;</code>, <code>R&lt;R&lt;V&gt;&gt;</code>, <code>R&lt;R&lt;R&lt;V&gt;&gt;&gt;</code>&#8230;&#8203;</p>
4136</div>
4137<div class="paragraph">
4138<p>It then returns an <code>mp_list</code> whose elements are formed by applying <code>F</code> to the above
4139sequence of values. That is, it returns <code>mp_list&lt;F&lt;V&gt;, F&lt;R&lt;V&gt;&gt;, F&lt;R&lt;R&lt;V&gt;&gt;&gt;, &#8230;&#8203;&gt;</code>.</p>
4140</div>
4141<div class="paragraph">
4142<p><code>mp_iterate</code> is in a way the reverse operation of <code>mp_reverse_fold</code>. Given</p>
4143</div>
4144<div class="literalblock">
4145<div class="content">
4146<pre>template&lt;class T, class U&gt; struct cons {};
4147struct nil {};</pre>
4148</div>
4149</div>
4150<div class="paragraph">
4151<p><code>mp_reverse_fold&lt;mp_list&lt;X1, X2, X3&gt;, nil, cons&gt;</code> produces <code>cons&lt;X1, cons&lt;X2, cons&lt;X3, nil&gt;&gt;&gt;</code>,
4152which when passed as <code>V</code> to <code>mp_iterate&lt;V, mp_first, mp_second&gt;</code> recovers the original
4153<code>mp_list&lt;X1, X2, X3&gt;</code>.</p>
4154</div>
4155<div class="listingblock">
4156<div class="title">Code Example 66. Using mp_iterate</div>
4157<div class="content">
4158<pre>struct X1 {};
4159struct X2 {};
4160struct X3 {};
4161
4162using L1 = mp_list&lt;X1, X2, X3&gt;;
4163using R1 = mp_iterate&lt;L1, mp_first, mp_rest&gt;; // L1
4164
4165template&lt;class T, class U&gt; struct cons {};
4166struct nil {};
4167
4168using V2 = mp_reverse_fold&lt;L1, nil, cons&gt;; // cons&lt;X1, cons&lt;X2, cons&lt;X3, nil&gt;&gt;&gt;
4169using R2 = mp_iterate&lt;V2, mp_first, mp_second&gt;; // L1
4170
4171struct Y1 {};
4172struct Y2 { using value_type = double; using next_type = Y1; };
4173struct Y3 { using value_type = float; using next_type = Y2; };
4174struct Y4 { using value_type = int; using next_type = Y3; };
4175
4176template&lt;class T&gt; using value_type = typename T::value_type;
4177template&lt;class T&gt; using next_type = typename T::next_type;
4178
4179using R3 = mp_iterate&lt;Y4, mp_identity_t, next_type&gt;; // mp_list&lt;Y4, Y3, Y2, Y1&gt;
4180using R4 = mp_iterate&lt;Y4, value_type, next_type&gt;; // mp_list&lt;int, float, double&gt;</pre>
4181</div>
4182</div>
4183</div>
4184<div class="sect3">
4185<h4 id="mp_iterate_qv_qf_qr">mp_iterate_q&lt;V, Qf, Qr&gt;</h4>
4186<div class="literalblock">
4187<div class="content">
4188<pre>template&lt;class V, class Qf, class Qr&gt; using mp_iterate_q =
4189    mp_iterate&lt;V, Qf::template fn, Qr::template fn&gt;;</pre>
4190</div>
4191</div>
4192<div class="paragraph">
4193<p>As <code>mp_iterate</code>, but takes quoted metafunctions.</p>
4194</div>
4195</div>
4196<div class="sect3">
4197<h4 id="mp_uniquel">mp_unique&lt;L&gt;</h4>
4198<div class="literalblock">
4199<div class="content">
4200<pre>template&lt;class L&gt; using mp_unique = /*...*/;</pre>
4201</div>
4202</div>
4203<div class="paragraph">
4204<p><code>mp_unique&lt;L&gt;</code> returns a list of the same form as <code>L</code> with the duplicate elements removed.</p>
4205</div>
4206</div>
4207<div class="sect3">
4208<h4 id="mp_unique_ifl_p">mp_unique_if&lt;L, P&gt;</h4>
4209<div class="literalblock">
4210<div class="content">
4211<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_unique_if = /*...*/;</pre>
4212</div>
4213</div>
4214<div class="paragraph">
4215<p>As <code>mp_unique</code>, but two elements <code>T</code> and <code>U</code> are considered duplicates when <code>mp_to_bool&lt;P&lt;T, U&gt;&gt;</code> is <code>mp_true</code>.</p>
4216</div>
4217</div>
4218<div class="sect3">
4219<h4 id="mp_unique_if_ql_q">mp_unique_if_q&lt;L, Q&gt;</h4>
4220<div class="literalblock">
4221<div class="content">
4222<pre>template&lt;class L, class Q&gt; using mp_unique_if_q =
4223    mp_unique_if&lt;L, Q::template fn&gt;;</pre>
4224</div>
4225</div>
4226<div class="paragraph">
4227<p>As <code>mp_unique_if</code>, but takes a quoted metafunction.</p>
4228</div>
4229</div>
4230<div class="sect3">
4231<h4 id="mp_all_ofl_p">mp_all_of&lt;L, P&gt;</h4>
4232<div class="literalblock">
4233<div class="content">
4234<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_all_of =
4235    mp_bool&lt; mp_count_if&lt;L, P&gt;::value == mp_size&lt;L&gt;::value &gt;;</pre>
4236</div>
4237</div>
4238<div class="paragraph">
4239<p><code>mp_all_of&lt;L, P&gt;</code> is <code>mp_true</code> when <code>P</code> holds for all elements of <code>L</code>, <code>mp_false</code> otherwise. When <code>L</code> is empty, the result is <code>mp_true</code>.</p>
4240</div>
4241</div>
4242<div class="sect3">
4243<h4 id="mp_all_of_ql_q">mp_all_of_q&lt;L, Q&gt;</h4>
4244<div class="literalblock">
4245<div class="content">
4246<pre>template&lt;class L, class Q&gt; using mp_all_of_q = mp_all_of&lt;L, Q::template fn&gt;;</pre>
4247</div>
4248</div>
4249<div class="paragraph">
4250<p>As <code>mp_all_of</code>, but takes a quoted metafunction.</p>
4251</div>
4252</div>
4253<div class="sect3">
4254<h4 id="mp_none_ofl_p">mp_none_of&lt;L, P&gt;</h4>
4255<div class="literalblock">
4256<div class="content">
4257<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_none_of =
4258    mp_bool&lt; mp_count_if&lt;L, P&gt;::value == 0 &gt;;</pre>
4259</div>
4260</div>
4261<div class="paragraph">
4262<p><code>mp_none_of&lt;L, P&gt;</code> is <code>mp_true</code> when <code>P</code> holds for no element of <code>L</code>, <code>mp_false</code> otherwise. When <code>L</code> is empty, the result is <code>mp_true</code>.</p>
4263</div>
4264</div>
4265<div class="sect3">
4266<h4 id="mp_none_of_ql_q">mp_none_of_q&lt;L, Q&gt;</h4>
4267<div class="literalblock">
4268<div class="content">
4269<pre>template&lt;class L, class Q&gt; using mp_none_of_q = mp_none_of&lt;L, Q::template fn&gt;;</pre>
4270</div>
4271</div>
4272<div class="paragraph">
4273<p>As <code>mp_none_of</code>, but takes a quoted metafunction.</p>
4274</div>
4275</div>
4276<div class="sect3">
4277<h4 id="mp_any_ofl_p">mp_any_of&lt;L, P&gt;</h4>
4278<div class="literalblock">
4279<div class="content">
4280<pre>template&lt;class L, template&lt;class...&gt; class P&gt; using mp_any_of =
4281    mp_bool&lt; mp_count_if&lt;L, P&gt;::value != 0 &gt;;</pre>
4282</div>
4283</div>
4284<div class="paragraph">
4285<p><code>mp_any_of&lt;L, P&gt;</code> is <code>mp_true</code> when <code>P</code> holds for at least one element of <code>L</code>, <code>mp_false</code> otherwise. When <code>L</code> is empty, the result is <code>mp_false</code>.</p>
4286</div>
4287</div>
4288<div class="sect3">
4289<h4 id="mp_any_of_ql_q">mp_any_of_q&lt;L, Q&gt;</h4>
4290<div class="literalblock">
4291<div class="content">
4292<pre>template&lt;class L, class Q&gt; using mp_any_of_q = mp_any_of&lt;L, Q::template fn&gt;;</pre>
4293</div>
4294</div>
4295<div class="paragraph">
4296<p>As <code>mp_any_of</code>, but takes a quoted metafunction.</p>
4297</div>
4298</div>
4299<div class="sect3">
4300<h4 id="mp_for_eachlf">mp_for_each&lt;L&gt;(f)</h4>
4301<div class="literalblock">
4302<div class="content">
4303<pre>template&lt;class L, class F&gt; constexpr F mp_for_each(F&amp;&amp; f);</pre>
4304</div>
4305</div>
4306<div class="paragraph">
4307<p><code>mp_for_each&lt;L&gt;(f)</code> calls <code>f</code> with <code>T()</code> for each element <code>T</code> of the list <code>L</code>, in order.</p>
4308</div>
4309<div class="paragraph">
4310<p>Returns <code>std::forward&lt;F&gt;(f)</code>.</p>
4311</div>
4312<div class="listingblock">
4313<div class="title">Code Example 67. Using mp_for_each and a C++14 lambda to print a tuple</div>
4314<div class="content">
4315<pre class="highlight"><code>template&lt;class... T&gt; void print( std::tuple&lt;T...&gt; const &amp; tp )
4316{
4317    std::size_t const N = sizeof...(T);
4318
4319    mp_for_each&lt;mp_iota_c&lt;N&gt;&gt;( [&amp;]( auto I ){
4320
4321        // I is mp_size_t&lt;0&gt;, mp_size_t&lt;1&gt;, ..., mp_size_t&lt;N-1&gt;
4322
4323        std::cout &lt;&lt; std::get&lt;I&gt;(tp) &lt;&lt; std::endl;
4324
4325    });
4326}</code></pre>
4327</div>
4328</div>
4329</div>
4330<div class="sect3">
4331<h4 id="mp_with_indexni_f">mp_with_index&lt;N&gt;(i, f)</h4>
4332<div class="literalblock">
4333<div class="content">
4334<pre>template&lt;std::size_t N, class F&gt;
4335  constexpr auto mp_with_index( std::size_t i, F &amp;&amp; f )
4336    -&gt; decltype(std::declval&lt;F&gt;()(std::declval&lt;mp_size_t&lt;0&gt;&gt;()));</pre>
4337</div>
4338</div>
4339<div class="paragraph">
4340<p><code>mp_with_index&lt;N&gt;(i, f)</code> calls <code>f</code> with <code>mp_size_t&lt;i&gt;()</code> and returns the result. <code>i</code> must be less than <code>N</code>.
4341Only <code>constexpr</code> on C++14 and higher.</p>
4342</div>
4343<div class="literalblock">
4344<div class="content">
4345<pre>template&lt;class N, class F&gt;
4346  constexpr auto mp_with_index( std::size_t i, F &amp;&amp; f )
4347    -&gt; decltype(std::declval&lt;F&gt;()(std::declval&lt;mp_size_t&lt;0&gt;&gt;()));</pre>
4348</div>
4349</div>
4350<div class="paragraph">
4351<p>Returns <code>mp_with_index&lt;N::value&gt;(i, f)</code>.</p>
4352</div>
4353<div class="listingblock">
4354<div class="title">Code Example 68. Using mp_with_index and a C++14 lambda to print the active element of a variant</div>
4355<div class="content">
4356<pre class="highlight"><code>template&lt;class... T&gt; void print( std::variant&lt;T...&gt; const&amp; v )
4357{
4358    mp_with_index&lt;sizeof...(T)&gt;( v.index(), [&amp;]( auto I ) {
4359
4360        // I is mp_size_t&lt;v.index()&gt;{} here
4361
4362        std::cout &lt;&lt; std::get&lt;I&gt;( v ) &lt;&lt; std::endl;
4363
4364    });
4365}</code></pre>
4366</div>
4367</div>
4368</div>
4369</div>
4370<div class="sect2">
4371<h3 id="set">Set Operations, &lt;boost/mp11/set.hpp&gt;</h3>
4372<div class="paragraph">
4373<p>A set is a list whose elements are unique.</p>
4374</div>
4375<div class="sect3">
4376<h4 id="mp_is_sets">mp_is_set&lt;S&gt;</h4>
4377<div class="literalblock">
4378<div class="content">
4379<pre>template&lt;class S&gt; using mp_is_set = /*...*/;</pre>
4380</div>
4381</div>
4382<div class="paragraph">
4383<p><code>mp_is_set&lt;S&gt;</code> is <code>mp_true</code> if <code>S</code> is a set, <code>mp_false</code> otherwise.</p>
4384</div>
4385</div>
4386<div class="sect3">
4387<h4 id="mp_set_containss_v">mp_set_contains&lt;S, V&gt;</h4>
4388<div class="literalblock">
4389<div class="content">
4390<pre>template&lt;class S, class V&gt; using mp_set_contains = /*...*/;</pre>
4391</div>
4392</div>
4393<div class="paragraph">
4394<p><code>mp_set_contains&lt;S, V&gt;</code> is <code>mp_true</code> if the type <code>V</code> is an element of the set <code>S</code>, <code>mp_false</code> otherwise.</p>
4395</div>
4396</div>
4397<div class="sect3">
4398<h4 id="mp_set_push_backs_t">mp_set_push_back&lt;S, T&#8230;&#8203;&gt;</h4>
4399<div class="literalblock">
4400<div class="content">
4401<pre>template&lt;class S, class... T&gt; using mp_set_push_back = /*...*/;</pre>
4402</div>
4403</div>
4404<div class="paragraph">
4405<p>For each <code>T1</code> in <code>T&#8230;&#8203;</code>, <code>mp_set_push_back&lt;S, T&#8230;&#8203;&gt;</code> appends <code>T1</code> to the end of the set <code>S</code> if it&#8217;s not already an element of <code>S</code>.</p>
4406</div>
4407</div>
4408<div class="sect3">
4409<h4 id="mp_set_push_fronts_t">mp_set_push_front&lt;S, T&#8230;&#8203;&gt;</h4>
4410<div class="literalblock">
4411<div class="content">
4412<pre>template&lt;class S, class... T&gt; using mp_set_push_front = /*...*/;</pre>
4413</div>
4414</div>
4415<div class="paragraph">
4416<p><code>mp_set_push_front&lt;S, T&#8230;&#8203;&gt;</code> inserts at the front of the set <code>S</code> those elements of <code>T&#8230;&#8203;</code> for which <code>S</code> does not already contain the same type.</p>
4417</div>
4418</div>
4419<div class="sect3">
4420<h4 id="mp_set_unionl">mp_set_union&lt;L&#8230;&#8203;&gt;</h4>
4421<div class="literalblock">
4422<div class="content">
4423<pre>template&lt;class... L&gt; using mp_set_union = /*...*/;</pre>
4424</div>
4425</div>
4426<div class="paragraph">
4427<p><code>mp_set_union&lt;S, L&#8230;&#8203;&gt;</code> is <code>mp_set_push_back&lt;S, T&#8230;&#8203;&gt;</code>, where <code>T&#8230;&#8203;</code> are the combined elements of the lists <code>L&#8230;&#8203;</code>.
4428<code>mp_set_union&lt;&gt;</code> is <code>mp_list&lt;&gt;</code>.</p>
4429</div>
4430</div>
4431<div class="sect3">
4432<h4 id="mp_set_intersections">mp_set_intersection&lt;S&#8230;&#8203;&gt;</h4>
4433<div class="literalblock">
4434<div class="content">
4435<pre>template&lt;class... S&gt; using mp_set_intersection = /*...*/;</pre>
4436</div>
4437</div>
4438<div class="paragraph">
4439<p><code>mp_set_intersection&lt;S&#8230;&#8203;&gt;</code> returns a set that contains the elements that occur in all of the sets <code>S&#8230;&#8203;</code>.
4440<code>mp_set_intersection&lt;&gt;</code> is <code>mp_list&lt;&gt;</code>.</p>
4441</div>
4442</div>
4443<div class="sect3">
4444<h4 id="mp_set_differencel_s">mp_set_difference&lt;L, S&#8230;&#8203;&gt;</h4>
4445<div class="literalblock">
4446<div class="content">
4447<pre>template&lt;class L, class... S&gt; using mp_set_difference = /*...*/;</pre>
4448</div>
4449</div>
4450<div class="paragraph">
4451<p><code>mp_set_difference&lt;L, S&#8230;&#8203;&gt;</code> removes the elements of the list <code>L</code> that appear in any of the sets <code>S&#8230;&#8203;</code> and
4452returns the result.</p>
4453</div>
4454</div>
4455</div>
4456<div class="sect2">
4457<h3 id="map">Map Operations, &lt;boost/mp11/map.hpp&gt;</h3>
4458<div class="paragraph">
4459<p>A map is a list of lists, the inner lists having at least one element (the key.) The keys of the map must be unique.</p>
4460</div>
4461<div class="sect3">
4462<h4 id="mp_is_mapm">mp_is_map&lt;M&gt;</h4>
4463<div class="literalblock">
4464<div class="content">
4465<pre>template&lt;class M&gt; using mp_is_map = /*...*/;</pre>
4466</div>
4467</div>
4468<div class="paragraph">
4469<p><code>mp_is_map&lt;M&gt;</code> is <code>mp_true</code> if <code>M</code> is a map, <code>mp_false</code> otherwise.</p>
4470</div>
4471</div>
4472<div class="sect3">
4473<h4 id="mp_map_findm_k">mp_map_find&lt;M, K&gt;</h4>
4474<div class="literalblock">
4475<div class="content">
4476<pre>template&lt;class M, class K&gt; using mp_map_find = /*...*/;</pre>
4477</div>
4478</div>
4479<div class="paragraph">
4480<p><code>mp_map_find&lt;M, K&gt;</code> is an alias for the element of the map <code>M</code> with a key <code>K</code>, or for <code>void</code>, if there is no such element.</p>
4481</div>
4482</div>
4483<div class="sect3">
4484<h4 id="mp_map_containsm_k">mp_map_contains&lt;M, K&gt;</h4>
4485<div class="literalblock">
4486<div class="content">
4487<pre>template&lt;class M, class K&gt; using mp_map_contains =
4488    mp_not&lt;std::is_same&lt;mp_map_find&lt;M, K&gt;, void&gt;&gt;;</pre>
4489</div>
4490</div>
4491<div class="paragraph">
4492<p><code>mp_map_contains&lt;M, K&gt;</code> is <code>mp_true</code> if the map <code>M</code> contains an element with a key <code>K</code>, <code>mp_false</code> otherwise.</p>
4493</div>
4494</div>
4495<div class="sect3">
4496<h4 id="mp_map_insertm_t">mp_map_insert&lt;M, T&gt;</h4>
4497<div class="literalblock">
4498<div class="content">
4499<pre>template&lt;class M, class T&gt; using mp_map_insert =
4500    mp_if&lt; mp_map_contains&lt;M, mp_first&lt;T&gt;&gt;, M, mp_push_back&lt;M, T&gt; &gt;;</pre>
4501</div>
4502</div>
4503<div class="paragraph">
4504<p>Inserts the element <code>T</code> into the map <code>M</code>, if an element with a key <code>mp_first&lt;T&gt;</code> is not already in <code>M</code>.</p>
4505</div>
4506</div>
4507<div class="sect3">
4508<h4 id="mp_map_replacem_t">mp_map_replace&lt;M, T&gt;</h4>
4509<div class="literalblock">
4510<div class="content">
4511<pre>template&lt;class M, class T&gt; using mp_map_replace = /*...*/;</pre>
4512</div>
4513</div>
4514<div class="paragraph">
4515<p>If the map <code>M</code> does not contain an element with a key <code>mp_first&lt;T&gt;</code>, inserts it (using <code>mp_push_back&lt;M, T&gt;</code>); otherwise,
4516replaces the existing element with <code>T</code>.</p>
4517</div>
4518</div>
4519<div class="sect3">
4520<h4 id="mp_map_updatem_t_f">mp_map_update&lt;M, T, F&gt;</h4>
4521<div class="literalblock">
4522<div class="content">
4523<pre>template&lt;class M, class T, template&lt;class...&gt; class F&gt; using mp_map_update = /*...*/;</pre>
4524</div>
4525</div>
4526<div class="paragraph">
4527<p>If the map <code>M</code> does not contain an element with a key <code>mp_first&lt;T&gt;</code>, inserts it (using <code>mp_push_back&lt;M, T&gt;</code>); otherwise,
4528replaces the existing element <code>L&lt;X, Y&#8230;&#8203;&gt;</code> with <code>L&lt;X, F&lt;X, Y&#8230;&#8203;&gt;&gt;</code>.</p>
4529</div>
4530<div class="listingblock">
4531<div class="title">Code Example 69. Using mp_map_update to count the number of occurrences of types in a list</div>
4532<div class="content">
4533<pre class="highlight"><code>template&lt;class T, class U&gt; using inc2nd = mp_int&lt;U::value + 1&gt;;
4534
4535template&lt;class M, class T&gt; using count_types =
4536    mp_map_update&lt;M, std::pair&lt;T, mp_int&lt;1&gt;&gt;, inc2nd&gt;;
4537
4538using L1 = mp_list&lt;float, char, float, float, float, float, char, float&gt;;
4539
4540using R1 = mp_fold&lt;L1, std::tuple&lt;&gt;, count_types&gt;;
4541// std::tuple&lt;std::pair&lt;float, mp_int&lt;6&gt;&gt;, std::pair&lt;char, mp_int&lt;2&gt;&gt;&gt;</code></pre>
4542</div>
4543</div>
4544</div>
4545<div class="sect3">
4546<h4 id="mp_map_update_qm_t_q">mp_map_update_q&lt;M, T, Q&gt;</h4>
4547<div class="literalblock">
4548<div class="content">
4549<pre>template&lt;class M, class T, class Q&gt; using mp_map_update_q =
4550    mp_map_update&lt;M, T, Q::template fn&gt;;</pre>
4551</div>
4552</div>
4553<div class="paragraph">
4554<p>As <code>mp_map_update</code>, but takes a quoted metafunction.</p>
4555</div>
4556</div>
4557<div class="sect3">
4558<h4 id="mp_map_erasem_k">mp_map_erase&lt;M, K&gt;</h4>
4559<div class="literalblock">
4560<div class="content">
4561<pre>template&lt;class M, class K&gt; using mp_map_erase = /*...*/;</pre>
4562</div>
4563</div>
4564<div class="paragraph">
4565<p>If the map <code>M</code> contains an element with a key <code>K</code>, removes it.</p>
4566</div>
4567</div>
4568<div class="sect3">
4569<h4 id="mp_map_keysm">mp_map_keys&lt;M&gt;</h4>
4570<div class="literalblock">
4571<div class="content">
4572<pre>template&lt;class M&gt; using mp_map_keys = mp_transform&lt;mp_first, M&gt;;</pre>
4573</div>
4574</div>
4575<div class="paragraph">
4576<p><code>mp_map_keys&lt;M&gt;</code> returns a list of the keys of <code>M</code>. When <code>M</code> is a valid map, the keys are unique, so the result is a set.</p>
4577</div>
4578</div>
4579</div>
4580<div class="sect2">
4581<h3 id="function">Helper Metafunctions, &lt;boost/mp11/function.hpp&gt;</h3>
4582<div class="sect3">
4583<h4 id="mp_voidt">mp_void&lt;T&#8230;&#8203;&gt;</h4>
4584<div class="literalblock">
4585<div class="content">
4586<pre>template&lt;class... T&gt; using mp_void = void;</pre>
4587</div>
4588</div>
4589<div class="paragraph">
4590<p>Same as <code>std::void_t</code> from C++17.</p>
4591</div>
4592</div>
4593<div class="sect3">
4594<h4 id="mp_andt">mp_and&lt;T&#8230;&#8203;&gt;</h4>
4595<div class="literalblock">
4596<div class="content">
4597<pre>template&lt;class... T&gt; using mp_and = /*...*/;</pre>
4598</div>
4599</div>
4600<div class="paragraph">
4601<p><code>mp_and&lt;T&#8230;&#8203;&gt;</code> applies <code>mp_to_bool</code> to the types in <code>T&#8230;&#8203;</code>, in order. If the result of an application is <code>mp_false</code>, <code>mp_and</code>
4602returns <code>mp_false</code>. If the application causes a substitution failure, returns <code>mp_false</code>. If all results are <code>mp_true</code>,
4603returns <code>mp_true</code>. <code>mp_and&lt;&gt;</code> is <code>mp_true</code>.</p>
4604</div>
4605<div class="listingblock">
4606<div class="title">Code Example 70. mp_and behavior</div>
4607<div class="content">
4608<pre class="highlight"><code>using R1 = mp_and&lt;mp_true, mp_true&gt;;   // mp_true
4609
4610using R2 = mp_and&lt;mp_false, void&gt;;     // mp_false, void is not reached
4611
4612using R3 = mp_and&lt;mp_false, mp_false&gt;; // mp_false
4613
4614using R4 = mp_and&lt;void, mp_true&gt;;      // mp_false (!)</code></pre>
4615</div>
4616</div>
4617</div>
4618<div class="sect3">
4619<h4 id="mp_allt">mp_all&lt;T&#8230;&#8203;&gt;</h4>
4620<div class="literalblock">
4621<div class="content">
4622<pre>template&lt;class... T&gt; using mp_all = /*...*/;</pre>
4623</div>
4624</div>
4625<div class="paragraph">
4626<p><code>mp_all&lt;T&#8230;&#8203;&gt;</code> is <code>mp_true</code> if <code>mp_to_bool&lt;U&gt;</code> is <code>mp_true</code> for all types <code>U</code> in <code>T&#8230;&#8203;</code>, <code>mp_false</code> otherwise. Same as
4627<code>mp_and</code>, but does not perform short-circuit evaluation. <code>mp_and&lt;mp_false, void&gt;</code> is <code>mp_false</code>, but <code>mp_all&lt;mp_false, void&gt;</code>
4628is an error because <code>void</code> does not have a nested <code>value</code>. The upside is that <code>mp_all</code> is potentially faster and does not
4629mask substitution failures as <code>mp_and</code> does.</p>
4630</div>
4631<div class="listingblock">
4632<div class="title">Code Example 71. mp_all behavior</div>
4633<div class="content">
4634<pre class="highlight"><code>using R1 = mp_all&lt;mp_true, mp_true&gt;;   // mp_true
4635
4636using R2 = mp_all&lt;mp_false, void&gt;;     // compile-time error
4637
4638using R3 = mp_all&lt;mp_false, mp_false&gt;; // mp_false
4639
4640using R4 = mp_all&lt;void, mp_true&gt;;      // compile-time error</code></pre>
4641</div>
4642</div>
4643</div>
4644<div class="sect3">
4645<h4 id="mp_ort">mp_or&lt;T&#8230;&#8203;&gt;</h4>
4646<div class="literalblock">
4647<div class="content">
4648<pre>template&lt;class... T&gt; using mp_or = /*...*/;</pre>
4649</div>
4650</div>
4651<div class="paragraph">
4652<p><code>mp_or&lt;T&#8230;&#8203;&gt;</code> applies <code>mp_to_bool</code> to the types in <code>T&#8230;&#8203;</code>, in order. If the result of an application is <code>mp_true</code>, <code>mp_or</code>
4653returns <code>mp_true</code>. If all results are <code>mp_false</code>, returns <code>mp_false</code>. <code>mp_or&lt;&gt;</code> is <code>mp_false</code>.</p>
4654</div>
4655<div class="listingblock">
4656<div class="title">Code Example 72. mp_or behavior</div>
4657<div class="content">
4658<pre class="highlight"><code>using R1 = mp_or&lt;mp_true, mp_false&gt;;   // mp_true
4659
4660using R2 = mp_or&lt;mp_true, void&gt;;       // mp_true, void is not reached
4661
4662using R3 = mp_or&lt;mp_false, mp_false&gt;;  // mp_false
4663
4664using R4 = mp_or&lt;void, mp_true&gt;;       // compile-time error</code></pre>
4665</div>
4666</div>
4667</div>
4668<div class="sect3">
4669<h4 id="mp_anyt">mp_any&lt;T&#8230;&#8203;&gt;</h4>
4670<div class="literalblock">
4671<div class="content">
4672<pre>template&lt;class... T&gt; using mp_any = /*...*/;</pre>
4673</div>
4674</div>
4675<div class="paragraph">
4676<p><code>mp_any&lt;T&#8230;&#8203;&gt;</code> is <code>mp_true</code> if <code>mp_to_bool&lt;U&gt;</code> is <code>mp_true</code> for any type <code>U</code> in <code>T&#8230;&#8203;</code>, <code>mp_false</code> otherwise. Same as
4677<code>mp_or</code>, but does not perform short-circuit evaluation.</p>
4678</div>
4679<div class="listingblock">
4680<div class="title">Code Example 73. mp_any behavior</div>
4681<div class="content">
4682<pre class="highlight"><code>using R1 = mp_any&lt;mp_true, mp_false&gt;;  // mp_true
4683
4684using R2 = mp_any&lt;mp_true, void&gt;;      // compile-time error
4685
4686using R3 = mp_any&lt;mp_false, mp_false&gt;; // mp_false
4687
4688using R4 = mp_any&lt;void, mp_true&gt;;      // compile-time error</code></pre>
4689</div>
4690</div>
4691</div>
4692<div class="sect3">
4693<h4 id="mp_samet">mp_same&lt;T&#8230;&#8203;&gt;</h4>
4694<div class="literalblock">
4695<div class="content">
4696<pre>template&lt;class... T&gt; using mp_same = /*...*/;</pre>
4697</div>
4698</div>
4699<div class="paragraph">
4700<p><code>mp_same&lt;T&#8230;&#8203;&gt;</code> is <code>mp_true</code> if all the types in <code>T&#8230;&#8203;</code> are the same type, <code>mp_false</code> otherwise. <code>mp_same&lt;&gt;</code> is <code>mp_true</code>.</p>
4701</div>
4702</div>
4703<div class="sect3">
4704<h4 id="mp_similart">mp_similar&lt;T&#8230;&#8203;&gt;</h4>
4705<div class="literalblock">
4706<div class="content">
4707<pre>template&lt;class... T&gt; using mp_similar = /*...*/;</pre>
4708</div>
4709</div>
4710<div class="paragraph">
4711<p><code>mp_similar&lt;T&#8230;&#8203;&gt;</code> is <code>mp_true</code> if all the types in <code>T&#8230;&#8203;</code> are the same type, or instantiations of the same class template
4712whose parameters are all types, <code>mp_false</code> otherwise. <code>mp_similar&lt;&gt;</code> is <code>mp_true</code>.</p>
4713</div>
4714<div class="listingblock">
4715<div class="title">Code Example 74. mp_similar</div>
4716<div class="content">
4717<pre class="highlight"><code>using R1 = mp_similar&lt;void&gt;;                        // mp_true
4718using R2 = mp_similar&lt;void, void&gt;;                  // mp_true
4719using R3 = mp_similar&lt;void, void, void&gt;;            // mp_true
4720using R4 = mp_similar&lt;void, void, float&gt;;           // mp_false
4721
4722template&lt;class T&gt; struct X;
4723template&lt;class... T&gt; struct Y;
4724
4725using R5 = mp_similar&lt;X&lt;int&gt;, X&lt;void&gt;, X&lt;float&gt;&gt;;   // mp_true
4726using R6 = mp_similar&lt;Y&lt;&gt;, Y&lt;void&gt;, Y&lt;void, void&gt;&gt;; // mp_true
4727using R7 = mp_similar&lt;X&lt;void&gt;, Y&lt;void&gt;&gt;;            // mp_false</code></pre>
4728</div>
4729</div>
4730</div>
4731<div class="sect3">
4732<h4 id="mp_plust">mp_plus&lt;T&#8230;&#8203;&gt;</h4>
4733<div class="literalblock">
4734<div class="content">
4735<pre>template&lt;class... T&gt; using mp_plus = /*...*/;</pre>
4736</div>
4737</div>
4738<div class="paragraph">
4739<p><code>mp_plus&lt;T&#8230;&#8203;&gt;</code> is an integral constant type with a value that is the sum of <code>U::value</code> for all types <code>U</code> in <code>T&#8230;&#8203;</code>.
4740<code>mp_plus&lt;&gt;</code> is <code>mp_int&lt;0&gt;</code>.</p>
4741</div>
4742</div>
4743<div class="sect3">
4744<h4 id="mp_lesst1_t2">mp_less&lt;T1, T2&gt;</h4>
4745<div class="literalblock">
4746<div class="content">
4747<pre>template&lt;class T1, class T2&gt; using mp_less = /*...*/;</pre>
4748</div>
4749</div>
4750<div class="paragraph">
4751<p><code>mp_less&lt;T1, T2&gt;</code> is <code>mp_true</code> when the numeric value of <code>T1::value</code> is less than the numeric value of <code>T2::value</code>,
4752<code>mp_false</code> otherwise.</p>
4753</div>
4754<div class="paragraph">
4755<p>(Note that this is not necessarily the same as <code>T1::value &lt; T2::value</code> when comparing between signed and unsigned types;
4756<code>-1 &lt; 1u</code> is <code>false</code>, but <code>mp_less&lt;mp_int&lt;-1&gt;, mp_size_t&lt;1&gt;&gt;</code> is <code>mp_true</code>.)</p>
4757</div>
4758</div>
4759<div class="sect3">
4760<h4 id="mp_mint1_t">mp_min&lt;T1, T&#8230;&#8203;&gt;</h4>
4761<div class="literalblock">
4762<div class="content">
4763<pre>template&lt;class T1, class... T&gt; using mp_min = mp_min_element&lt;mp_list&lt;T1, T...&gt;, mp_less&gt;;</pre>
4764</div>
4765</div>
4766<div class="paragraph">
4767<p><code>mp_min&lt;T&#8230;&#8203;&gt;</code> returns the type <code>U</code> in <code>T&#8230;&#8203;</code> with the lowest <code>U::value</code>.</p>
4768</div>
4769</div>
4770<div class="sect3">
4771<h4 id="mp_maxt1_t">mp_max&lt;T1, T&#8230;&#8203;&gt;</h4>
4772<div class="literalblock">
4773<div class="content">
4774<pre>template&lt;class T1, class... T&gt; using mp_max = mp_max_element&lt;mp_list&lt;T1, T...&gt;, mp_less&gt;;</pre>
4775</div>
4776</div>
4777<div class="paragraph">
4778<p><code>mp_max&lt;T&#8230;&#8203;&gt;</code> returns the type <code>U</code> in <code>T&#8230;&#8203;</code> with the highest <code>U::value</code>.</p>
4779</div>
4780</div>
4781</div>
4782<div class="sect2">
4783<h3 id="bind">Bind, &lt;boost/mp11/bind.hpp&gt;</h3>
4784<div class="sect3">
4785<h4 id="mp_argi">mp_arg&lt;I&gt;</h4>
4786<div class="literalblock">
4787<div class="content">
4788<pre>template&lt;std::size_t I&gt; struct mp_arg;</pre>
4789</div>
4790</div>
4791<div class="paragraph">
4792<p><code>mp_arg&lt;I&gt;</code> is a quoted metafunction whose nested template <code>fn&lt;T&#8230;&#8203;&gt;</code> returns the <code>I</code>-th zero-based element of <code>T&#8230;&#8203;</code>.</p>
4793</div>
4794</div>
4795<div class="sect3">
4796<h4 id="1_9">_1, &#8230;&#8203;, _9</h4>
4797<div class="literalblock">
4798<div class="content">
4799<pre>using _1 = mp_arg&lt;0&gt;;
4800using _2 = mp_arg&lt;1&gt;;
4801using _3 = mp_arg&lt;2&gt;;
4802using _4 = mp_arg&lt;3&gt;;
4803using _5 = mp_arg&lt;4&gt;;
4804using _6 = mp_arg&lt;5&gt;;
4805using _7 = mp_arg&lt;6&gt;;
4806using _8 = mp_arg&lt;7&gt;;
4807using _9 = mp_arg&lt;8&gt;;</pre>
4808</div>
4809</div>
4810<div class="paragraph">
4811<p><code>_1</code> to <code>_9</code> are placeholder types, the equivalent to the placeholders of <code>boost::bind</code>.</p>
4812</div>
4813</div>
4814<div class="sect3">
4815<h4 id="mp_bindf_t">mp_bind&lt;F, T&#8230;&#8203;&gt;</h4>
4816<div class="literalblock">
4817<div class="content">
4818<pre>template&lt;template&lt;class...&gt; class F, class... T&gt; struct mp_bind;</pre>
4819</div>
4820</div>
4821<div class="paragraph">
4822<p><code>mp_bind&lt;F, T&#8230;&#8203;&gt;</code> is a quoted metafunction that implements the type-based
4823equivalent of <code>boost::bind</code>. Its nested template <code>fn&lt;U&#8230;&#8203;&gt;</code> returns <code>F&lt;V&#8230;&#8203;&gt;</code>,
4824where <code>V&#8230;&#8203;</code> is <code>T&#8230;&#8203;</code> with the placeholders replaced by the corresponding
4825element of <code>U&#8230;&#8203;</code> and the <code>mp_bind</code>, <code>mp_bind_front</code>, and <code>mp_bind_back</code>
4826expressions replaced with their corresponding evaluations against <code>U&#8230;&#8203;</code>.</p>
4827</div>
4828<div class="paragraph">
4829<p>For example, <code>mp_bind&lt;F, int, _2, mp_bind&lt;G, _1&gt;&gt;::fn&lt;float, void&gt;</code> is <code>F&lt;int, void, G&lt;float&gt;&gt;</code>.</p>
4830</div>
4831</div>
4832<div class="sect3">
4833<h4 id="mp_bind_qq_t">mp_bind_q&lt;Q, T&#8230;&#8203;&gt;</h4>
4834<div class="literalblock">
4835<div class="content">
4836<pre>template&lt;class Q, class... T&gt; using mp_bind_q = mp_bind&lt;Q::template fn, T...&gt;;</pre>
4837</div>
4838</div>
4839<div class="paragraph">
4840<p>As <code>mp_bind</code>, but takes a quoted metafunction.</p>
4841</div>
4842</div>
4843<div class="sect3">
4844<h4 id="mp_bind_frontf_t">mp_bind_front&lt;F, T&#8230;&#8203;&gt;</h4>
4845<div class="literalblock">
4846<div class="content">
4847<pre>template&lt;template&lt;class...&gt; class F, class... T&gt; struct mp_bind_front;</pre>
4848</div>
4849</div>
4850<div class="paragraph">
4851<p><code>mp_bind_front&lt;F, T&#8230;&#8203;&gt;</code> binds the leftmost arguments of <code>F</code> to <code>T&#8230;&#8203;</code>. Its nested template <code>fn&lt;U&#8230;&#8203;&gt;</code> returns <code>F&lt;T&#8230;&#8203;, U&#8230;&#8203;&gt;</code>.</p>
4852</div>
4853</div>
4854<div class="sect3">
4855<h4 id="mp_bind_front_qq_t">mp_bind_front_q&lt;Q, T&#8230;&#8203;&gt;</h4>
4856<div class="literalblock">
4857<div class="content">
4858<pre>template&lt;class Q, class... T&gt; using mp_bind_front_q =
4859    mp_bind_front&lt;Q::template fn, T...&gt;;</pre>
4860</div>
4861</div>
4862<div class="paragraph">
4863<p>As <code>mp_bind_front</code>, but takes a quoted metafunction.</p>
4864</div>
4865</div>
4866<div class="sect3">
4867<h4 id="mp_bind_backf_t">mp_bind_back&lt;F, T&#8230;&#8203;&gt;</h4>
4868<div class="literalblock">
4869<div class="content">
4870<pre>template&lt;template&lt;class...&gt; class F, class... T&gt; struct mp_bind_back;</pre>
4871</div>
4872</div>
4873<div class="paragraph">
4874<p><code>mp_bind_back&lt;F, T&#8230;&#8203;&gt;</code> binds the rightmost arguments of <code>F</code> to <code>T&#8230;&#8203;</code>. Its nested template <code>fn&lt;U&#8230;&#8203;&gt;</code> returns <code>F&lt;U&#8230;&#8203;, T&#8230;&#8203;&gt;</code>.</p>
4875</div>
4876</div>
4877<div class="sect3">
4878<h4 id="mp_bind_back_qq_t">mp_bind_back_q&lt;Q, T&#8230;&#8203;&gt;</h4>
4879<div class="literalblock">
4880<div class="content">
4881<pre>template&lt;class Q, class... T&gt; using mp_bind_back_q =
4882    mp_bind_back&lt;Q::template fn, T...&gt;;</pre>
4883</div>
4884</div>
4885<div class="paragraph">
4886<p>As <code>mp_bind_back</code>, but takes a quoted metafunction.</p>
4887</div>
4888</div>
4889</div>
4890<div class="sect2">
4891<h3 id="integer_sequence">Integer Sequences, &lt;boost/mp11/integer_sequence.hpp&gt;</h3>
4892<div class="sect3">
4893<h4 id="integer_sequencet_i">integer_sequence&lt;T, I&#8230;&#8203;&gt;</h4>
4894<div class="literalblock">
4895<div class="content">
4896<pre>template&lt;class T, T... I&gt; struct integer_sequence
4897{
4898};</pre>
4899</div>
4900</div>
4901<div class="paragraph">
4902<p><code>integer_sequence&lt;T, I&#8230;&#8203;&gt;</code> holds a sequence of integers of type <code>T</code>. Same as C++14&#8217;s <code>std::integer_sequence</code>.</p>
4903</div>
4904</div>
4905<div class="sect3">
4906<h4 id="make_integer_sequencet_n">make_integer_sequence&lt;T, N&gt;</h4>
4907<div class="literalblock">
4908<div class="content">
4909<pre>template&lt;class T, T N&gt; using make_integer_sequence = /*...*/;</pre>
4910</div>
4911</div>
4912<div class="paragraph">
4913<p><code>make_integer_sequence&lt;T, N&gt;</code> is <code>integer_sequence&lt;T, 0, 1, &#8230;&#8203;, N-1&gt;</code>. Same as C++14&#8217;s <code>std::make_integer_sequence</code>.</p>
4914</div>
4915</div>
4916<div class="sect3">
4917<h4 id="index_sequencei">index_sequence&lt;I&#8230;&#8203;&gt;</h4>
4918<div class="literalblock">
4919<div class="content">
4920<pre>template&lt;std::size_t... I&gt; using index_sequence = integer_sequence&lt;std::size_t, I...&gt;;</pre>
4921</div>
4922</div>
4923<div class="paragraph">
4924<p><code>index_sequence&lt;I&#8230;&#8203;&gt;</code> is an alias for <code>integer_sequence&lt;size_t, I&#8230;&#8203;&gt;</code>. Same as C++14&#8217;s <code>std::index_sequence</code>.</p>
4925</div>
4926</div>
4927<div class="sect3">
4928<h4 id="make_index_sequencen">make_index_sequence&lt;N&gt;</h4>
4929<div class="literalblock">
4930<div class="content">
4931<pre>template&lt;std::size_t N&gt; using make_index_sequence =
4932    make_integer_sequence&lt;std::size_t, N&gt;;</pre>
4933</div>
4934</div>
4935<div class="paragraph">
4936<p><code>make_index_sequence&lt;N&gt;</code> is <code>index_sequence&lt;0, 1, &#8230;&#8203;, N-1&gt;</code>. Same as C++14&#8217;s <code>std::make_index_sequence</code>.</p>
4937</div>
4938</div>
4939<div class="sect3">
4940<h4 id="index_sequence_fort">index_sequence_for&lt;T&#8230;&#8203;&gt;</h4>
4941<div class="literalblock">
4942<div class="content">
4943<pre>template&lt;class... T&gt; using index_sequence_for =
4944    make_integer_sequence&lt;std::size_t, sizeof...(T)&gt;;</pre>
4945</div>
4946</div>
4947<div class="paragraph">
4948<p><code>index_sequence_for&lt;N&gt;</code> is <code>make_index_sequence&lt;sizeof&#8230;&#8203;(T)&gt;</code>. Same as C++14&#8217;s <code>std::index_sequence_for</code>.</p>
4949</div>
4950</div>
4951</div>
4952<div class="sect2">
4953<h3 id="tuple">Tuple Operations, &lt;boost/mp11/tuple.hpp&gt;</h3>
4954<div class="sect3">
4955<h4 id="tuple_applyf_tp">tuple_apply(f, tp)</h4>
4956<div class="literalblock">
4957<div class="content">
4958<pre>template&lt;class F, class Tp&gt; constexpr /*...*/ tuple_apply(F&amp;&amp; f, Tp&amp;&amp; tp);</pre>
4959</div>
4960</div>
4961<div class="paragraph">
4962<p><code>tuple_apply(f, tp)</code> returns <code>std::forward&lt;F&gt;(f)(std::get&lt;J&gt;(std::forward&lt;Tp&gt;(tp))&#8230;&#8203;)</code> for <code>J</code> in 0..<code>N-1</code>,
4963where <code>N</code> is <code>std::tuple_size&lt;typename std::remove_reference&lt;Tp&gt;::type&gt;::value</code>. Same as <code>std::apply</code> in C++17.</p>
4964</div>
4965</div>
4966<div class="sect3">
4967<h4 id="construct_from_tuplettp">construct_from_tuple&lt;T&gt;(tp)</h4>
4968<div class="literalblock">
4969<div class="content">
4970<pre>template&lt;class T, class Tp&gt; T construct_from_tuple(Tp&amp;&amp; tp);</pre>
4971</div>
4972</div>
4973<div class="paragraph">
4974<p><code>construct_from_tuple&lt;T&gt;(tp)</code> returns <code>T(std::get&lt;J&gt;(std::forward&lt;Tp&gt;(tp))&#8230;&#8203;)</code> for <code>J</code> in 0..<code>N-1</code>,
4975where <code>N</code> is <code>std::tuple_size&lt;typename std::remove_reference&lt;Tp&gt;::type&gt;::value</code>. Same as <code>std::make_from_tuple</code> in C&#43;&#43;17.
4976The name of the function doesn&#8217;t match the C&#43;&#43;17 one to avoid ambiguities when both are visible or in unqualified calls.</p>
4977</div>
4978</div>
4979<div class="sect3">
4980<h4 id="tuple_for_eachtp_f">tuple_for_each(tp, f)</h4>
4981<div class="literalblock">
4982<div class="content">
4983<pre>template&lt;class Tp, class F&gt; constexpr F tuple_for_each(Tp&amp;&amp; tp, F&amp;&amp; f);</pre>
4984</div>
4985</div>
4986<div class="paragraph">
4987<p><code>tuple_for_each(tp, f)</code> applies the function object <code>f</code> to each element of <code>tp</code> in order by evaluating the
4988expression <code>f(std::get&lt;J&gt;(std::forward&lt;Tp&gt;(tp)))</code> for <code>J</code> in 0..<code>N-1</code>, where <code>N</code> is <code>std::tuple_size&lt;typename std::remove_reference&lt;Tp&gt;::type&gt;::value</code>.</p>
4989</div>
4990<div class="paragraph">
4991<p>Returns <code>std::forward&lt;F&gt;(f)</code>.</p>
4992</div>
4993</div>
4994<div class="sect3">
4995<h4 id="tuple_transformf_tp">tuple_transform(f, tp&#8230;&#8203;)</h4>
4996<div class="literalblock">
4997<div class="content">
4998<pre>template&lt;class F, class... Tp&gt; constexpr /*...*/ tuple_transform(F const&amp; f, Tp&amp;&amp;... tp);</pre>
4999</div>
5000</div>
5001<div class="paragraph">
5002<p><code>tuple_transform(f, tp&#8230;&#8203;)</code> accepts a function object <code>f</code> followed by one or more tuples of equal length
5003(<code>std::tuple</code>, <code>std::pair</code> and <code>std::array</code> are considered tuples.)</p>
5004</div>
5005<div class="paragraph">
5006<p>The callable <code>f</code> must accept as many arguments as there are tuples. The function object is called with the
5007first elements of each tuple, with the second elements of each tuple, and so on, as if by evaluating
5008the expression <code>f(std::get&lt;J&gt;(std::forward&lt;Tp&gt;(tp))&#8230;&#8203;)</code> for <code>J</code> in 0..<code>N-1</code>, where <code>N</code> is the length of
5009the tuples.</p>
5010</div>
5011<div class="paragraph">
5012<p>The order in which the elements of the tuples are processed is unspecified.</p>
5013</div>
5014<div class="paragraph">
5015<p>The results are returned as a <code>std::tuple&lt;T&#8230;&#8203;&gt;</code> with <code>T&#8230;&#8203;</code> deduced from the return values of <code>f</code> (lvalue
5016references are preserved, rvalue references are returned by value.)</p>
5017</div>
5018</div>
5019</div>
5020<div class="sect2">
5021<h3 id="mp11">Convenience Header, &lt;boost/mp11.hpp&gt;</h3>
5022<div class="paragraph">
5023<p>The convenience header <code>&lt;boost/mp11.hpp&gt;</code> includes all of the
5024headers listed previously in this reference.</p>
5025</div>
5026</div>
5027<div class="sect2">
5028<h3 id="mpl">MPL Support, &lt;boost/mp11/mpl.hpp&gt;</h3>
5029<div class="paragraph">
5030<p>The header <code>&lt;boost/mp11/mpl.hpp&gt;</code>, when included, defines the
5031necessary support infrastructure for <code>mp_list</code> and <code>std::tuple</code>
5032to be valid <a href="../../../../libs/mpl">MPL</a> sequences.</p>
5033</div>
5034<div class="admonitionblock note">
5035<table>
5036<tr>
5037<td class="icon">
5038<div class="title">Note</div>
5039</td>
5040<td class="content">
5041<code>mpl.hpp</code> is not included by <code>&lt;boost/mp11.hpp&gt;</code>.
5042</td>
5043</tr>
5044</table>
5045</div>
5046<div class="paragraph">
5047<p>It&#8217;s also possible to only enable support for <code>mp_list</code> by
5048including <code>&lt;boost/mp11/mpl_list.hpp&gt;</code>, and for <code>std::tuple</code>
5049by including <code>&lt;boost/mp11/mpl_tuple.hpp&gt;</code>. This may be required
5050because some libraries, such as Boost.Fusion, contain their own MPL
5051support for <code>std::tuple</code>, which conflicts with Mp11&#8217;s one.</p>
5052</div>
5053</div>
5054</div>
5055</div>
5056<div class="sect1">
5057<h2 id="copyright_license_and_acknowledgments">Appendix A: Copyright, License, and Acknowledgments</h2>
5058<div class="sectionbody">
5059<div class="paragraph">
5060<p>This documentation is</p>
5061</div>
5062<div class="ulist">
5063<ul>
5064<li>
5065<p>Copyright 2017-2019 Peter Dimov</p>
5066</li>
5067<li>
5068<p>Copyright 2017 Bjørn Reese</p>
5069</li>
5070</ul>
5071</div>
5072<div class="paragraph">
5073<p>and is distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</p>
5074</div>
5075<div class="paragraph">
5076<p>The "Simple C&#43;&#43;11 metaprogramming" articles have been graciously converted to Asciidoc format for incorporation
5077into this documentation by Glen Fernandes.</p>
5078</div>
5079</div>
5080</div>
5081</div>
5082<div id="footer">
5083<div id="footer-text">
5084Last updated 2020-08-11 14:56:30 UTC
5085</div>
5086</div>
5087<style>
5088
5089*:not(pre)>code { background: none; color: #600000; }
5090:not(pre):not([class^=L])>code { background: none; color: #600000; }
5091table tr.even, table tr.alt, table tr:nth-of-type(even) { background: none; }
5092
5093</style>
5094</body>
5095</html>